I was working to setup the development environment of this website on Ubuntu 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 20.04/18.04 and Ubuntu 14.04.
Read Also: Useful Commands for Ubuntu Linux
Ubuntu 20.04 or 18.04
Run the following commands to install PHP & MySQL
sudo apt update sudo apt install apache2 mysql-server php sudo apt install php-curl php-gd php-mbstring php-xml php-xmlrpc php-soap php-intl php-zip
To setup PHPMyAdmin:
sudo apt install php php-cgi libapache2-mod-php php-common php-pear php-mbstring sudo a2enconf php7.2-cgi sudo systemctl reload apache2.service sudo apt install phpmyadmin php-gettext
Enter database name and password for this.
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.
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.
If you have any issues with phpMyAdmin and want to reconfigure, try entering this into the Terminal:
To check which php modules are installed:
for more details
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.
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!!