Nginx Alias cannot parse PHP workaround

Source: Internet
Author: User
Nginx Alias cannot parse PHP solution

Nginx Alias cannot parse the PHP solution:

server {
??????? Listen?????? 80;
??????? Server_Name? xxxx.com.cn;


??????? Error_log? /tmp/eror.log;
??????? Set $www _ROOT/HOME/WEB/YQBB/BGSKK;


??????? Location/{
??????????? Root?? $www _root;
??????????? Index? Index.html index.php;
??????? }


??????? Location/feedback {
??????????? Index? index.php;
??????????? Alias/home/web/yqbb/bgskk/app/htdocs;
??????? }


??????? Error_page?? 500 502 503 504? /50x.html;
??????? Location =/50x.html {
??????????? Root?? html
??????? }


??????? Location ~ ^/feedback/.+\.php$ {
??????????????? Root/home/web/yqbb/bgskk/app/htdocs;
??????????????? rewrite/feedback/(. *\.php?)/$1 break;
??????????????? Include fastcgi.conf;
??????????????? Fastcgi_pass?? 127.0.0.1:9000;
??????????????? Fastcgi_index? index.php;
??????????????? Fastcgi_param script_filename/home/web/yqbb/bgskk/app/htdocs/$fastcgi _script_name;
??????? }


??????? Location ~. *\. (PHP|PHP5)? $ {
??????????????? Fastcgi_pass? 127.0.0.1:9000;
??????????????? Fastcgi_index index.php;
??????????????? Include fastcgi.conf;
??????? }


??? }


?

?

Server
??? {
??????? Listen 80;? #端口号
??????? server_name www.linuxidc.com;?? #域名
??????? Index index.html index.htm index.php index.shtml;? #默认首页
??????? Root? /var/www/html;? #网站根目录
??????? CharSet GBK;??? #默认编码

??????? Location/public/? #设定要重写的目录名
??????? {
??????????????? alias/var/www/public/; #重定向目的目录.

??????????????? #例: If the user accesses http://www.linuxidc.com/public/test.html does not access/var/www/html/public/test.html, and the access is/var/www/public/ test.html, although this file is not in the domain name directory
??????? }

#做完上面的设置后, we found that when we visited PHP file http://www.linuxidc.com/public/test.php, we went to visit/var/www/html/public/ Test.php, which means that access to PHP files does not play a role in redirection, so we will also configure the following paragraph

#start


??????? Location ~ ^/public/.+\.php$
??????? {
??????????????? Root/var/www/html/web/news/public;
??????????????? rewrite/public/(. *\.php?)/$1 break;
??????????????? Include fastcgi.conf;
??????????????? Fastcgi_pass?? 127.0.0.1:9000;
??????????????? Fastcgi_index? index.php;
??????? }

#end


??????? Location ~. *\. (PHP|PHP5)? $
??????? {
??????????? #fastcgi_pass? Unix:/tmp/php-cgi.sock;
??????????? Fastcgi_pass? 127.0.0.1:9000;
??????????? Fastcgi_index index.php;
??????????? #include fcgi.conf;
??????????? Include fastcgi.conf;
??????????? Rewrite? ^/([a-za-z]+) \ ([a-za-z]+) $/$2.shtml last;
??????? }

??????? Location ~. *\. (gif|jpg|jpeg|png|bmp|swf) $
??????? {
??????????? Expires????? 30d;? #缓存30天
??????? }

??????? Location ~. *\. (JS|CSS)? $
??????? {
??????????? Expires????? 1h; #缓存1个小时
??????? }

??????? Access_log? /var/log/linuxidc.log? Access;? #定义日志文件
??????? SSI on;
??????? Ssi_silent_errors on;
??????? Ssi_types text/shtml;
??? }

  • 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.