January 7th, 2016

Installing Linux, Apache, MySQL, PHP (LAMP) Stack on Ubuntu 14.04

I was working to setup development environment of this website on Ubuntu 14.04 virtual machine. So decided to write a post on it. This post explains how to install LAMP stack (Linux, Apache, MySQL and PHP) on Ubuntu 14.04.

Installation:

Run following commands:

sudo apt-get update
sudo apt-get install apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin

Here libapache2-mod-php5 is installed otherwise you will get following error on running phpMyAdmin even php_mbstring is enabled in php.ini:

phpMyAdmin – Error The mbstring extension is missing. Please check your PHP configuration.

Uninstallation:

If some packages are already installed, you want to clean up/uninstall (To remove Apache and all of its dependencies with), run following commands:

sudo apt-get purge apache2 php5 libapache2-mod-php5 mysql-server libapache2-mod-auth-mysql php5-mysql phpmyadmin

sudo rm -rf /etc/apache2; rm -rf /etc/php5; rm -rf /var/lib/mysql; rm etc/mysql 

After clean up, you can install them from scratch.

Reconfigure phpMyAdmin:

If you have any issues with phpMyAdmin and want to reconfigure, try entering this into the Terminal:

dpkg-reconfigure phpmyadmin

Get Info:

To check which php modules are installed:

php -m

for more details

php --info

To check php and MySQL version

php -v
mysql -V

To restart apache2 service:

service apache2 restart

You can check Apache by running http://localhost in your browser.

Conclusion:

In this post, we have installed LAMP stack. Now you can do it what you want next.. may be WordPress setup, web application setup or anything else. If you are beginner of Ubuntu, you would like to see Useful Commands for Ubuntu Linux.

Enjoy LAMP stack!!