Nginx "virtual directory" does not support PHP workaround

Source: Internet
Author: User
Nginx "virtual directory" does not support PHP workaround

These days in the configuration nginx,php with fastcgi, want to install a phpMyAdmin management database, phpMyAdmin do not want to put in the root directory of the site, so it is not easy to mix with the site application, so phpMyAdmin directory is placed elsewhere, in Apache, There is alias, more convenient, there is no virtual directory under Nginx concept, is using location with alias use, I first tried a simple configuration method

location/web/{
alias/data/web/;
Index index.html index.htm index.php;
}

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

I can use http://localhost/web/to access the static file in the/data/web directory, but access the PHP file, but no input file Specified error, and in the Nginx error log But what information is not, I searched the internet, the judge should be PHP file is not run by the backend fastcgi, I continue to search some articles, try to add a configuration

location/web/{
alias/data/web/;
Index index.html index.htm index.php;
}

Location ~ ^/web/.+\.php$ {
root/data/;
rewrite/web/(. *\.php?)/$1 break;
Include fcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/web$fastcgi_script_name;
}

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

This can be, the principle should be adopted rewrite method, for/web/PHP type of request to the backend fastcgi processing, and specify the location of the PHP script, so we can configure the phpMyAdmin, configured as follows

location/phpmyadmin/{
alias/data/phpmyadmin/;
Index index.html index.htm index.php;
}

Location ~ ^/phpmyadmin/.+\.php$ {
root/data/;
rewrite/phpmyadmin/(. *\.php?)/$1 break;
Include fcgi.conf;
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Fastcgi_param Script_filename/data/phpmyadmin$fastcgi_script_name;
}

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

It's important to note that

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

This paragraph, to put in the back of the phpMyAdmin, put in front of the problem, this is and nginx location rules about, concrete look at Nginx document, in addition, phpMyAdmin to configure the absolute path of the URI, you can.

?

?

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