Permalink
Switch branches/tags
Nothing to show
Find file Copy path
1f7f390 Sep 5, 2018
1 contributor

Users who have contributed to this file

executable file 87 lines (45 sloc) 5.31 KB

Local Server Setup

When discussing software, a stack refers to the technologies a particular application is using. On the web, a stack typically entails an operating system, a web server, a database server, and a particular programming language.

For example, in this course when we deploy our applications on a production server, those servers will be using a “LAMP” stack:

  • The L stands for Linux - Main operating system the server is using.
  • The A stands for Apache - Open-source web server.
  • The M stands for MySQL - Open-source database server.
  • The P stands for PHP - Web scripting language.

In order to run, debug, and test our applications, we want to mirror this stack on our own local machines, substituting Linux for whatever operating system we use.spring-2018

We could individually download and install Apache, PHP and MySQL on our computers, but a simpler approach is to use a program that manages all three such as MAMP or XAMPP.

While both MAMP and XAMPP are cross-platform, experience in past semesters suggest that MAMP works best for Mac users and XAMPP works best for PC users, so that is my recommendation. Below are instructions for setting up both.

MAMP Setup on Mac

Download and install MAMP: https://mamp.info/en/downloads

Note: The download includes both free MAMP and MAMP Pro (paid version). You'll only need to use the free MAMP version in this class.

In MAMP > Preferences > Web Server, note that the Document Root is, by default, set to /Applications/MAMP/htdocs, as shown here:

The Document Root is where the server “points to”, i.e. when you access your local site, it will serve files from this directory.

We'll eventually customize the document root as we start building individual applications, but for now you can leave it as is.

Also in Preferences, under Ports click Set Apache & MySQL ports to 80 & 3306:

The default Apache port is 80, so setting it to this makes it so you can access your local sites via the url http://localhost. If your Apache port is something else, for example, 8888, you'd have to access your sites via http://localhost:8888.

After you adjust your ports, MAMP should restart your local server.

If you see two little green dots next to Apache and MySQL Server, you know everything started okay.

If either of these services don't start up, you'll want to read these notes: Local server troubleshooting.

Your first file

With MAMP installed and your local server running, you can test out a simple PHP script— create a new file in a code/text editor and save it as helloworld.php in /Applications/MAMP/htdocs/.

Paste in this code to your helloworld.php file.

Finally, load your helloworld.php file in your browser via this URL http://localhost/helloworld.php.

That's it! Your local server for Mac is installed, running, and tested.

XAMPP Setup on Windows

Download xampp-win32-7.2.9-0-VC15-installer.exe.

Install XAMPP...

Enlarge...

Once installation is complete, from the XAMPP Control Panel, start Apache and MySQL.

If all goes well, Apache and MySQL in the Modules column should light up with a green background.

If either of these services don't start up, you'll want to read these notes: Local Server Troubleshooting.

Your first file

With MAMP installed and your local server running, you can test out a simple PHP script— create a new file in a code/text editor and save it as helloworld.php in c:/xampp/htdocs/. This path is your local server's Document Root which is where you'll put all your web files and projects. You may want to create a shortcut to this directory, because you'll be working in it a lot.

Paste in this code to your helloworld.php file.

Load your helloworld.php file in your browser via http://localhost/helloworld.php.

That's it! Your local server for Windows is installed, running, and tested.