DevCamp/Laptop setup/Linux web server
Quick links:
These instructions assume you are running Ubuntu or Debian. If you are running Fedora or another similar system, you should contact a staffer and get help. (Raise your hand!)
Install Apache and PHP via the package manager
Open up a terminal, as you have done before. Take note: Some of these commands are run with sudo, which will ask you for your password. Those commands have the power to do anything because they run as root. (We use that power sparingly. In general, it can be tempting to add 'sudo' to any command that does not work. Instead, that can make things worse! Raise your hand if something does not work.)
We will use the sqlite database, rather than MySQL, to make setup simpler.
sudo apt-get install apache2 libapache2-mod-php5 php5-sqlite
You will be asked if you really want to; press enter to agree. The "apt-get" program will print a lot of messages while downloading and installing.
Restart the Apache web server (necessary for Debian stable, not for Debian testing; won't hurt on any system):
sudo service apache2 restart
You may see a warning about "ServerName" not being set properly. That warning is safe to ignore.
Save a sample PHP file
In this step, we store a simple PHP file in the place where we believe the web server will run it.
With the terminal you still have open, we change directory into the path used by the web server:
cd /var/www/
(Note: On Fedora, use /var/www/html/ instead.)
We will use the text editor called nano to create a sample PHP file. To start the editor, type this command:
sudo nano -w sample.php
Enter the following text exactly:
<?php echo "sweet"; ?>
Then type Ctrl-o and press enter to save the file. Now, type Ctrl-x to quit.
Finally, load up this URL in your favorite web browser: http://localhost/sample.php . You should see the word "sweet", and nothing else.
If that works, great! If not, raise your hand and get help from a helper.
Clean up (remove) the sample PHP file
Now that we know PHP works, run this command in a terminal to remove the sample file:
sudo rm /var/www/sample.php
Okay, great. Apache is installed, and we know it can run PHP.