开启php nginx后无法进入路由器,php – 在nginx之后找不到Laravel路由

在我将ICG更改为nginx之后,除索引页之外的所有路由都不起作用.

Laravel配置:

#/etc/nginx/sites-enabled/laravel

server {

listen 80;

root /var/www/home;

index index.php;

server_name 192.168.178.71;

access_log /var/www/home/storage/app/logs/laravel-nginx-access.log;

error_log /var/www/home/storage/app/logs/laravel-nginx-error.log error;

location /home {

root /home/public;

try_files $uri $uri/ /index.php?$query_string;

}

location = /favicon.ico { log_not_found off; access_log off; }

location = /robots.txt { log_not_found off; access_log off; }

# ERROR

error_page 404 /index.php;

# DENY HTACCESS

location ~ /\.ht {

deny all;

}

}

默认配置:

# /etc/nginx/sites-enabled/default

server {

listen 80 default_server;

listen [::]:80 default_server;

root /var/www;

# Add index.php to the list if you are using PHP

index index.php index.html index.htm;

server_name 192.168.178.71 localhost;

location / {

# First attempt to serve request as file, then

# as directory, then fall back to displaying a 404.

try_files $uri $uri/ index.php?$query_string;

autoindex on;

# Remove trailing slash to please routing system.

if (!-d $request_filename) {

rewrite ^/(.+)/$/$1 permanent;

}

}

location ~ \.php${

#try_files $uri /index.php =404;

try_files $uri =404;

fastcgi_split_path_info ^(.+\.php)(/.+)$;

fastcgi_pass unix:/var/run/php5-fpm.sock;

fastcgi_index index.php;

include fastcgi_params;

fastcgi_param SCRIPT_FILENAME document_root$fastcgi_script_name;

}

location ~ /\.ht {

deny all;

}

}

我的nginx配置

#/etc/nginx/nginx.conf

user www-data;

worker_processes 4;

pid /run/nginx.pid;

events {

worker_connections 768;

# multi_accept on;

}

http {

disable_symlinks off;

##

# Basic Settings

##

sendfile on;

tcp_nopush on;

tcp_nodelay on;

keepalive_timeout 65;

types_hash_max_size 2048;

# server_tokens off;

# server_names_hash_bucket_size 64;

# server_name_in_redirect off;

include /etc/nginx/mime.types;

default_type application/octet-stream;

##

# SSL Settings

##

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE

ssl_prefer_server_ciphers on;

##

# Logging Settings

##

access_log /var/log/nginx/access.log;

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

##

# Gzip Settings

##

gzip on;

gzip_disable "msie6";

##

# Virtual Host Configs

##

include /etc/nginx/conf.d/*.conf;

include /etc/nginx/sites-enabled/*;

}

我尝试了什么:

/var/www/home# (home folder is laravel folder)

sudo chown -R www-data:www-data *

/var/www/home#

sudo chown -R root:root *

我也试着改变

try_files $uri $uri/ /index.php?$query_string;

try_files $uri $uri/ /index.php$is_args$args;

try_files $uri $uri/ /index.php;

php artisan cache:clear

谷歌的大多数问题我都读过,但没有什么可以帮助我.

我的phpinfo – link

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
当使用React部署到Nginx时,如果直接访问页面出现404错误,可能是由于配置问题引起的。以下是一些可能的解决方案: 1. 检查Nginx配置文件:确保在Nginx的配置文件中设置了正确的根目录,并且指向React项目的构建文件夹。例如,如果项目构建后生成的文件夹名为“build”,则Nginx配置文件中的根目录应该是指向这个文件夹的路径。 2. 配置路由规则:当使用React路由时,需要在Nginx配置文件中设置一些路由规则,以便正确地处理页面间的导航。这通常涉及使用try_files指令。例如,将下面的代码段添加到Nginx配置文件的服务器块中: ``` location / { try_files $uri /index.html; } ``` 这将确保无论访问的是哪个URL,Nginx都会返回index.html文件,然后React路由器将负责渲染正确的页面。 3. 确保React项目已正确构建:在部署到Nginx之前,确保React项目已经正确地构建。使用`npm run build`命令来生成构建文件夹,并确保在Nginx配置中指向了正确的构建文件夹。 4. 重启Nginx服务:在修改Nginx配置文件后,需要重启Nginx服务以使更改生效。使用`sudo service nginx restart`命令来重新启动Nginx。 如果以上解决方案都没有解决问题,还可以检查Nginx的错误日志,以了解详细的错误信息。日志文件通常位于`/var/log/nginx/error.log`。检查错误日志可能有助于进一步诊断并解决404错误。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值