If you do a lot of web stuff, it is nice to have a web server installed on a computer on your local network. It is a nice way to be able to test and develop websites.
I thought I would share the guide that I wrote one of my friends who wanted to install a simple web server with Apache, MySQL, and PHP on their Ubuntu Desktop. If you have Ubuntu installed, this guide should get you through setting up a simple LAMP. I also detail installing a simple firewall; phpMyAdmin, a web-based database utility; and mod_rewrite, a utility needed for WordPress and many other Content Management Systems.
Note: For code in this font, type the command into a Terminal window.
Install the web server
sudo tasksel
Select “LAMP Server” with the spacebar
If you want to be able to SSH in, you can also select “OpenSSH Server”
Your web server should be installed. That was easy, huh.
Install the ufw firewall
Ufw is a very simple yet customizable firewall, perfect for a web development server.
sudo apt-get install ufw
You can configure this how you like once it is installed. If you do not need any ports other than http (80) and ssh (22) running what I run on my box (below) should work. Let me know if you need another configuration, and I can probably point you toward a guide.
This will essentially make your firewall deny anything that is not explicitly allowed:
sudo default reject
This will allow anyone in the world to access your pages over http:
sudo allow to any port 80
This will allow you to ssh into your server from your IP only:
sudo ufw allow from YOUR IP to any port 22
Install phpMyAdmin
This will allow you to edit your databases in a web-based environment at http://your-hostname/phpmyadmin
sudo apt-get install phpmyadmin
To make it work properly, you will probably have to must add this line:
Include /etc/phpmyadmin/apache.conf
to the very bottom of the file here:
/etc/apache2/apache2.conf
Enable mod_rewrite
This is needed for WordPress to function properly the way it writes its urls.
Go to: /etc/apache2/sites-available/default
and look for AllowOverride. It needs to be changed to either “AllowOverride All” or “AllowOverride None” in each place that it appears in that file (2-3 times I think). Which ever one it is not by default is the one you want. Let me know which one it is so I can make a note in my files.
Keep the machine up to date
sudo apt-get update and sudo apt-get upgrade
You will want to run these commands frequently to make sure that your software is kept up to date.
Restart the machine. Your web server should be setup!!
Test the server
Visit the server. It should be available at http://yourhostname/
Files available on the web will be stored in /var/www/
Go to http://yourhostname/phpmyadmin and make sure you can log in. If it is working, php and MySQL should be working.
Congratulations! You just installed a web server on your computer, perfect for development work!
Welcome to tomlany.net, home of Tom Lany's radio jingles, the latest on Tom's web and journalism projects, and whatever else is on his mind. Tom grew up in the Minneapolis area and is now attending