Introduction to VPS and Web Technology Development

nginx配置laravel后只可以访问index.php访问其他路由为404

自由vps php

server {

    listen       80;

    server_name  sir486.com;

    root   /www/sir486/public;

    index  index.php index.html index.htm;

    #charset koi8-r;

    

    access_log /dev/null;

    #access_log  /var/log/nginx/nginx.localhost.access.log  main;

    error_log  /var/log/nginx/nginx.localhost.error.log  warn;

    

    #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   /usr/share/nginx/html;

    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass   http://127.0.0.1;

    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ [^/]\.php(/|$) {

        fastcgi_pass   php:9000;

        include        fastcgi-php.conf;

        include        fastcgi_params;

    }

    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}

加入location



实现效果

server {

    listen       80;

    server_name  sir486.com;

    root   /www/sir486/public;

    index  index.php index.html index.htm;

    #charset koi8-r;

    

    access_log /dev/null;

    #access_log  /var/log/nginx/nginx.localhost.access.log  main;

    error_log  /var/log/nginx/nginx.localhost.error.log  warn;

    

    #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   /usr/share/nginx/html;

    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80

    #

    #location ~ \.php$ {

    #    proxy_pass   http://127.0.0.1;

    #}

    

    location / {         try_files $uri $uri/ /index.php?$query_string; }

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    #

    location ~ [^/]\.php(/|$) {

        fastcgi_pass   php:9000;

        include        fastcgi-php.conf;

        include        fastcgi_params;

    }

    # deny access to .htaccess files, if Apache's document root

    # concurs with nginx's one

    #

    #location ~ /\.ht {

    #    deny  all;

    #}

}

使用chatGPT寻求答案
标签: 暂无标签

免责声明:

本站提供的资源,都来自网络,版权争议与本站无关,所有内容及软件的文章仅限用于学习和研究目的。不得将上述内容用于商业或者非法用途,否则,一切后果请用户自负,我们不保证内容的长久可用性,通过使用本站内容随之而来的风险与本站无关,您必须在下载后的24个小时之内,从您的电脑/手机中彻底删除上述内容。如果您喜欢该程序,请支持正版软件,购买注册,得到更好的正版服务。侵删请致信E-mail:master@freevpsweb.com

同类推荐
评论列表