Heim  >  Fragen und Antworten  >  Hauptteil

Wenn Nginx unter Windows mit vhost konfiguriert ist, wird beim Öffnen einer URL standardmäßig der Download durchgeführt?

127.0.1.1.conf-Datei im vhost-Verzeichnis

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

Wird in

nginx.conf

verwendet

include vhost/*.conf;

Dann öffnen Sie 127.0.1.1 und eine Download-Box wird angezeigt. Die Download-Datei heißt „Download“ und der Inhalt ist der Inhalt von index.php.

Was ist los? 🎜
黄舟黄舟2712 Tage vor667

Antworte allen(1)Ich werde antworten

  • 習慣沉默

    習慣沉默2017-05-16 17:21:52

    你这里只配置了端口和处理路径,没有配置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;
        }
    }

    Antwort
    0
  • StornierenAntwort