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