Install LAMPP Stack on Ubuntu MATE Xenial Xerus 16.04

I used the Beta 2 Version for this tutorial and have rebuild my whole Ubuntu Mate 14.04 environment on 16.04 Beta 2 from the computer I use every day for business and it works flawless. I like Ubuntu MATE because it is stable. This Beta 2 is more stable than other distros after release date. And I can do all my stuff with this distro like programming in python, php, lazarus, java, making printing templates for the printery with gimp, inkscape, scribus in pdf/x format and icc cmyk profiles, making videos with openshot and all the other things with libreoffiice. MATE is the best balanced DE between resource saving and usability.
For wordpress and web development I need a local web server every day. Php 7 is the most recent version of php, but most web servers use php5 until now.

WordPress works fine with php7 but many plugins have problems. And without plugins wordpress is useless.
So I install php5, because it makes no sense to develop things, that can’t be used in the real live.

Some things are different from the installation on 14.04.
I installed apache2, mariadb, php5 and myphpadmin. lampp

Update 5/29/2016
PHP5 is no longer available in Ubuntu repositories.
You can only install PHP7 from there.

But there is a ppa for PHP5.6.
So the installation process changed.
Here is how to install apache2, mariadb, php5.6 and myphpadmin using the ppa:

First open a terminal and install the packages:

sudo add-apt-repository ppa:ondrej/php
sudo apt update
sudo apt-get install apache2
sudo apt-get install mariadb-server

Mariadb has no root password by default. You should set a password else you will get in trouble with phpmyadmin when logging in from the browser. Change new_password to your new password. To set the root password follow these steps in a terminal:

sudo mysql -uroot -p
use mysql
update user set password=PASSWORD("new_password") where User='root';
update user set plugin='' where User='root';
flush privileges;

Restart mariadb.

systemctl restart mysql

Install PHP5.6 and phpmyadmin

sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring 
sudo apt-get install php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0
sudo apt-get install php php-mysql php5.6-gd phpmyadmin libapache2-mod-php 
sudo apt-get install php5.6-curl php5.6-zip php5.6-xml php5.6-soap 
sudo apt-get install php-mbstring php-gettext php5.6-mcrypt 

Phpmyadmin asks for the password of mariadb while installation. 
If you get an error 1045 while installation, hit „ignore“.
When you start phpmyadmin the first time, a message comes up to install

To switch between PHP5 and PHP7 use a2enmod

sudo a2dismod php5
sudo a2enmod php7.0

The version numbers can differ with the years. You will find all avalible modules at

If you want to use wordpress with pretty permalinks (e.g you have to enable mod_rewrite.

sudo a2enmod rewrite
systemctl restart apache2

Now tell apache to use pretty permalinks and edit the apache config file.

sudo pluma /etc/apache2/apache2.conf

Search for : <Directory /var/www/> and replace

AllowOverride None


AllowOverride All

in this section, save the file and restart apache.

systemctl restart apache2

Now the basic configuration is done and you can use the LAMPP stack as it is.
The root directory is /var/www by default. I don’t like that, because there is always trouble with the permissions. I put the web server root directory in my home directory.
That means no trouble with permissions and it is easy to backup.

Create a new directory as server root in your home directory.

mkdir /home/username/html

Edit the default virtualhost file:

sudo pluma /etc/apache2/sites-available/000-default.conf

change DocumentRoot from /var/www to the path of your new server root
e.g. /home/username/html
Take care: There is NO slash behind the last directory.

Edit apache2.conf:

sudo pluma /etc/apache2/apache2.conf

Search for : <Directory /var/www/> and replace /var/www with your new server root
e.g. /home/username/html/
Take care: There IS a slash behind the last directory.

On my own laptop I don’t deal with permissions so I changed them for the html directory to 777. Never do this on a production machine.

sudo chmod -R 777 /home/username/html

That’s it.