Created
November 28, 2021 01:35
-
-
Save cfxd/a6e5d29aa5f5b60403f4eb1e73e78a6d to your computer and use it in GitHub Desktop.
nginx.conf file for LEMP stack on MacBook Pro M1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace all instances of <YOUR_USERNAME> with your local username | |
#place this file in /opt/homebrew/etc/nginx (overwrite the existing default file there) | |
user <YOUR_USERNAME> staff; | |
worker_processes 1; | |
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log; | |
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log notice; | |
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log info; | |
error_log /Users/<YOUR_USERNAME>/Sites/nginx.log warn; | |
worker_rlimit_nofile 65535; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
sendfile on; | |
keepalive_timeout 65; | |
include servers/*; | |
client_max_body_size 100M; | |
server_names_hash_bucket_size 64; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace all instances of <YOUR_USERNAME> with your local username | |
#place this file in /opt/homebrew/etc/nginx/servers | |
server { | |
listen 8080; | |
server_name ~^(www\.)?(?<domain>.+).localhost$; | |
root /Users/<YOUR_USERNAME>/Sites/$domain/wp; | |
index index.php index.htm index.html; | |
port_in_redirect off; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpfpm-error.log; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpfpm-error.log notice; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpfpm-error.log info; | |
charset utf-8; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri /index.php; | |
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
# Mitigate https://httpoxy.org/ vulnerabilities | |
fastcgi_param HTTP_PROXY ""; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
# include the fastcgi_param setting | |
include fastcgi_params; | |
# SCRIPT_FILENAME parameter is used for PHP FPM determining | |
# the script name. If it is not set in fastcgi_params file, | |
# i.e. /etc/nginx/fastcgi_params or in the parent contexts, | |
# please comment off following line: | |
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $realpath_root; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
# proxy the PHP scripts to Apache listening on 127.0.0.1:80 | |
# | |
#location ~ \.php$ { | |
# proxy_pass http://127.0.0.1; | |
#} | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
# | |
# location ~ \.php$ { | |
# root html; | |
# fastcgi_pass 127.0.0.1:9000; | |
# fastcgi_index index.php; | |
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; | |
# include fastcgi_params; | |
# } | |
# deny access to .htaccess files, if Apache's document root | |
# concurs with nginx's one | |
# | |
#location ~ /\.ht { | |
# deny all; | |
#} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#replace all instances of <YOUR_USERNAME> with your local username | |
#place this file in /opt/homebrew/etc/nginx/servers | |
server { | |
listen 8080; | |
server_name phpmyadmin.localhost; | |
root /opt/homebrew/share/phpmyadmin; | |
index index.php; | |
port_in_redirect off; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpmyadmin-error.log; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpmyadmin-error.log notice; | |
error_log /Users/<YOUR_USERNAME>/Sites/phpmyadmin-error.log info; | |
charset utf-8; | |
client_max_body_size 25m; | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
location ~ \.php$ { | |
try_files $uri /index.php; | |
fastcgi_split_path_info ^(.+?\.php)(/.*)$; | |
if (!-f $document_root$fastcgi_script_name) { | |
return 404; | |
} | |
# Mitigate https://httpoxy.org/ vulnerabilities | |
fastcgi_param HTTP_PROXY ""; | |
fastcgi_param PATH_INFO $fastcgi_path_info; | |
fastcgi_pass 127.0.0.1:9000; | |
fastcgi_index index.php; | |
# include the fastcgi_param setting | |
include fastcgi_params; | |
# SCRIPT_FILENAME parameter is used for PHP FPM determining | |
# the script name. If it is not set in fastcgi_params file, | |
# i.e. /etc/nginx/fastcgi_params or in the parent contexts, | |
# please comment off following line: | |
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_param DOCUMENT_ROOT $realpath_root; | |
fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; | |
} | |
#error_page 404 /404.html; | |
# redirect server error pages to the static page /50x.html | |
# | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root html; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment