Nginx directory Aliases (alias) Support PHP configuration

Source: Internet
Author: User

Requirements: Access to/var/data/www through example.com, but EXAMPLE.COM/PA access is/var/data/phpmyadmin, that is, protection phpMyAdmin is not exposed to the WWW directory.

One, method one: (not recommended)

Introduction: This is a popular way of Rewrite on the Internet.
BUG: A simple PHP program can cope with a complicated program "No input file specified"

Server {Listen the;    server_name example.com; Root/var/data/www;    Index index.html index.php; Location/PA {alias/var/data/phpMyAdmin;    Index index.html index.php; } Location~/pa/.+\.php$ {rewrite/pa/(. +\.php)/$1  Break; Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php; Fastcgi_param Script_filename/var/data/phpmyadmin/$fastcgi _script_name;    Include Fastcgi_params; } Location~. +\.php.*$ {Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php; Fastcgi_param script_filename $document _root/$fastcgi _script_name;        Fastcgi_param script_filename $request _filename;    Include Fastcgi_params; }}
Two, method two: (recommended)

Introduction: Perfect realization, no side effects.
Features: A variable called "$valid _fastcgi_script_name" is used

Server {Listen the;    server_name example.com; Root/var/data/www;    Index index.html index.php; Location/PA {alias/var/data/phpMyAdmin;    Index index.html index.php; } Location~/pa/.+\.php.*$ {        if($fastcgi _script_name ~/pa/(. +\.php.*)$) {            Set$valid _fastcgi_script_name $1; } Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php; Fastcgi_param Script_filename/var/data/phpmyadmin/$valid _fastcgi_script_name;    Include Fastcgi_params; } Location~. +\.php.*$ {Fastcgi_pass127.0.0.1:9000;        Fastcgi_index index.php; Fastcgi_param script_filename $document _root/$fastcgi _script_name;        Fastcgi_param script_filename $request _filename;    Include Fastcgi_params; }}
Two, method three:

Summary: The creative approach seen on zhigang.net, which is one station plus two server fields, is then implemented in a reverse fashion.
Specific: The method is creative, a little bit troublesome.

Nginx directory Aliases (alias) Support PHP configuration

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.