In about 15 minutes, the time it takes to install Ubuntu Server Edition, you can have a LAMP (Linux, Apache, MySQL and PHP) server up and ready to go. This feature, exclusive to Ubuntu Server Edition, is available at the time of installation.
The LAMP option means you don’t have to install and integrate each of the four separate LAMP components separately. That is a process which can take hours, and requires someone who is highly skilled in the installation and configuration of the individual applications.
Instead, with Ubuntu Server Edition, you get increased security, reduced time-to-install, and reduced risk of misconfiguration. All of which results in a lower cost of ownership.
New pre-configured installation options have been added to the Ubuntu Server. Mail Server, File Server, Print Server, and Database Server options join existing LAMP and DNS options for pre-configured installations. Easing the deployment of common server configurations.
I can’t tell you how many times I have been asked what is the fastest, easiest way to install a LAMP (Linux Apache, MySQL, PHP) server on Ubuntu. Well, I guess it’s time I just post it here for everyone to enjoy.
I am going to assume that this server does not have any of the components pre-installed. I am also going to assume you have sudo permission for the server. So starting with a blank slate we will first install Apache.
To install Apache open the command terminal and enter the following command:
sudo apt-get install apache2
Once this is installed, you want to make sure Apache is up and running. So fire up your browser and point it to https://localhost, or you can type servers’ IP address into the address bar). If you get the message “It Works!” you are good to go.
With Apache installed, let’s move on.
The next step is to install PHP. This will need to be installed so it will have everything needed to integrate with Apache. To do this, issue the command:
sudo apt-get install php5 libapache2-mod-php5
Restart Apache with the Command Terminal with the following command:
sudo /etc/init.d/apache2 restart
Now, it’s time to test to make sure PHP is working. Create a file within /var/www/testphp.php with the following contents:
< ?php phpinfo(); ?>
Save that file in /var/www/ and then point your browser to that file. If all is well you will see the text, “Test PHP Page.” If you see that, you can move to to…
The next step: MySQL.
To install the necessary tools, issue the command:
sudo apt-get install mysql-server
This is where it gets just a bit tricky. You have to first set a password for MySQL. To do this, run the first command in order to get to the mysql prompt and the second to set the password:
mysql -u root
mysql> SET PASSWORD FOR ‘root’@’localhost’ = PASSWORD(‘YOURPASSWORD’);
Where YOURPASSWORD is the actual password you want to use for the root user.
You’re done. You now have a basic LAMP installation. Of course I would suggest taking this further by installing phpmyadmin in order to make creating MySQL databases much easier. But other than that, you are ready to install applications that require the LAMP configuration! If you encountered problems, you can always try with XAMMP for Linux but with Ubuntu Server LAMP installation is a piece of cake, so most likely you won’t encounter any problems.