windows下nginx配置vhost,打开网址默认是下载?
黄舟
黄舟 2017-05-16 17:19:52
0
1
661

vhost目录下127.0.1.1.conf文件

server {
    listen       80;
    # listen       somename:8080;
    server_name  127.0.1.1;

    location / {
        root   D:/www/test;
        index  index.php;
        try_files $uri $uri/ /index.php?$query_string;
    }
}

nginx.conf中使用

include vhost/*.conf;

然后打开127.0.1.1会弹出下载框,下载文件叫“下载”,内容就是index.php的内容。
这是怎么回事呢?

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
習慣沉默

你这里只配置了端口和处理路径,没有配置PHP处理程序,当然就默认当成普通静态网站了。

nginx 搭建 PHP 网站,除了要配置 nginx,还要开启 php-fpm 供 ngnix 调用去处理 php 程序。

至少要修改成类似这样,当然具体的代除了程序,要看你是如何配置和启动的了

server {
    listen       80;
    # listen       somename:8080;
    server_name  127.0.1.1;

    location / {
        root   D:/www/test;
        index  index.php;
        try_files $uri $uri/ /index.php?$query_string;
    }
    
    location ~ \.php {
        fastcgi_pass   127.0.0.1:9000;
        include        fastcgi_params;
        fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
    }
}
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!