虚拟机域名指向共享文件夹404的问题

环境:

vmware
php7
nginx
mysql
laravel

挂载目录 /mnt/hgfs/WWW/test/l/public

首先是/usr/local/nginx/conf/vhost 下的test.com.conf

server{    listen 80;    #listen [::]:80;
    server_name test.com test2.com;    index index.html index.htm index.php default.html default.htm default.php;    root  /mnt/hgfs/WWW/test/l/public;    include rewrite/laravel.conf;    #error_page   404   /404.html;

    # Deny access to PHP files in specific directory
    #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

    include enable-php-pathinfo.conf;    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
    {        expires      30d;
    }    location ~ .*\.(js|css)?$
    {        expires      12h;
    }    location ~ /.well-known {        allow all;
    }    location ~ /\. {        deny all;
    }    access_log off;
}

接下来是windows的host文件

192.168.0.16 test.com

问题:此时使用游览器访问test.com出现了404,域名指向挂载目录是行不通的吗,还是我配置错了?求大神


LEATH
浏览 893回答 1
1回答

婷婷同学_

缺少nginx 与 php 通讯的地方   location ~ \.php(.*)$  {            fastcgi_pass   127.0.0.1:9000;            fastcgi_index  index.php;            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;            fastcgi_param  PATH_INFO  $fastcgi_path_info;            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;            include        fastcgi_params;         }
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript