Guest User

Nginx WordPress Multisite

a guest
Apr 9th, 2014
561
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. **/nginx/global/common.conf**
  2.  
  3. # Global configuration file.
  4. # ESSENTIAL : Configure Nginx Listening Port
  5. listen 80;
  6. # ESSENTIAL : Default file to serve. If the first file isn't found,
  7. index index.php index.html index.htm;
  8. # ESSENTIAL : no favicon logs
  9. location = /favicon.ico {
  10. log_not_found off;
  11. access_log off;
  12. }
  13. # ESSENTIAL : robots.txt
  14. location = /robots.txt {
  15. allow all;
  16. log_not_found off;
  17. access_log off;
  18. }
  19. # ESSENTIAL : Configure 404 Pages
  20. error_page 404 /404.html;
  21. # ESSENTIAL : Configure 50x Pages
  22. error_page 500 502 503 504 /50x.html;
  23. location = /50x.html {
  24. root /usr/share/nginx/html;
  25. }
  26. # SECURITY : Deny all attempts to access hidden files .abcde
  27. location ~ /\. {
  28. deny all;
  29. }
  30. # PERFORMANCE : Set expires headers for static files and turn off logging.
  31. location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|atom|jpg|jpeg|gif|png|ico|zip|tgz|gz|rar|bz2|doc|xls|exe|ppt|tar|mid|midi|wav|bmp|rtf)$ {
  32. access_log off; log_not_found off; expires 30d;
  33. }
  34.  
  35. **/nginx/global/wordpress.conf**
  36.  
  37.  
  38. # WORDPRESS : Rewrite rules, sends everything through index.php and keeps the appended query string intact
  39. location / {
  40. try_files $uri $uri/ /index.php?q=$uri&$args;
  41. }
  42.  
  43. # SECURITY : Deny all attempts to access PHP Files in the uploads directory
  44. location ~* /(?:uploads|files)/.*\.php$ {
  45. deny all;
  46. }
  47. # REQUIREMENTS : Enable PHP Support
  48. location ~ \.php$ {
  49. # SECURITY : Zero day Exploit Protection
  50. try_files $uri =404;
  51. # ENABLE : Enable PHP, listen fpm sock
  52. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  53. fastcgi_pass unix:/var/run/php5-fpm.sock;
  54. fastcgi_index index.php;
  55. include fastcgi_params;
  56. }
  57. # PLUGINS : Enable Rewrite Rules for Yoast SEO SiteMap
  58. rewrite ^/sitemap_index\.xml$ /index.php?sitemap=1 last;
  59. rewrite ^/([^/]+?)-sitemap([0-9]+)?\.xml$ /index.php?sitemap=$1&sitemap_n=$2 last;
  60.  
  61. **/nginx/global/multisite.conf**
  62.  
  63. # Rewrite rules for WordPress Multi-site.
  64. if (!-e $request_filename) {
  65. rewrite /wp-admin$ $scheme://$host$uri/ permanent;
  66. rewrite ^/[_0-9a-zA-Z-]+(/wp-.*) $1 last;
  67. rewrite ^/[_0-9a-zA-Z-]+(/.*\.php)$ $1 last;
  68. }
  69.  
  70.  
  71. **/nginx/sites-available/example.com**
  72.  
  73. server {
  74. # URL: Correct way to redirect URL's
  75. server_name example.com;
  76. rewrite ^/(.*)$ http://www.example.com/$1 permanent;
  77. }
  78. server {
  79. server_name www.example.com;
  80. root /usr/share/nginx/html/example;
  81. access_log /var/log/nginx/www.example.com.access.log;
  82. error_log /var/log/nginx/www.example.com.error.log;
  83. include global/common.conf;
  84. include global/wordpress.conf;
  85. include global/multisite.conf;
  86. }
RAW Paste Data