首页 > nginx关于php的二级域名+子目录问题

nginx关于php的二级域名+子目录问题

具体环境为nginx+php,欲配置phpmyadmin。

现在的问题是访问主机域名,html目录下php可以正常运行。但是访问phpmyadmin.xxxxx.com域名,html/phpmyadmin下文件会通过浏览器下载。各种搜索改参数无果,求支援。


具体nginx.conf参数如下:

    server {
        listen       80;
        server_name  localhost;
    root html;

        access_log  logs/host.access.log main;

        location / {
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

    location ~ \.php?$ {
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;
    }


        location ~ /\.ht {
            deny  all;
        }
    }
include vhost/*.conf;

vhosh/*.conf配置如下

server {
        listen       80;
        server_name  phpmyadmin.xxxxx.com;
        root   html/phpmyadmin;
        #charset koi8-r;

        access_log  logs/phpmyadmin.access.log  main;
        #error_log  log/phpmyadmin.error.log main;


        location / {
            index  index.html index.htm index.php;
        }

}

huandu已经解答了

你没有配置php解析部分,所谓nginx不知道你要通过什么方式去解析

话说你用的lnmp.org的安装包,不太需要自己修改配置文件吧,顶多加个include *.conf用来解析urlwrite


在你的 phpmyadmin.xxxxx.com 的 vhost 里缺少 fastcgi 的配置,当然不对啦。把你在 localhost 的 vhost 里配置的内容复制过来就差不多对了。

就是以下这些:

error_page   500 502 503 504  /50x.html;
location = /50x.html {
    root   html;
}

location ~ \.php?$ {
    fastcgi_pass 127.0.0.1:9000;
    fastcgi_index index.php;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    include fastcgi_params;
}
【热门文章】
【热门文章】