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-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;
exit

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
myphpadmin-database.

If you want to use wordpress with pretty permalinks (e.g mysite.com/my-new-post) 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

with

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.
e.g.

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.

Speicherbedarf von MariaDB reduzieren und ein bisschen Lizenz-Kram

MariaDBk

MariaDB ist eine Opensource-Datenbank, die zu MySql kompatibel ist.
Selbst die Objekte in den Verzeichnissen tragen die gleichen Namen wie die von MySql.
Das macht eine Migration sehr einfach.
Ich benutzt MariaDB auch als Datenbank für kleinere Projekte im Zusammenhang mit Lazarus und den Zeos-Datenbank-Objekten.

MySql wurde durch die Lizenzbedingungen von Oracle, die MySql von SUN übernommen haben uninteressant.
Man bekommt Lizenzprobleme wenn man die nicht unter der GPL stehende Clientbibliothek libmysql.dll verwendet. Ohne diese Datei ist jedoch ein Aufbau einer Verbindung zur Datenbank unmöglich.
Anfänglich wurde diese DLL auch zum Verbindungsaufbau zu MariaDB benötigt. Damit lief man, wie bei MySql in die Oracle-Lizenz-Falle. Mittlerwiele existiert jedoch eine eingensträndige Bibliothek für MariaDB »libmariadb.dll«, die unter der LGPL lizenziert ist.
Diese kann auf der MariaDB-Webseite heruntergeladen werden.
Somit ist MariaDB jetzt eine 100% zu MySql kompatible Opensource Alternative.
DIe libmariadb.dll arbeitet auch hervorragend mit den Zeos-Data-Objects zusammen.
Benennt man die libmariadb.dll in libmysql.dll um kann auch HeidiSQL damit arbeiten.

Die Installation von MariaDB benötigt rund 600MB Festplattenplatz. Das ist für eine Einplatzlösung meiner Meinung nach schon zuviel, man muß sich aber eben mal für eine Datenbank entscheiden. MySql kannte ich, MariaDB ist dazu kompatibel. Ich habe mir auch mal Firebird angesehen, war aber wenig begeistert.

Beim Start von mysqld.exe von MariaDB fiel mit auf, dass die Datenbank im Leerlauf schon 300MB RAM unter Windows verbrauchte. Dies schien mir unverhältnismäßig hoch zu sein. Durch Suche im Internet habe ich mir dann eine My.ini zusammen gebastelt, bei der der mysqld Prozess noch knapp 50MB benötigt. Man möge jetzt sagen: »Damit läuft die Datenbank wie ein Sack Nüsse«, jedoch merke ich das bei einer Einzelplatzinstallation bzw. wenigen Benutzern nicht.

Bitte bei dieser My.ini auf den Port der Datenbank achten ! Ich benutze den Port 3666 statt dem Standard-Port 3306 um mit evtl. besehenden Installationen nicht zu kollidieren.
Also bei Bedarf einfach ändern.

Mysql.ini für MariDB 5.5

# Example MySQL config file for small systems.
#
# This is for a system with little memory (<= 64M) where MySQL is only used
# from time to time and it’s important that the mysqld daemon
# doesn’t use much resources.
#
# MySQL programs look for option files in a set of
# locations which depend on the deployment platform.
# You can copy this option file to one of those
# locations. For information about these locations, see:
# http://dev.mysql.com/doc/mysql/en/option-files.html
#
# In this file, you can use all long options that a program supports.
# If you want to know which options a program supports, run the program
# with the „–help“ option.

# The following options will be passed to all MySQL clients
[client]
#password    = your_password
port        = 3666
socket        = /tmp/mysql.sock

# Here follows entries for some specific programs

# The MySQL server
[mysqld]
port        = 3666
socket        = /tmp/mysql.sock
skip-external-locking
key_buffer_size = 16K
max_allowed_packet = 1M
###MOD001#####
aria_pagecache_buffer_size = 128K
aria_sort_buffer_size = 128K
query_cache_size = 0
###MOD001#####
table_open_cache = 4
sort_buffer_size = 64K
read_buffer_size = 256K
read_rnd_buffer_size = 256K
net_buffer_length = 2K
thread_stack = 240K

# Don’t listen on a TCP/IP port at all. This can be a security enhancement,
# if all processes that need to connect to mysqld run on the same host.
# All interaction with mysqld must be made via Unix sockets or named pipes.
# Note that using this option without enabling named pipes on Windows
# (using the „enable-named-pipe“ option) will render mysqld useless!
#
#skip-networking
server-id    = 1

# Uncomment the following if you want to log updates
#log-bin=mysql-bin

# binary logging format – mixed recommended
#binlog_format=mixed

# Causes updates to non-transactional engines using statement format to be
# written directly to binary log. Before using this option make sure that
# there are no dependencies between transactional and non-transactional
# tables such as in the statement INSERT INTO t_myisam SELECT * FROM
# t_innodb; otherwise, slaves may diverge from the master.
#binlog_direct_non_transactional_updates=TRUE

# Uncomment the following if you are using InnoDB tables
#innodb_data_home_dir = C:\\mysql\\data\\
innodb_data_file_path = ibdata1:10M:autoextend
#innodb_log_group_home_dir = C:\\mysql\\data\\
# You can set .._buffer_pool_size up to 50 – 80 %
# of RAM but beware of setting memory usage too high
innodb_buffer_pool_size = 16M
innodb_additional_mem_pool_size = 2M
# Set .._log_file_size to 25 % of buffer pool size
innodb_log_file_size = 5M
innodb_log_buffer_size = 8M
innodb_flush_log_at_trx_commit = 1
innodb_lock_wait_timeout = 50

[mysqldump]
quick
max_allowed_packet = 16M

[mysql]
no-auto-rehash
# Remove the next comment character if you are not familiar with SQL
#safe-updates

[myisamchk]
key_buffer_size = 8M
sort_buffer_size = 8M

[mysqlhotcopy]
interactive-timeout