LAMP Stack is a group of open-source software that set your servers up and running. LAMP stands for Linux, Apache, MySQL and PHP.
The VPS is already running Ubuntu, so the Linux part of the acronym is taken care of!
Now let’s move on to installing the AMP part of LAMP!
Requirements – you should have root privileges on your VPS.
INSTALLING APACHE
Apache is free open software. Almost all the world’s web servers run on apache.
Step 1.
Open terminal and type in the below commands:
sudo apt-get update
sudo apt-get install apache2
You are done! To make sure Apache is installed, just direct your browser to the IP address of your server. The page will show the words ‘It works!’.
Run the following command to find your servers IP address
ifconfig eth0 | grep inet | awk '{ print $2 }'
INSTALLING MySQL
MySQL is a database management system. It organizes and retrieves data.
Step 1. Enter the following command in the terminal to install Mysql
sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql
MySQL will ask you to set a root password. In case you miss this while installation, you can always set it later within the MySQL shell.
Activate mysql with this command:
sudo mysql_install_db
Clean up by the MySQL set up script:
sudo /usr/bin/mysql_secure_installation
A prompt will ask you for your current root password. Type your password in.
Enter current password for root (enter for none):
OK, successfully used password, moving on...
The prompt will ask you if you want to change the password, choose n and move on.
For the further prompt steps, it is easier to choose the yes option. Go ahead and choose y. Mysql will take care of the new changes.
By default, a MySQL installation has an anonymous user, allowing anyone
to log into MySQL without having to have a user account created for
them. This is intended only for testing, and to make the installation
go a bit smoother. You should remove them before moving into a
production environment.
Remove anonymous users? [Y/n] y
... Success!
Normally, root should only be allowed to connect from 'localhost'. This
ensures that someone cannot guess at the root password from the network.
Disallow root login remotely? [Y/n] y
... Success!
By default, MySQL comes with a database named 'test' that anyone can
access. This is also intended only for testing, and should be removed
before moving into a production environment.
Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.
Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...
Now we can move onto installing PHP
INSTALLING PHP
So, PHP is an open-source web scripting language. It is used to create and build dynamic webpages.
Step 1. Type in this command to install PHP:
sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt
The prompt will ask you to confirm the installation twice, just answer yes. And the PHP will be installed.
It is really helpful to add PHP to the directory index :
sudo nano /etc/apache2/mods-enabled/dir.conf
After adding index.php to the beginning of your index files, the page should look like this ;
<IfModule mod_dir.c>
DirectoryIndex index.php index.html index.cgi index.pl index.php index.xhtml index.htm
</IfModule>
Yay! You have successfully installed the LAMP stack on Ubuntu
The end…
Too make sure your components are online, create a php info page.
For this, create a new file :
sudo nano /var/www/info.php
And add the following line:
<?php
phpinfo();
?>
Now, save and exit!
For the effects to take place, restart Apache :
sudo service apache2 restart
Note – make sure you replace the example IP address with your IP address.
Conclude the adventure by visiting you PHP info page!
Found this article helpful? Let us know!
Share Your Comments & Feedback