kushaldsouza

Nginx server configuration for yii

Jan 23rd, 2013
183
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.66 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. set $host_path "/usr/share/nginx/";
  22. access_log /usr/share/nginx/www/log/access.log;
  23.  
  24. server_name mysite;
  25. root $host_path/www;
  26. set $yii_bootstrap "index.php";
  27.  
  28. charset utf-8;
  29.  
  30. location / {
  31. index index.html $yii_bootstrap;
  32. try_files $uri $uri/ /$yii_bootstrap?$args;
  33. }
  34.  
  35. location ~ ^/(protected|framework|themes/\w+/views) {
  36. deny all;
  37. }
  38.  
  39. #avoid processing of calls to unexisting static files by yii
  40. location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
  41. try_files $uri =404;
  42. }
  43.  
  44. # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
  45. #
  46. location ~ \.php {
  47. fastcgi_split_path_info ^(.+\.php)(.*)$;
  48.  
  49. #let yii catch the calls to unexising PHP files
  50. set $fsn /$yii_bootstrap;
  51. if (-f $document_root$fastcgi_script_name){
  52. set $fsn $fastcgi_script_name;
  53. }
  54.  
  55. fastcgi_pass 127.0.0.1:9000;
  56. include fastcgi_params;
  57. fastcgi_param SCRIPT_FILENAME $document_root$fsn;
  58.  
  59. #PATH_INFO and PATH_TRANSLATED can be omitted, but RFC 3875 specifies them for CGI
  60. fastcgi_param PATH_INFO $fastcgi_path_info;
  61. fastcgi_param PATH_TRANSLATED $document_root$fsn;
  62. }
  63.  
  64. location ~ /\.ht {
  65. deny all;
  66. }
  67. }
  68.  
  69. # another virtual host using mix of IP-, name-, and port-based configuration
  70. #
  71. #server {
  72. # listen 8000;
  73. # listen somename:8080;
  74. # server_name somename alias another.alias;
  75. # root html;
  76. # index index.html index.htm;
  77. #
  78. # location / {
  79. # try_files $uri $uri/ =404;
  80. # }
  81. #}
  82.  
  83.  
  84. # HTTPS server
  85. #
  86. #server {
  87. # listen 443;
  88. # server_name localhost;
  89. #
  90. # root html;
  91. # index index.html index.htm;
  92. #
  93. # ssl on;
  94. # ssl_certificate cert.pem;
  95. # ssl_certificate_key cert.key;
  96. #
  97. # ssl_session_timeout 5m;
  98. #
  99. # ssl_protocols SSLv3 TLSv1;
  100. # ssl_ciphers ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv3:+EXP;
  101. # ssl_prefer_server_ciphers on;
  102. #
  103. # location / {
  104. # try_files $uri $uri/ =404;
  105. # }
  106. #}
Advertisement
Add Comment
Please, Sign In to add comment