Advertisement
Guest User

Nginx Wordpress config (pretty URL)

a guest
Oct 25th, 2013
642
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.68 KB | None | 0 0
  1. # You may add here your
  2. # server {
  3. # ...
  4. # }
  5. # statements for each of your virtual hosts to this file
  6.  
  7. ##
  8. # You should look at the following URL's in order to grasp a solid understanding
  9. # of Nginx configuration files in order to fully unleash the power of Nginx.
  10. # http://wiki.nginx.org/Pitfalls
  11. # http://wiki.nginx.org/QuickStart
  12. # http://wiki.nginx.org/Configuration
  13. #
  14. # Generally, you will want to move this file somewhere, and start with a clean
  15. # file but keep this around for reference. Or just disable in sites-enabled.
  16. #
  17. # Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
  18. ##
  19.  
  20. server {
  21. server_name www.example.com;
  22. return 301 $scheme://example.com$request_uri;
  23. }
  24.  
  25. server {
  26. listen 80;
  27. root /usr/share/nginx/www/example;
  28. index index.php;
  29. server_name example.com;
  30.  
  31. access_log /var/log/nginx/example.access.log;
  32. error_log /var/log/nginx/example.error.log;
  33.  
  34. error_page 404 /index.php;
  35.  
  36. location / {
  37. try_files $uri $uri/ @wordpress;
  38. }
  39.  
  40. # enforce NO www
  41. #if ($host ~* ^www\.(.*)) {
  42. # set $host_without_www $1;
  43. # rewrite ^/(.*)$ $scheme://$host_without_www/$1 permanent;
  44. #}
  45.  
  46. if (!-e $request_filename) {
  47. rewrite ^(.+)$ /index.php?q=$1 last;
  48. }
  49.  
  50. location @wordpress {
  51. fastcgi_pass 127.0.0.1:9000;
  52. fastcgi_param SCRIPT_FILENAME /usr/share/nginx/www/example/index.php;
  53. include /etc/nginx/fastcgi_params;
  54. fastcgi_param SCRIPT_NAME /index.php;
  55. }
  56.  
  57. location ~ \.php$ {
  58. try_files $uri @wordpress;
  59. fastcgi_split_path_info ^(.+\.php)(/.+)$;
  60. # NOTE: You should have "cgi.fix_pathinfo = 0;" in php.ini
  61.  
  62. # With php5-cgi alone:
  63. fastcgi_pass 127.0.0.1:9000;
  64. # With php5-fpm:
  65. # fastcgi_pass unix:/var/run/php5-fpm.sock;
  66. fastcgi_index index.php;
  67. include fastcgi_params;
  68. }
  69.  
  70. location /phpmyadmin {
  71. root /usr/share/;
  72. index index.php index.html index.htm;
  73. location ~ ^/phpmyadmin/(.+\.php)$ {
  74. try_files $uri =404;
  75. root /usr/share/;
  76. fastcgi_pass 127.0.0.1:9000;
  77. fastcgi_index index.php;
  78. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  79. include /etc/nginx/fastcgi_params;
  80. }
  81. location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
  82. root /usr/share/;
  83. }
  84. }
  85. location /phpMyAdmin {
  86. rewrite ^/* /phpmyadmin last;
  87. }
  88.  
  89.  
  90. # deny access to .htaccess files, if Apache's document root
  91. # concurs with nginx's one
  92. #
  93. #location ~ /\.ht {
  94. # deny all;
  95. #}
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement