How To Install LAMP (Linux, Apache, MySQL, PHP) on Ubuntu 14.04

noah Uncategorized 0 Comments

What is LAMP?
LAMP is a basic server installation of open source software that is also an acronym. The acronym stands for: Linux, Apache, MySQL and PHP.

Since we have Linux installed, we need to focus on installing Apache, MySQL, and PHP.

Requirements
The VPS or server you install this on needs to be Ubuntu 14.04. This tutorial was executed successfully on a 1GB RAM VPS with Ubuntu 14.04 installed.

Lets get started! Go ahead and SSH into your VPS or server.

Step one: Update Repositories
Updating the VPS repositories is very easy. Simply, run the command:

sudo apt-get update

After the VPS has finished updating its repositories, we get to move on to installing Apache.

Step two: Install Apache
Apache is free webserver software that is very commonly used.

To install apache, we are going to run the command:

sudo apt-get install apache2

Apache2 will now install. Keep in mind that since we are executing these commands with sudo, they all get executed with root privileges.

Perfect! Now, lets move on to step two which is installing MySQL.

Step three: Install MySQL
MySQL is a advanced database system that is used to send and retrieve data. It is very commonly used on virtual private servers.

To install MySQL, lets run the command:

sudo apt-get install mysql-server php5-mysql

During this install, it will ask you to enter a new root password for the root MySQL user. Enter the password and hit ok when it asks this. It will ask you twice.

To start setting up MySQL, we need MySQL to create its database structure which allows it to start storing information. Execute the command:

sudo mysql_install_db

Awesome! After that installs, its time to run the secure mysql installation. Run the command:

sudo mysql_secure_installation

During this install, it will ask you many more questions. First it will ask you to enter the MySQL root password you set earlier. Enter that then press enter. After that, you can say ‘n’ to when it asks you if you would like to set a new root password. There is no need to set a new one since you set a secure password earlier in this tutorial. It will then ask you more questions in which you can say ‘Y’ to for all of them. Below is my installation:

Enter current password for root (enter for none):
OK, successfully used password, moving on…

Setting the root password ensures that nobody can log into the MySQL
root user without the proper authorisation.

You already have a root password set, so you can safely answer ‘n’.

Change the root password? [Y/n] n
… skipping.

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…
ERROR 1008 (HY000) at line 1: Can’t drop database ‘test’; database doesn’t exist
… Failed! Not critical, keep moving…
– 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…

All done! If you’ve completed all of the above steps, your MySQL
installation should now be secure.

Thanks for using MySQL!

Great! We have now installed MySQL. Its time to install PHP which is step four!

Step four: Install PHP
PHP is a extremely common web scripting language. Just like apache, PHP is open source.

Lets install PHP. Run the command:

sudo apt-get install php5 libapache2-mod-php5 php5-mcrypt

Perfect! PHP will now install. Once it has finished, your Ubuntu 14.04 server now has the LAMP stack installed!

Leave a Reply