server {listen 80;
server_name ceshi3.com;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /www/html/ceshi3.com/htdocs;
index index.html index.php index.htm;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/html/ceshi3.com/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location /phpmyadmin {
alias /usr/share/phpMyAdmin/;
index index.php;}
location ~ /phpmyadmin/.+\.php$ {
if ($fastcgi_script_name ~ /phpmyadmin/(.+\.php.*)$) {
set $valid_fastcgi_script_name $1;}
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpMyAdmin/$valid_fastcgi_script_name;
}
}但是这样配置之后phpmyadmin打不开,phpmyadmin不在网站根目录下,用的alias定义虚拟目录,如果我把 location ~ \.php$这个删掉,phpmyadmin就可以打开了,但是这样网站首页如果是php的,那么打开首页就会变成下载php文件了,说明php解析不成功,这是怎么回事!
以上语法有错误吗,为什么有冲突呢?
location ~ \.php$
有说明处理的话,那后边的 phpmyadmin 部分或许就不需要再对 php 要求后端处理了。
server {
listen 80;
server_name ceshi3.com;
#charset koi8-r;
#access_log logs/host.access.log main;
# Load configuration files for the default server block.
include /etc/nginx/default.d/*.conf;
location / {
root /www/html/ceshi3.com/htdocs;
index index.html index.php index.htm;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000#
location ~ \.php$ {
# root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/html/ceshi3.com/htdocs$fastcgi_script_name;
include fastcgi_params;
}
location /phpmyadmin {
alias /usr/share/phpMyAdmin/;
}
这样的话,会有什么结果呢?
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。