Laravel部署404
1. 运行环境
manjaro xfce最新版
nginx 1.26.1
PHP 8.3.9
laravel 11.9
mysql和redis没装,不知道是不是因为没装导致的?
2. 问题描述?
- 手动配置部署,没有用部署面板/工具,报404;
- laravel项目是用composer直接创建的,就装了依赖,其他没动;
- 文档上要求的扩展phpinfo上都有;
- 在项目的public文件夹下新增一个php文件输出hello world,可以正常访问;
- 尝试在linux上做开发环境,练手部署,所以没有装mysql、redis之类的
- hosts文件已添加对应的域名
- nginx配置文件如下:
web.php配置路由server { listen 80; server_name erp.me; root /usr/share/nginx/html/erp.me/my-la/public; index index.php; location / { index index.php index.html error/index.html; error_page 400 /error/400.html; error_page 403 /error/403.html; error_page 404 /error/404.html; error_page 500 /error/500.html; error_page 501 /error/501.html; error_page 502 /error/502.html; error_page 503 /error/503.html; error_page 504 /error/504.html; error_page 505 /error/505.html; error_page 506 /error/506.html; error_page 507 /error/507.html; error_page 509 /error/509.html; error_page 510 /error/510.html; include /usr/share/nginx/html/erp.me/my-la/public/nginx.htaccess; autoindex off; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } location ~ \.php$ { fastcgi_pass 127.0.0.1:7001; 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; } }
访问erp.me/index.php/ok 报404,但是在public下新增一个404.php,又能访问的到<?php use Illuminate\Support\Facades\Route; Route::get('/ok', function () { return "6666666"; });
推荐文章: