I have been trying to create an Nginx environment on MAMP Pro for a WordPress Multisite with subdirectories. I was able to do majority of the steps to create the WordPress multisite however I realized that Nginx does not use htaccesss and instead its required nginx.conf file to be updated per their documentation at: https://wordpress.org/documentation/article/nginx/. I believe this is preventing me from accessing my second sub-site wp-admin dashboard and causing my second sub-site to return 404 (Not Found) errors for every external link and stylesheet (I already checked database site urls and blog urls were set correctly).
I've attempted to make the changes but it could also be I am doing it wrong as this would be my first time attempting to do this.
So I was wondering if anyone could point me in the direction of which directives would need to be added and where? I'm attaching a copy of the MAMP nginx.conf for reference and I believe some directives can also be added via the MAMP GUI dashboard so I'll be attaching a screenshot of what I'm seeing for reference.
Nginx.conf
MAMP_ngx_http_image_filter_module_MAMPload_module "modules/ngx_http_image_filter_module.so";
MAMP_ngx_http_perl_module_MAMPload_module "modules/ngx_http_perl_module.so";
MAMP_ngx_http_xslt_filter_module_MAMPload_module "modules/ngx_http_xslt_filter_module.so";
MAMP_ngx_mail_module_MAMPload_module "modules/ngx_mail_module.so";
MAMP_ngx_stream_module_MAMPload_module "modules/ngx_stream_module.so";
MAMP_User_Directive_MAMPuser MAMP_User_MAMP MAMP_Group_MAMP;
worker_processes auto;
events {
worker_connections 1024;
}
http {
include /Applications/MAMP/conf/nginx/mime.types;
default_type text/html;
gzip on;
gzip_types text/css text/x-component application/x-javascript application/javascript text/javascript text/x-js text/richtext image/svg+xml text/plain text/xsd text/xsl text/xml image/x-icon;
sendfile on;
keepalive_timeout 65;
# access_log "/Applications/MAMP/logs/nginx_access.log";
error_log "MAMP_NginxErrorLog_MAMP";
server_names_hash_bucket_size 128;
# Enables or disables stapling of OCSP responses by the server. Example:
#ssl_stapling on | off;
# Enables or disables verification of OCSP responses by the server
#ssl_stapling_verify on | off;
server {
listen MAMP_Port_MAMP default_server;
listen MAMP_SSL_Port_MAMP default_server ssl;
ssl_ciphers 'aNULL';
ssl_certificate "/Applications/MAMP/conf/server/default.crt";
ssl_certificate_key "/Applications/MAMP/conf/server/default.key";
return 444;
}
server {
listen MAMP_Port_MAMP;
server_name localhost;
root "MAMP_Localhost_DocumentRoot_MAMP";
location / {
index MAMP_Localhost_DirectoryIndex_MAMP;
}
location ~* /MAMP([^-].*)$ {
root "/Library/Application Support/appsolute/MAMP PRO";
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location ~* /phpMyAdmin(.*)$ {
root "/Library/Application Support/appsolute/MAMP PRO";
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location ~* /phpMyAdmin5(.*)$ {
root "/Library/Application Support/appsolute/MAMP PRO";
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location ~* /phpPgAdmin(.*)$ {
root /Applications/MAMP/bin;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location ~* /phpLiteAdmin(.*)$ {
root /Applications/MAMP/bin;
index index.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location ~* /adminer(.*)$ {
root /Applications/MAMP/bin;
index adminer.php;
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
}
location /icons {
alias /Applications/MAMP/Library/icons;
autoindex on;
}
location /favicon.ico {
alias /Applications/MAMP/bin/favicon.ico;
# log_not_found off;
# access_log off;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpLocalhost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
location ~ /\. {
deny all;
}
# location ~* \.(gif|jpg|png|pdf)$ {
# expires 30d;
# }
# location = /robots.txt {
# allow all;
# log_not_found off;
# access_log off;
# }
# location ~* \.(txt|log)$ {
# allow 127.0.0.1;
# deny all;
# }
# location ~ \..*/.*\.php$ {
# return 403;
# }
location /nginx_status {
stub_status on;
access_log off;
allow 127.0.0.1;
deny all;
}
}
MAMP_VirtualHost_iteration_begin_MAMP
server {
listen MAMP_IP_Port_MAMP;
server_name MAMP_VirtualHost_ServerName_MAMP;
MAMP_VirtualHost_ServerAliases_MAMP
root "MAMP_VirtualHost_DocumentRoot_MAMP";
location / {
try_files MAMP_Try_Files_MAMP;
index MAMP_VirtualHost_DirectoryIndex_MAMP;
autoindex MAMP_VirtualHost_AutoIndex_MAMP;
MAMP_VirtualHost_Allow_MAMP
MAMP_VirtualHost_Deny_MAMP
MAMP_LocationCustom_MAMP
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpHost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
MAMP_VirtualHost_AdditionalCustom_MAMP
}
MAMP_VirtualHost_iteration_end_MAMP
MAMP_SSLVirtualHost_iteration_begin_MAMP
server {
listen MAMP_SSL_IP_Port_MAMP ssl;
server_name MAMP_SSLVirtualHost_ServerName_MAMP;
client_max_body_size 0;
MAMP_SSLVirtualHost_ServerAliases_MAMP
root "MAMP_SSLVirtualHost_DocumentRoot_MAMP";
# access_log "/Applications/MAMP/logs/nginx_ssl_access.log";
error_log "/Applications/MAMP/logs/nginx_ssl_error.log";
ssl_certificate "MAMP_SSLVirtualHost_Certificate_MAMP";
ssl_certificate_key "MAMP_SSLVirtualHost_CertificateKey_MAMP";
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
ssl_session_tickets off;
MAMP_SSLVirtualHost_OnlyAllowTLS_MAMPssl_protocols TLSv1 TLSv1.1 TLSv1.2;
MAMP_SSLVirtualHost_OnlyAllowTLS_MAMPssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256';
MAMP_SSLVirtualHost_OnlyAllowTLS_MAMPssl_prefer_server_ciphers on;
MAMP_SSLVirtualHost_OnlyAllowTLS_MAMPadd_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;
location / {
try_files MAMP_Try_Files_MAMP;
index MAMP_SSLVirtualHost_DirectoryIndex_MAMP;
autoindex MAMP_VirtualHost_AutoIndex_MAMP;
MAMP_VirtualHost_Allow_MAMP
MAMP_VirtualHost_Deny_MAMP
MAMP_LocationCustom_MAMP
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/Applications/MAMP/Library/logs/fastcgi/nginxFastCGI_phpMAMP_PhpHost_MAMP.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /Applications/MAMP/conf/nginx/fastcgi_params;
}
MAMP_VirtualHost_AdditionalCustom_MAMP
}
MAMP_SSLVirtualHost_iteration_end_MAMP
}
# DONT REMOVE: MAMP PRO nginx.conf template compatibility version: 23
I've attempted to copy and paste the code from this link to various locations in the nginx.conf file and on the MAMP app GUI PER: https://wordpress.org/documentation/article/nginx/#wordpress-multisite-subdirectory-rules. But I feel like I'm not adding it correctly as nginx is something I'm not familiar with.
