How to create a LAMP server for PHP development

This post I will show the steps I follow to create a LAMP (Linux, Apache, MySql & PHP) server for PHP development.

I used Ubuntu 18.04 LTS.

The steps are described below:

1. Installing Apache

Install Apache using the following command:

sudo add-apt-repository ppa:ondrej/apache2
sudo apt install apache2


1. Change “www” folder

change the permission of “www” folder:

sudo chmod 777 /var/www
sudo chmod 777 /var/www/*

Help Links


2. Installing MySql 5.7

Install MySQL from apt:

sudo apt install mysql-server

3. Installing PHP 7.2

Install PHP 7.2 using the following command:

sudo add-apt-repository ppa:ondrej/php
sudo apt install php7.2
# Additional Modules:
sudo apt install php-pear php7.2-curl php7.2-dev php7.2-gd php7.2-mbstring php7.2-zip php7.2-mysql php7.2-xml

Help Links


4. Installing phpMyAdmin

First install phpMyAdmin form apt:

sudo apt install phpmyadmin

NOTE: The installation will ask some question during installation:

  1. For the server selection, choose apache2 using <space>.
  2. Select yes when asked whether to use “dbconfig-common” to set up the database
  3. You will be prompted for your database administrator’s password, keep it blank and press Enter.
  4. Then restart the Apache server:
     > sudo systemctl restart apache2


1. “localhost/phpmyadmin” not found!

Open “/etc/apache2/apache2.conf” file in any text editor and add the below line at the end of the file:

Include /etc/phpmyadmin/apache.conf

2. Cannot use the user “root”!

Just use the below commands to use “root” user:

sudo mysql -u root
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY '';

 3. phpMyAdmin Autologin

Open “/etc/phpmyadmin/” file in any text editor and add the following line below “/* Authentication type */“:

 $cfg['Servers'][$i]['auth_type'] = 'config';
 $cfg['Servers'][$i]['user'] = 'root';
 $cfg['Servers'][$i]['password'] = '';

Then un-comment the following line (just remove “//” from the line):

 $cfg['Servers'][$i]['AllowNoPassword'] = TRUE;

There are two instances of this, un-comment both.

4 “no privileges” phpmyadmin create database

just clear cookies of phpmyadmin.

5. “Warning in ./libraries/sql.lib.php#613
count(): Parameter must be an array or an object that implements Countable”

To solve this follow the steps:

  1. Download latest version of phpMyAdmin from here.
  2. Make a backup of the directory “/usr/share/phpmyadmin/“, which is the old version, and is for backup.

    sudo mv phpmyadmin phpmyadmin_backup
    sudo mkdir phpmyadmin
  3. Extract all files of the downloaded zip file to “/usr/share/phpmyadmin/” folder.
  4. Open “libraries/vendor_config.php” file with any text editor and change below line:
    define('CONFIG_DIR', '');


    define('CONFIG_DIR', '/etc/phpmyadmin/');
  5. Restart Apache server.

    sudo service apache2 restart

6. “The $cfg[‘TempDir’] (./tmp/) is not accessible. phpMyAdmin is not able to cache templates and will be slow because of this.”

To solve this problem, create a “tmp” directory in “/usr/share/phpmyadmin/” folder and change its MODE to 777. Use the following command to do both (Terminal base directory must be “/usr/share/phpmyadmin/“):

mkdir tmp && chmod 777 tmp

Help Links


4. Installing Composer

Install Composer from here.

To use the composer globally use the following command:

mv composer.phar /usr/local/bin/composer

Help Links


One thought on “How to create a LAMP server for PHP development

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.