Install Linux, Apache, MySQL, PHP on Ubuntu 14.04

This is how I installed Apache, MySQL and PHP on my Ubuntu 14.04 server. Thanks to www.digitalocean.com for this lovely and easy to follow tutorial and www.liquidweb.com for the PHPMyAdmin integration with Apache.

Step One – Install Apache

To install apache, open terminal and type in these commands:

sudo apt-get update
sudo apt-get install apache2

That’s it. To check if Apache is installed, direct your browser to your server’s IP address (eg. http://12.34.56.789). The page should display the “Apache2 Ubuntu Default Page”.

Step Two – Install MySQL

To install MySQL, open terminal and type in these commands:

sudo apt-get install mysql-server libapache2-mod-auth-mysql php5-mysql

During the installation, MySQL will ask you to set a root password. If you miss the chance to set the password while the program is installing, it is very easy to set the password later from within the MySQL shell.

Once you have installed MySQL, we should activate it with this command:

sudo mysql_install_db

Finish up by running the MySQL set up script (not necessary for personal setups):

sudo /usr/bin/mysql_secure_installation

The prompt will ask you for your current root password. Type it in.

Then the prompt will ask you if you want to change the root password. Go ahead and choose N and move on to the next steps.

It’s easiest just to say Yes to all the options. At the end, MySQL will reload and implement the new changes.

Step Three – Install PHP

To install PHP, open terminal and type in this command.

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

After you answer yes to the prompt twice, PHP will install itself.

That’s it. However, I installed PhpMyAdmin because I don’t like using the MySQL shell.

Step Four – Install PHPMyAdmin

Open terminal and type:

sudo apt-get install phpmyadmin

This will ask you a few questions in order to configure your installation correctly.

  • For the server selection, choose apache2. Note: If you do not hit “SPACE” to select Apache, the installer will not move the necessary files during installation. Hit “SPACE”, “TAB”, and then “ENTER” to select Apache.
  • Select yes when asked whether to use dbconfig-common to set up the database
  • You will be prompted for your database administrator’s password
  • You will then be asked to choose and confirm a password for the phpMyAdmin application itself

The installation process actually adds the phpMyAdmin Apache configuration file into the /etc/apache2/conf-enabled/ directory, where it is automatically read.

The only thing we need to do is explicitly enable the php5-mcrypt extension, which we can do by typing:

sudo php5enmod mcrypt

Step Five – Finish the Configuration of Apache

In a terminal window, type the following:

sudo nano /etc/apache2/apache2.conf

At the end of the file, type:

# phpMyAdmin Configuration
Include /etc/phpmyadmin/apache.conf

Save the file by pressing CTRL + O
Next, exit by pressing CTRL + X

Now we just need to restart our Apache server for the changes to take effect. We do this by typing:

sudo service apache2 restart

And we are done! We now have a working web server using Apache with PHP and MySQL installed and PHPMyAdmin to interface with the MySQL databases.

Tags: , , , ,