Install and use a LAMP Server on Ubuntu

If you’ve been wishing that you could install a web server on your Ubuntu PC, you will be pleased to find out that you can install one very easily. All you will need is an Internet connection, and a bit of time. I hope this guide is helpful.

Here’s how to install: Open Synaptic Package Manager. Choose Edit > Mark Packages by Task. Scroll down and check the box beside “LAMP Server.” This will mark apache2, PHP, and MySQL for installation. Apply the changes. You will be prompted for some configuration information. That’s it! Punch http://localhost into your browser’s address box to test your installation.

Now I suppose you want to add some files. The server’s root directory is /var/www. If you navigate there with your file browser you will see the files, and even be able to open them with gedit, but you will not be able to edit them. This is because the directory is owned by root. There are multiple ways to work with this. You can run Nautilus from a terminal (sudo nautilus /var/www), or even create a launcher on your desktop (for this command: gksudo nautilus /var/www). However, you will probably find it more convenient to change the permissions of the /var/www folder. To do this, run Nautilus as root (sudo nautilus), navigate to the /var folder and right-click on the www folder. Give yourself access under the permissions tab. Now you can create and delete files without running your file browser as root.

Feedback welcome!

Oh by the way, you can access the server from another computer on the network as well, provided that your firewall allows incoming traffic onĀ  port 80. Just enter http://your-ip, where your-ip is the ip address of the computer that hosts the server.