As mentioned in the previous post, I’ve been playing around with my own LAMP (Linux, Apache, MySQL, PHP) stack, and in this post I’ll talk a little bit about my experience installing Apache on my System76 laptop.  Apache is one of the most popular web servers, and runs primarily on Linux.  Apache is a web server, which means it provides web pages in response to HTTP requests.  If you ask for a file called “index.html” that’s stores on any old computer, you won’t get the file.  What you need is a web server like Apache, which processes HTTP requests for HTML files (among other types) and delivers them to the connecting computer.  PHP is a common web scripting language that can execute small programs within an HTML environment.

There are three “programs” we’ll install to finish our LAMP stack (since after my post last time we already have the Linux and MySQL part).  The first is the core Apache module:

sudo apt-get install apache2

.  Next we add PHP:

sudo apt-get install php5

.  Lastly we add a library module that helps them work together:

sudo apt-get install libapache2-mod-php5

.  To get it to get along famously with PHP5 we need to actually enable the module that we just installed:

sudo a2enmod php5

.  When we installed Apache, the service started running, and so now we need to restart the service so that it runs with the PHP5 module we added:

sudo service apache2 restart

(this can also be accomplished with

sudo /etc/init.d/apache2 restart


Now you’re ready to start adding content you want to access through the web.  The default folder for many distributions is /var/www/.  Generally speaking, this is where you’ll put content you want publicly available (or where you’ll put stuff for testing purposes, depending on how you’re using your server).  To access these files, you’ll have to open them through a web browser (Chrome is my browser of choice; just make sure you’re aware of each browser’s peculiarities when you’re constructing scripts).  If you’re testing the files from the computer where they’re stored, you can put in http://localhost/test.php (for example).  If you’re accessing the files from another computer on an intranet or over the internet, you’ll put in the IP address or domain name, of course.  Since PHP is parsed through the web browser, the files will probably download if you try to open them from Nautilus (or the file manager of your choice), so make sure you’re actually putting in a URL in a browser.