DEV Community

Cover image for Docker compose For Wordpress
Mohammad Zakery
Mohammad Zakery

Posted on • Updated on

Docker compose For Wordpress

Wordpress

Wordpress Docker

How to use this image :

1.Clone or download all files from GitHub Page
2.Download Wordpress from Wordpress Downloads
3.Extract Wordpress.zip to the following directory:

/var/www/html/wp
Enter fullscreen mode Exit fullscreen mode

4.Run the command below :

docker-compose up -d
Enter fullscreen mode Exit fullscreen mode

5.Open up your web browser, and proceed to the following address to start the installation ( Remember that my configuration will start the server at port 80, in case you want to change the hostname/port, proceed to the next section to customize this image )

127.0.0.1
Enter fullscreen mode Exit fullscreen mode

6.If see 404 ERROR :

chmod 777 -R var/
Enter fullscreen mode Exit fullscreen mode

7.In the Database settings, adjust the following :

Database Name = wordpress
Username = wp
Password = 147258369
Database Host = mysql
Table Prefix = wp_
Enter fullscreen mode Exit fullscreen mode

Customize this image :

Use domain with SSL and change Nginx configurations

in the files downloaded from this GitHub Page
1.In this directory, uncomment the lines in the wp.conf and replace your domain with example.com

/nginx/conf.d/wp.conf
Enter fullscreen mode Exit fullscreen mode

2.Following the guides from Letsencrypt (certbot), copy the privkey.pem and fullchain.pem to the following directory. (Remember that from the previous step, the cert files names should correspond with these config file) :

/nginx/conf.d/certs
Enter fullscreen mode Exit fullscreen mode

3.In case you want to configure your Nginx, you can find the config file in the following directory :

/nginx/nginx.conf
Enter fullscreen mode Exit fullscreen mode

Change mysql configurations :

1.Customize your configs in the following file :

/mysql/my.cnf
Enter fullscreen mode Exit fullscreen mode

2.Change the mysql environment variables in the docker-compose.yml file :

environment:
        MYSQL_ROOT_PASSWORD: 147258369
        MYSQL_DATABASE: wordpress
        MYSQL_USER: wp
        MYSQL_PASSWORD: 147258369
Enter fullscreen mode Exit fullscreen mode

Change php-fpm configurations :

Add your customized configurations in these files :

/php-fpm/php.ini-development
/php-fpm/php.ini-production
/php-fpm/www.conf
/php-fpm/php.ini
Enter fullscreen mode Exit fullscreen mode

Exposing external port :

Edit docker-compose.yml to change the exposed ports :

ports:
     - 80:80
     - 443:443
Enter fullscreen mode Exit fullscreen mode

Top comments (0)