Nginx Configuration virtual directory and support PHP

Source: Internet
Author: User

question: If www.111.com site root directory for/data/web/, now want to www.111.com a site, www.111.com/abc/

However, you cannot create an ABC directory directly under/data/web/, and you should place it under/data1/abc/.


Workaround:

Using the Nginx alias feature to implement a virtual directory

In the configuration file, add

Location ~/abc/(. *) $ {

alias/data1/abc/$1;

}

Of course, alias after the directory can be arbitrary, as long as you put the program directory. In other words, the/data1/abc/defined behind alias can also make/data1/123/

At this time, access to pictures, Web pages, CSS and JS are no problem, but access to PHP will be reported 404. What to do?

Continue to add the following configuration, but note that it should be added in front of the location configuration above, otherwise it will not take effect.

Location ~/abc/.+\.php$ {

root/data1/;

rewrite/abc/(. *\.php)/$1 break;

Include Fastcgi_params;

Fastcgi_pass Unix:/tmp/php-fcgi.sock;

Fastcgi_index index.php;

Fastcgi_param script_filename/data1/abc/$fastcgi _script_name;

}

In this, you can also support PHP.



This article is from the Linux OPS blog, so be sure to keep this source http://zhumy.blog.51cto.com/11647651/1826886

Nginx Configuration virtual directory and support PHP

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.