Menu Close

Category: Linux

Move WordPress to a subdirectory with Rancher

About one year ago, I wrote about Create wordpress blog with docker and rancher and was a great thing have a blog full dockerized in our rancher infrastructure.

Today, I’ve another challenge: put a wordpress blog to a subdirectory of a domain, keeping the main site separated from the blog in different docker containers, well.. not so easy.

What we should have, is something like: -> docker container with our main site -> different docker container with only the blog

I spent lots of time for understand the right way to do this, and finally, I got it!

Invalid datetime value in mysql 5.7

Mysql 5.7 added a validation on datetime so blank value or ‘0000-00-00 00:00:00’ are no more valid dates and it will give you an error if you try to edit/alter a column with this value from console, phpmyadmin or from your applications.
For avoid this issue, you should set every datatime column as NULLABLE, but if you have existing databases and existing applications it’s lots of work.
A workaround for this problem is edit “sql_mode” option in your code, like prestashop:

But, if you want that phpmyadmin continues to work fine, you have to edit mysql conf file and set sql_mode persistently.

Fix github Permission errors in Jenkins

Sometimes could happen that jenkins cannot work good with github repos in our project dependencies.

Errors could be something like:
   Cloning into '/var/www/vendor/zendframework/zend-uri'...
   Host key verification failed.
   fatal: Could not read from remote repository.
   Please make sure you have the correct access rights
   and the repository exists.


Cloning into 'zend-uri'...
   Permission denied (publickey).
   fatal: Could not read from remote repository.

For avoid these type of errors, you can add a public ssh key to your jenkins user:

Save psql query output to csv file


In terminal (while connected to the db) set output to the csv file

1) set field seperator to “;” by:

\f ';'

2) set output format unaligned:


3) show only tuples


4) set output

\o '/tmp/yourOutputFile.csv'

5) execute your query

select * from YOUR_TABLE

6) output


you will be able to find your cvs file in this location

cd //tmp
copy it using scp command 

or edit using nano:

nano //tmp/yourOutputFile.csv

You can also print to console with \o again.

Remove untagged images from docker


In the process of running docker I accumulated several images that are not tagged. To remove these I use this command:

docker rmi $(docker images -a | grep "^" | awk '{print $3}')

This works by using rmi with a list of image ids. To get the image ids we call docker images then pipe it to grep “^”. The grep will filter it down to only lines with the value “” in the repository column. Then to extract the id out of the third column we pipe it to awk “{print $3}” which will print the third column of each line passed to it.

Gitlab with Docker and Dokku

Gitlab is a fantastic git repository manager, it’s essentially github but with no limit on private repositories and most important, it’s absolutely open source.

You know, configure a new platform or service can often be a pain, but the good thing of docker is that with a single command we can have any service online in few seconds!

Move WordPress Site to Dokku Server

If you have a dedicated server and you have done all your testing with docker and dokku, you are ready to move all your sites on your new server.
Most common CMS is of course wordpress, so here I’ll explain how you can safely move a hosted wordpress site to a docker container with dokku.
(PS: This tutorial supposes that you have a base knowledge about docker and dokku).

N.B: I wrote this tutorial with specific idea of how wordpress should be installed in a container.
If you search with google something like “docker wordpress” you will found lots of resources and “dockerfile ready” container with all in one (wordpress + mysql).

For me it’s very important that wordpress and mysql stay on different containers (and dokku helps us with this).
Also important data of wordpress should stay in a safe place, because keep wp-content directory inside the container expose it to the risk of loss important files if you delete the container or something goes wrong with your dokku/docker installation.

Let’s start!

Find hidden content in mounted directories

You have a VPS or a server where you mounted some folders from a NAS / SAN, where for example you syncronize content or backup critical files.

Sometimes, the mount can be lost for various problems like bad network or a restart of the NAS.

What happen if the NAS go down and your server/VPS tries to backup files to mounted directory? Easy, it copies them to LOCAL folder where you think that is mounted NAS folders.

The problem is that you’ll NEVER see that content, and your disk space is obviously reduced and you don’t understand why.

Is there a way to view and delete this hidden content? YES!

How To Install and Setup Spamassassin on Ubuntu 12.04

by DigitalOcean

About Spamassassin

Spamassassin is a free and open-source mail filter written in Perl that is used to identify spam using a wide range of heuristic tests on mail headers and body text. It will save your mailbox from much unwanted spam emails.


Before installing Spamassassin, you need to install and setup a mail transfer agent such as Postfix on your virtual private server.

You can find instructions on that here