sajad torkamani

This post assumes you installed Nginx via Homebrew and that its config lives in /opt/homebrew/etc/nginx. Other installation methods may place the config files elsewhere.

Clone repo

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

cd ~/sites # or wherever
git clone

Create Nginx config

touch /opt/homebrew/etc/nginx/sites-available/wordpress-example-project.test.conf

Set its contents to:

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

  index index.php;

  location = /favicon.ico {
    log_not_found off;
    access_log off;

  location = /robots.txt {
    allow all;
    log_not_found off;
    access_log off;

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

  location ~ \.php$ {
    include fastcgi_params;
    fastcgi_pass; # Assuming PHP-FPM is listening on port 9000
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

  location ~ /\.ht {
    deny all;

  location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
    expires max;
    log_not_found off;

Activate config.

ln -s /opt/homebrew/etc/nginx/sites-available/wordpress-example-project.test.conf /opt/homebrew/etc/nginx/sites-enabled

Test config.

nginx -t

Reload Nginx.

nginx -s reload

Update /etc/hosts and add the following entry. wordpress-example-project.test

Verify configuration

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