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.
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”.
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.
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.
Open terminal and type:
sudo apt-get install phpmyadmin
This will ask you a few questions in order to configure your installation correctly.
dbconfig-common
to set up the databaseThe 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
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.