Run Behat tests on Ubuntu 16.10

Submitted by Peter Majmesku on Wed, 10/19/2016 - 15:35

To make it work you need Selenium standalone in version 2.52 and Firefox in version 45. This combination does work. The others do not. Download Selenium standalone in version 2.52 from

Then modify your


to use the packages from Ubuntu 16.04 Xenial. This is described at Afterwards update your package manager, check for the proper package version and install it:

sudo apt update

sudo apt-cache show firefox | grep Version

sudo apt-get install firefox=45.0.2+build1-0ubuntu1

Afterwards you are able to execute your Behat tests. F.e. by this command:

bin/behat --suite=my-test-suite

Install the Shutter screenshot program on Linux (Mint 18)

Submitted by Peter Majmesku on Mon, 10/17/2016 - 18:24

To install Shutter on Linux (Mint 18) with working screenshot editing extension, you must execute the following command. It will install the required packages via the Ubuntu package manager, which are needed for the screenshot editing extension.

sudo apt install shutter libgoo-canvas-perl gnome-web-photo

Then "restart" your computer. Afterwards Shutter looks like in the attached screenshot. Of course it will be in your operating system language. Mine is German.

Happy screen photographing! (:

Apache 2: Troubleshoot Vhost config for local development

Submitted by Peter Majmesku on Mon, 10/17/2016 - 09:46

General permissions

If you get this message in the webbrowser:

You don't have permission to access / on this server

and this one in the error.log file from Apache:

[Mon Oct 17 08:44:39.025804 2016] [core:error] [pid 8335:tid 139844481865472] (13)Permission denied: [client] AH00035: access to / denied (filesystem path '/home/peter/Dev') because search permissions are missing on a component of the path

then you need to execute the following command on your user folder (for me: /home/peter):

chmod +x /home/YOUR-USERNAME

If Apache is displaying your PHP file's code in the webbrowser, then run this command (worked for PHP7 on Ubuntu 16.04):

sudo apt install php libapache2-mod-php

Cache folder permissions

I assume you have your webroot files in your userfolder at /home/USER. As the PHP process is writing cache files as the www-data user per default (on Ubuntu/Debian), you must configure user and group permissions. Add the www-data user into the user's group and your user into the www-data group. So that they can use their files. The example command is:

sudo usermod -a -G www-data YOUR-USERNAME

sudo usermod -a -G YOUR-USERS-GROUP www-data

Then make the www-data user (as which Apache is acting), act by your user's group. This setting can be made in the file at /etc/apache2/envvars. Modify the lines as follows:

export APACHE_RUN_USER=www-data

Git: Squashing multiple commits to one

Submitted by Peter Majmesku on Tue, 10/04/2016 - 21:14

Let's say you are done with an new feature. Now you want to merge your feature into the master or develop branch. To keep a good overview within your Git log, you want just 1 Git commit within your log. You do not want all Git commits which you have made during the development in your Git log. Because this would pollute the Git log.

The following way firstly checks out your master branch. Then you are "squashing" all your Git commits to 1 commit. Afterwards you specify the 1 commit which holds your changes.

$ git checkout master
$ git merge --squash yourBranch
$ git commit -m "[#MY-TICKET-ID] Squashed commits."

Run Codeception Tests with Docker Compose

Submitted by Peter Majmesku on Thu, 09/22/2016 - 12:07


sudo docker-compose run --rm codeception codecept run

With HTML report creation:

sudo docker-compose run --rm codeception codecept run --html

With debug information:

sudo docker-compose run --rm codeception codecept run --debug

You can combine the parameters. See all Codeception commands here:

Phing: Sync a complete website to remote server quickly

Submitted by Peter Majmesku on Mon, 08/29/2016 - 21:04

The famous Phing build tool (written in PHP) offers automation for repetitive tasks, which need to be executed by the Linux terminal. So you can sync an entire website (files and database) to the remote server. Here is an example of a Phing target to do the job:

    <target name="syncWebsiteToLive"
            description="Sync folder and files via Rsync to live server.">
        <echo msg="Syncing data to live server." />
        <exec command="rsync -a --progress --delete /home/peter/Websites/ --exclude=.git/ --exclude=.idea/ --exclude=sites/default/settings.php"
              checkreturn="true" />
        <echo msg="Delete old database" />
        <exec command="ssh 'mysql -uroot -pPASSWORD -e &quot;drop database example_com;&quot;'"
              checkreturn="true" />
        <echo msg="Create new empty database" />
        <exec command="ssh 'mysql -uroot -pPASSWORD -e &quot;create database example_com;&quot;'"
              checkreturn="true" />
        <echo msg="Import database dump" />
        <exec command="ssh 'mysql -uroot -pPASSWORD example_com &lt; /var/www/'"
              checkreturn="true" />

This target is later contained in your build.xml file. Afterwards you can execute the following command:

phing syncWebsiteToLive

The output will be the following:

Buildfile: /home/peter/build.xml
DevOps > syncWebsiteToLive:
     [echo] Syncing data to live server.
sending incremental file list
      7,515,285 100%  111.94MB/s    0:00:00 (xfr#1, ir-chk=1009/1040)
     [echo] Delete old database
     [echo] Create new empty database
     [echo] Import database dump
Total time: 5.7706 seconds

The website has been single by one single console command in an absolute minimum of time. This approach is good for a website in development stadium or a website which database can be just replaced. Then this way can save a lot of time compared to other approaches like ftp and manual database dump import. 

Installing free of charge SSL certificate from in Apache 2 webserver on Ubuntu 14.04

Submitted by Peter Majmesku on Mon, 08/29/2016 - 20:57

SSL certificates are cost-free nowadays. is providing a service which lets you get SSL certificates that are free and work in the common web browsers. The following commands must be executed on the same machine on which your webserver is running. Because must be allowed to access it. Download the certbot from and make the binary executable:

chmod a+x certbot-auto

Now temporary stop your Apache server, to download the certificates.

sudo service apache2 stop

Now run the certbot program to download the certificates:

./certbot-auto certonly

This program leads you trough a short form process within your terminal. Asking you for the domain you want to secure.

Mind the SSL certificate renewal

The SSL certificate is valid for 3 months. You will get notified about this via the terminal output from the certbot. It looks like this, if you have executed the "./certbot-auto certonly" command at 23.07.2016:

 - Congratulations! Your certificate and chain have been saved at
   /etc/letsencrypt/live/ Your cert will
   expire on 2016-10-21. To obtain a new or tweaked version of this
   certificate in the future, simply run certbot-auto again. To
   non-interactively renew *all* of your certificates, run
   "certbot-auto renew"
 - If you like Certbot, please consider supporting our work by:
   Donating to ISRG / Let's Encrypt:
   Donating to EFF:          

There's an automatic way to accomplish the renewal. You can add this line to your crontab, to automatically re-new the certificates:

30 4 1 * * sudo service apache2 stop && ./certbot-auto renew --standalone && sudo service apache2 start

Enable the SSL certificate on your web server

Enable SSL in your Apache setup:

sudo a2enmod ssl

Now as you have the certificates, you can integrate them in your Apache 2 VHost configuration at /etc/apache2/sites-available/. Change "" to your domain name.

 SSLEngine on
   SSLCertificateFile    /etc/letsencrypt/live/
   SSLCertificateKeyFile /etc/letsencrypt/live/
   SSLCertificateChainFile /etc/letsencrypt/live/ 

Switch the virtual host port from 80 to 443. For this set the following in your Vhost configuration file: 

<VirtualHost *:80>


 <VirtualHost *:443>

Small tweak for SEO

Search engines expect that a web page can be accessed by only one address on your website. To redirect all requests from http to https and ensure that only will be requested and not "and", you can setup the redirect within your VHost file. Add this to the top of the configuration file for your virtual host: 

# Redirect all requests to SSL and ensure www. subdomain is re-directed, too.

<VirtualHost *:80>


Redirect /


<VirtualHost *:80>


Redirect /


<VirtualHost *:443>


Now restart Apache and happy SSL usage: 

sudo service apache2 restart

A complete Apache2 Vhost config file example:

<VirtualHost *:80>
Redirect /

<VirtualHost *:80>
Redirect /

<VirtualHost *:443>

ServerAdmin webmaster@localhost
DocumentRoot /var/www/

SSLEngine on
SSLCertificateFile /etc/ssl-cert/live/
SSLCertificateKeyFile /etc/ssl-cert/live/
SSLCertificateChainFile /etc/ssl-cert/live/

<Directory /var/www/>
Options Indexes FollowSymLinks
AllowOverride All
Require all granted

ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined