Last active
December 20, 2015 21:09
-
-
Save sondr3/6195994 to your computer and use it in GitHub Desktop.
Configurations for your website to use as an example.
This file contains hidden or 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
# www to non-www redirect -- duplicate content is BAD: | |
# https://github.com/h5bp/html5-boilerplate/blob/5370479476dceae7cc3ea105946536$ | |
# Choose between www and non-www, listen on the *wrong* one and redirect to | |
# the right one -- http://wiki.nginx.org/Pitfalls#Server_Name | |
server { | |
# don't forget to tell on which port this server listens | |
listen 80; | |
# listen on the www host | |
server_name www.yourwebsite.com; | |
# and redirect to the non-www host (declared below) | |
return 301 $scheme://yourwebsite.com$request_uri; | |
} | |
server { | |
# listen 80 default_server deferred; # for Linux | |
# listen 80 default_server accept_filter=httpready; # for FreeBSD | |
listen 80 default_server deferred; | |
# The host name to respond to | |
server_name yourwebsite.com; | |
# Path for static files | |
root /srv/yourwebsite.com/www; | |
# You still need to have an index mentioned it seems | |
index index.php index.html; | |
# This order might seem weird - this is attempted to match last if rules belo$ | |
# http://wiki.nginx.org/HttpCoreModule | |
location / { | |
try_files $uri $uri/ /index.php?$args; | |
} | |
# Add trailing slash to */wp-admin requests. | |
rewrite /wp-admin$ $scheme://$host$uri/ permanent; | |
# Directives to send expires headers and turn off 404 error logging. | |
location ~* ^.+\.(ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif$ | |
access_log off; log_not_found off; expires max; | |
} | |
# Location for the error logs | |
access_log /srv/yourwebsite.com/logs/access.log; | |
error_log /srv/yourwebsite.com/logs/error.log | |
#Specify a charset | |
charset utf-8; | |
# Custom 404 page | |
error_page 404 /404.html; | |
# Include the component config parts for h5bp | |
include conf/h5bp.conf; | |
# And include the WordPress restrictions file | |
include conf/restrict.conf; | |
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 | |
location ~ \.php$ { | |
#fastcgi_pass 127.0.0.1:9000; | |
# With php5-fpm: | |
fastcgi_pass unix:/var/run/yourwebsite.sock; | |
fastcgi_index index.php; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment