Yii uses nginx configuration

Source: Internet
Author: User
Yii uses nginx configuration
Upstream phpfpm {# server unix:/var/run/php5-fpm.sock; server 127.0.0.1: 9000;} server {listen 80; # Specify this vhost's domain nameserver_name lxy. me; root/home/lxy. me/public; index. php index.html index.htm; # Specify log locationsforcurrent siteaccess_log/home/lxy. me/log/access. log; error_log/home/lxy. me/log/error. log warn; # Typically I create a restrictions. conf file that I then1_demo-ss All of my vhosts # includeconf. d/restrictions. conf; # BEGIN restrictions. conf # Disable loggingforfaviconlocation =/favicon. ico {log_not_found off; access_log off ;}# Disable loggingforrobots.txt location =/robots.txt {allow all; log_not_found off; access_log off ;}# Deny all attempts to access hidden files suchas. htaccess ,. htpasswd ,. DS_Store (Mac ). location ~ /\. {Deny all; access_log off; log_not_found off;} # ENDrestrictions. conf # Typically I create a yiiframework. conf file that I then1_demo-ss all of my yii vhosts # includeconf. d/yiiframework. conf; # I 've got the content of my yiiframework. conf in-lineforthis example # BEGIN yiiframework. conf # Block access toprotected, framework, andnbproject (artifact from Netbeans) location ~ /(Protected | framework | nbproject) {deny all; access_log off; log_not_found off;} # Block access to theme-folder views directorieslocation ~ /Themes/\ w +/views {deny all; access_log off; log_not_found off;} # Attempt the uri, uri +/, then fall back to yii's index. php with args included # Note: old examplesuseIF statements, # which nginx considers edevil, this approach is more widely supportedlocation/{try_files $ uri // index. php? $ Args;} # ENDyiiframework. conf # Tell browser to cache image filesfor24 hours, # donot log missing images # I typically keep this after the yii rules, # so that there is no conflict with content served by Yiilocation ~ *\. (Js | css | png | jpg | jpeg | gif | ico) $ {expires 24 h; log_not_found off ;}# Blockforprocessing PHP files # Specifically matches URIs ending in. phplocation ~ \. Php $ {try_files $ uri = 404; # Fixforserver variables that behave differently under nginx/php-fpm than typically expectedfastcgi_split_path_info ^ (. + \. php )(/. +) $; # Include the standard fastcgi_params file encoded with nginx1_defastcgi_params; fastcgi_param PATH_INFO $ fastcgi_path_info; fastcgi_index index. php; # Override the SCRIPT_FILENAME variable set by character SCRIPT_FILENAME $ document_root $ fastcgi_script_name; # Pass to upstream PHP-FPM; This must match whatever you name your upstream connectionfastcgi_pass phpfpm ;}}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.