When nginx is configured with vhost under Windows, does it default to downloading when opening a URL?
黄舟
黄舟 2017-05-16 17:19:52
0
1
663

127.0.1.1.conf file in the vhost directory

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;
    }
}

Used in nginx.conf

include vhost/*.conf;

Then open 127.0.1.1 and a download box will pop up. The download file is called "Download" and the content is the content of index.php.
What's going on?

黄舟
黄舟

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

reply all(1)
習慣沉默

You have only configured the port and processing path here, but not the PHP handler. Of course, it will be treated as an ordinary static website by default.

nginx To build a PHP website, in addition to configuring nginx, you must also enable php-fpm for ngnix to call to process the php program.

At least modify it to something like this. Of course, the specific replacement program depends on how you configure and start it

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;
    }
}
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!