A “LAMP” stack is a group of open source software program that’s typically installed together to allow a server to host dynamic web sites and web apps. The acronym stands for Linux, Apache, MySQL, and PHP. It represents the Linux operating system, with the Apache web server. The site data is stored in a MySQL database, and dynamic content is processed by PHP. For the reason that virtual private server (VPS) is already running Ubuntu, the Linux part is taken care of.The steps in this tutorial require the user to have root privileges on your VPS.
1. Install Apache
To install Apache you have to install the Meta-package apache2. This can be carried out by installing in the Software Centre, or by typing the following command on terminal:
sudo apt-get install apache2
To test if Apache is installed, direct your browser to your server’s IP address. The page should display the words “It works!” .
2. Install MySQL
To install MySQL you have to install the Metapackage mysql-server. This can be carried out by installing in the Software Centre, or by typing in the following command on terminal:
sudo apt-get install mysql-server
In the course of the installation, MySQL will ask to set a root password.After getting installed MySQL, activate it with this command:
End up by running the MySQL set up script:
The prompt will ask you for current root password. Type it in.
3. Install PHP
To install PHP you have to install the Metapackages php5 and libapache2-mod-php5. This can be carried out by installing in the Software Centre, or by running the following command.
sudo apt-get install php5 libapache2-mod-php5
4. Restart Server
Server should restart Apache automatically after the installation of MySQL and PHP. If it does not, execute this command.
sudo /etc/init.d/apache2 restart
5. Check Apache
Open a web browser and navigate to http://localhost/. You should see a message saying It works!
6. Check PHP
You possibly can test your PHP by executing any PHP file from within /var/www/. Alternatively you possibly can execute the following command, which will make PHP run the code with out the need for creating a file .
php -r ‘echo “\n\nYour PHP installation is working fine.\n\n\n”;’
To test PHP, we can create a simple php script called “info.php” file in Apache document root folder. In Ubuntu 14.04, this directory is located at /var/www/html/. We can create the file at that location.
sudo nano /var/www/html/info.php
A blank file is opened, put the following PHP code inside the file
When finished, save and close file.
One can test whether our web server can display content generated by a PHP script.
If this was successful, then your PHP is working as expected.