Last updated on April 9th, 2017 at 11:23 am

In my last post i explain how to Installing XAMP server on Ubuntu. Now in this post i explain how we can install Apache, PHP, MySQL and phpMyadmin separately on Ubuntu.

Install Apache

Now first we can install Apache server open terminal or type ctrl+alt+t  to open terminal and run following commands.

sudo apt-get update
sudo apt-get install apache2

After this command terminal download and install Apache packages and then you can type http://localhost if Apache is installed you can see default page of Apache.

Install Apache, PHP, MySql and phpMyAdmin on Ubuntu

Install PHP and MySql

Now run following commands in your terminal and install PHP and MySql.

sudo apt-get install php7.0-mysql
sudo apt-get install mysql-server

after installing MySql you prompt to add your username and password for database set them and done, also run two more command to complete setup

sudo apt-get install php-mbstring php7.0-mbstring php-gettext
sudo apt-get install libapache2-mod-php7.0

Install PHP intl extension and other

Install ppa repository to server.

sudo add-apt-repository ppa:ondrej/php

After PPA repo installed, update the local package cache

sudo apt-get update

run following command to install intl & xsl extensions

sudo apt-get install php7.0-intl
sudo apt-get install php7.0-xsl

check other php extensions

php -m

Install PHP 7 on Apache Ubuntu

Restart server

sudo service apache2 restart

Check phpInfo go to /var/www/html/create_file_phpinfo.php . Open file in any editor and enter <?php echo phpinfo() ?> and go to browser and type http://localhost/phpinfo.php .

Install phpMyAdmin

Run bellow commands on terminal and install phpMyAdmin

sudo apt-get update
sudo apt-get install phpmyadmin

After running command you need to configure your phpMyAdmin so follow step on screen and after this, you also need to include PHPMyAdmin to your Apache Config file type bellow command in terminal and add

sudo nano /etc/apache2/apache2.conf

At the end of file add below code

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

restart Apache server type

sudo service apache2 restart

Now go to the browser and type http://localhost/phpmyadmin if everything go right you can see login screen of phpMyAdmin.

Install Apache, PHP, MySql and phpMyAdmin on Ubuntu

If you get 404 not found error then run below command in terminal to create sortlink

sudo ln -s /usr/share/phpmyadmin /var/www/html

Done 🙂