Skip to content

Instantly share code, notes, and snippets.

@razarahil
Created January 10, 2022 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save razarahil/6a96f2cdc52b06848956fda30c68bd04 to your computer and use it in GitHub Desktop.
Save razarahil/6a96f2cdc52b06848956fda30c68bd04 to your computer and use it in GitHub Desktop.
Wordpress Nginx PHP-FPM
server {
listen 80;
listen [::]:80;
root /var/www/html/naturewoodsschool.com;
index index.php index.html index.htm index.nginx-debian.html;
server_name naturewoodsschool.com www.naturewoodsschool.com;
access_log off;
log_not_found off;
client_max_body_size 800m;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;
# # With php-cgi (or other tcp sockets):
# fastcgi_pass 127.0.0.1:9000;
fastcgi_cache phpcache; # The name of the cache key-zone to use
fastcgi_cache_valid 200 30m; # What to cache: 'Code 200' responses, for half an hour
fastcgi_cache_methods GET HEAD; # What to cache: only GET and HEAD requests (not POST)
add_header X-Fastcgi-Cache $upstream_cache_status; # Add header so we can see if the cache hits or misses
}
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
# assets, media
location ~* \.(?:css(\.map)?|js(\.map)?|jpe?g|png|gif|ico|cur|heic|webp|tiff?|mp3|m4a|aac|ogg|midi?|wav|mp4|mov|webm|mpe?g|avi|ogv|flv|wmv)$ {
expires 7d;
access_log off;
}
# svg, fonts
location ~* \.(?:svgz?|ttf|ttc|otf|eot|woff2?)$ {
add_header Access-Control-Allow-Origin "*";
expires 7d;
access_log off;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment