Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/10.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Mac上指向本地主机的Nginx虚拟块';s index.php_Php_Macos_Nginx_Server - Fatal编程技术网

Mac上指向本地主机的Nginx虚拟块';s index.php

Mac上指向本地主机的Nginx虚拟块';s index.php,php,macos,nginx,server,Php,Macos,Nginx,Server,我正在配置虚拟主机以在我的mac上服务.localhost域。但当我在浏览器中打开“project.localhost”时,它会显示与相同的页面,浏览localhost的索引。(注:我还配置了dnsmasq和/etc/hosts)。(正在尝试为index.php提供服务) 这是我的nginx.conf: worker_processes 1; events { worker_connections 1024; } http { include mime.t

我正在配置虚拟主机以在我的mac上服务.localhost域。但当我在浏览器中打开“project.localhost”时,它会显示与相同的页面,浏览localhost的索引。(注:我还配置了dnsmasq和/etc/hosts)。(正在尝试为index.php提供服务)

这是我的nginx.conf:

worker_processes  1;


events {
    worker_connections  1024; }


http {
    include       mime.types;
    default_type  application/octet-stream;
    server_names_hash_bucket_size 64;

    client_max_body_size 50M;
    sendfile        on;
    keepalive_timeout  65;

    server {
        listen       80;
        server_name  localhost;
        root   html;

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

        #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$ {
            # root           html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }
    }

    include servers/*; }
以下是可用的网站:

    server {
        listen 80;
        listen project.localhost:80;
        server_name project.localhost;

        location / {
            root html/project.localhost/public_html;
            index index.php index.html index.htm;
            try_files $uri $uri/ =404;
        }

        location ~ \.php$ {
            root html/project.localhost/public_html;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            fastcgi_param  SCRIPT_FILENAME $request_filename;
            fastcgi_param  SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include        fastcgi_params;
        }

}
这是dnsmasq.conf:

address=/.localhost/127.0.0.1
下面是/etc/hosts:

127.0.0.1       localhost
255.255.255.255 broadcasthost
::1             localhost
127.0.0.1   project.localhost www.project.localhost

但当我在浏览器中浏览project.localhost时,它会显示与localhost/index.php相同的页面。我做错了什么?

正如@Richard在评论部分提到的那样,我能够通过将
站点可用/*.conf
include/usr/local/etc/nginx/sites available/*.conf
包含在我的nginx.conf之前解决这个问题。感谢@Richard

如果
服务器名称
值是
project.localhost
而不是
project.local
,我看不出可用的
站点中的文件是否已包含在您的Nginx配置中。您正在包括
服务器
目录中的文件(请参见最后一行)。使用
nginx-T
(大写
T
)查看所有包含文件中的整个nginx配置,并确保存在具有正确
服务器名称的
服务器
块。