LAMP on Ubuntu 14.04
Here’s a simple, easy to follow guide that will help you set up a fully functional “LAMP“: Linux (duuuuhhh), Apache, MySQL and PHP on your Ubuntu Desktop/ Server
For this tutorial, I am using a Ubuntu 14.04 Desktop, however, the steps remain more or less the same for a majority of other Ubuntu versions as well.
NOTE: The following steps require root (sudo) access to perform.
To get started, launch a terminal in your Ubuntu System, obtain root privileges by typing the sudo -i command.
The next thing to do is to provide a static IP address to your Ubuntu system. Although this can be left as optional, but I highly recommend that you always use static IPs for such Servers.
Make a note of your Ubuntu System’s IP address by executing the ifconfig command. Note down the IP address.
Edit the /etc/network/interfaces file and add the IP address info there. The final outcome of your interface file should look something as shown below:
# vi /etc/network/interfaces
# The Primary Network Interface
iface eth0 inet static
Once these preliminary activities are done, we are now ready to install our LAMP Server.
Installing Apache is a simple process. Simply type in the following command in your terminal and watch the magic happen:
# apt-get install apache2
The installation automatically attempts to start the Apache service. You can check the server’s status by executing the following command:
# service apache2 status
If the service status shows stopped, then start up the apache server by using:
# service apache2 start
Verify Apache was successfully installed by launching a browser window and simply putting your Ubuntu Server’s IP address in there. You should see Apache2 Default Page as shown below:
This involves installing and configuring MySQL Server and Client as well on your Ubuntu system. Type in the commands in your terminal to get started:
# apt-get install mysql-server mysql-client
Along the installation process, you will be prompted to provide the MySQL Server’s administrative (a.k.a root) password. Provide a strong password here.
TIP: I don’t know why, but I have faced issues with accessing MySQL from time to time especially if my password contained an ‘@’ in it. It seems MySQL treats this as some special character or something and does create problems at times. So avoid using the ‘@’ in your password, use whatever else that comes to your damn mind 🙂
Provide the same password again (Just to make sure that you are awake I guess.. 😛 )
Once the installation completes, check the status of your MySQL Server. It should be in the running state.
# service mysql status
You can then access your MySQL Server using the below syntax:
# mysql -u root -p
The next step in out LAMP is PHP.
# apt-get install php5 php5-mysql libapache2-mod-php5
To test your PHP installation, first we need to traverse to the following path and create a simple php file (Here, im gonna call it as info.php)
# cd /var/www/html
# vi php.info
# Add the following contents in your PHP.INFO file
The next thing to do is to restart the apache2 service. You may get a looooong warning message as shown in the image below, but not to worry. That’s there as we haven’t set the FQDN in the apache2 conf file. You can ignore this though for time being..
Open up a browser and type in the Ubuntu server’s IP address followed by the PHP.INFO file in the following format:
If you get a similar output as shown below, then voila.. you got yourself a working LAMP Server!!
Well, its not actually a bonus as such, but a pretty handy tool never the less. Its called as PHPMYADMIN. Ill not go in-depth on this, but just to keep things simple its a PHP based tool meant to administer MySQL databases using a web-based UI. You can read more about it HERE
To install it, type in the following in your terminal:
# apt-get install phpmyadmin
During the installation, it will prompt you to select the “Web Server” to run PHPMYADMIN. Select apache2 and continue
The next few screens, are just used for the configuration of PHPMYADMIN
Provide the administrative password of your MySQL DB to configure PHPMYADMIN
Provide a suitable password for PHPMYADMIN to register with the MySQL DB
Re-enter the password
Congrats! Your PHPMYADMIN is now ready for use.. simply login to the portal using root as the username and the password yhat you set in your earlier steps
You can use the tool to administer the MySQL DB as you want to.
There you have it! A simple LAMP tutorial to help you get started..
Stay tuned for more coming your way..