sajad torkamani

Clone repo

Suppose you have a standard WordPress project like the one in this repo. Clone your repo.

cd ~/sites # or wherever
git clone https://github.com/sajadtorkamani/wordpress-deployer-example

Create Nginx config

touch /usr/local/etc/nginx/sites-available/wordpress-deployer-example.test.conf

Set its contents to:

server {
    listen 80;
    server_name wordpress-deployer-example.test www.wordpress-deployer-example.test;
    root /Users/sajad/sites/wordpress-deployer-example/;

    index index.php index.html;

    location / {
      try_files $uri $uri/ /index.php?$query_string;
    }

    location ~ \.php$ {
      fastcgi_pass   127.0.0.1:9000; # Assuming PHP-FPM is listening on port 9000
      fastcgi_index  index.php;
      include        fastcgi.conf;
     }

    location ~ /\.ht {
        deny all;
    }
}

Activate config.

ln -s /usr/local/etc/nginx/sites-available/wordpress-deployer-example.test.conf /usr/local/etc/nginx/sites-enabled

Test config.

nginx -t

Reload Nginx.

nginx -s reload

Update /etc/hosts and add the following entry.

127.0.0.1 wordpress-deployer-example.test

Verify configuration

Navigate to http://wordpress-deployer-example.test and you should see the default WordPress installation page.