How to Setup WordPress Using Docker-Compose

Then, you need to update the server block. The following is just a sample for your reference. You need to pay attention at the root and php settings.

server {
    listen         80;

    root           /var/www/html;
    index          index.php index.html;

    location / {
      try_files $uri $uri/ /index.php?$args;

    location ~ \.php$ {
      fastcgi_pass    <the_php_service_name>:9000;
      include         fastcgi_params;
      fastcgi_param   SCRIPT_FILENAME    $document_root$fastcgi_script_name;
      fastcgi_param   SCRIPT_NAME        $fastcgi_script_name;

Change the fastcgi_pass to your PHP service name accordingly based on your docker-compose.yml file.

That’s all. Now you know how to easily setup WordPress websites using docker-compose.