Install multiple WordPress sites with phpMyAdmin and Nginx and Lets encrypt and Docker


This article is dependent on that you have Nginx, vsftp and docks installed according to the articles below:

  1. Installera Docker
  2. Installera Vsftp
  3. Installera Nginx med Let’s encrypt

In the article to install Vsftp we created the wordpress folder. Start by cd to that folder.
cd /home/topweb/ftp/files/wordpress/

Then create a docker-compose file
sudo nano docker-compose.yml

Then paste this for wordpress with phpMyAdmin. docker-compose.yml

Where I wrote #change is what you should change to add more wordpress sites. Thus, just create a docker-compose file in the wordpress folder of other users described in Install Vsftp article, to add more wordpress sites to the same server using docker.

Note that VIRTUAL_HOST and LETSENCRYPT_HOST should be the same to create SSL-certificates for the web site. You can of course change many parameters in the dock-compose file. LETSENCRYPT_EMAIL can be changed to your email and WORDPRESS_DB_NAME can be changed to something else. Make sure the names you change matches, so you change in all places. Thus, the names are linked and must be the same.

If you want to generate a password, you can use the following webpage for it: Generate password

Run docker-compose

Then just run the docker-compose and you can look at the display as described in Install Nginx with Let’s encrypt the article, how the certificates are created or not created.

Note: You must before you run docks-compose put domains against the server otherwise Let’s encrypt can not find the page, and no one else either for that matter. In this example, I added the subdomains for my domain ( @, www and db with an A address to the server’s ip. Thus all subdomains have the same ip and it is then nginx reverse-proxy that manages the distribution. If you have an ipv6 dns to your server in your dns settings delete it because lets encrypt try to go via ipv6 in the first hand and docker do not fully support ipv6. This was a problem I had way to long, the certificate was self signed but no certificate could be created.

sudo docker-compose up

Add users to the www-data group

In order to change the folders and files when we enter the web server via ftp, we need to add the user to the www-data group and give each folder and file the correct permissions. We put www-data as the primary group for the user topweb and then add topweb or the name of your user as a secondary group.
sudo usermod -g www-data topweb
sudo usermod -a -G topweb topweb
getent group www-data
id topweb

If you copy folders and files from another web page, it may be that the previous permissions are kept. The following command fixes this.
Cd so you are in the same folder as the wp_html folder.
cd /home/topweb/ftp/files/wordpress/home/
sudo find wp_html/ -type d -exec chmod 775 {} \;
sudo find wp_html/ -type f -exec chmod 664 {} \;
sudo chown -R www-data:www-data wp_html/

Is your site not entirely secure?

If you have ssl-certificate on your site and it is not completely secure. Eg says some pictures on the page are not secure. If you want to find which images that are unsafe or other content on the page that make it unsecure, you can use jitbit or whynopadlock to find the faults.

Leave a Reply

Your email address will not be published. Required fields are marked *