This machine uses a window environment, everything is normal, but it is deployed on a Linux system (with nginx). When accessed, the controller and methods can be executed normally, and the page can also be output, but the output page But the css file is missing. After checking, it is a 500 error. The request has been redirected to the public folder.
My directory structure is:
public/web/css/css.css
The domain name is:
aaa.com
Directly accessing aaa.com will execute Public/index.php (because nginx is set up to redirect the request to the public folder), and the page can also be output normally, but the page requested:
url:aaa.com/web/css/css.css
It’s an error of 500. I can’t figure it out. Please give me some advice. Thank you all.
Now I found that part of the problem is nginx configuration problem, I copied the settings online:
server {
listen 80;
server_name xxx;
access_log xxx main;
root xxx;
#root xxx;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
}
}
Although you can access the homepage now, there is another problem now. My project has a front and backend. The frontend can be accessed, but the backend cannot be accessed. This is how I implement the frontend and backend. I use routing separation. The map method in RouteProvider.php configures two routing files:
public function map(Router $router) {
//加载前台路由文件
$router->group([
'namespace' => 'App\Http\WebControllers',
// 'prefix' => 'Web',//引入前缀
//'middleware' => 'some_common_middleware',
], function ($router) {
require app_path('Http/routes/routes.php');
});
//加载后台路由文件
$router->group([
'namespace' => 'App\Http\AdminControllers',
'middleware' => 'App\Http\Middleware\LoginMenuMiddleware',
'prefix' => 'Am',//引入前缀
], function ($router) {
require app_path('Http/routes/admin_routes.php');
});
}
Now I cannot log in to the backend, that is, xxx.com/Am/Index/index will send a 500 error, and the ajax in the frontend cannot be executed.
Project structure directory:
Thank you everyone for your help. It's a pity that it can only be adopted by a great god in the end. The situation is like this. I will explain it here in case someone in the future has the same situation as me.
If the same thing happens to me In this case, please first check whether there are cache files in the bootstrap/cache directory of the server. If there are, please clear them and try again. It is indeed caused by the existence of cache.
Thank you for the invitation.
Personally, there are a few mistakes in deployment on Linux:
1. Case sensitive.
2. The folder development part under laravel uses soft connections.
3.index.php Under public, static resources should correspond to public.
If the problem is not solved, please post your project structure directory
Thanks for the invitation!
You can only exclude them one by one like this
Troubleshoot file cache issues
Directory permission problem, modify the directory permissions to 755
500 is an internal server error, indicating that there is an error in your code, not 404, Not found
Users and groups must be set in the configuration of php-fpm
Modify user group configuration
Set user group to nginx
The following directories of laravel require write permission
The vhost configuration for laravel is as follows:
500 error is very simple ~
If 500 is wrong, there will definitely be a prompt
The network panel in the browser may not be able to capture the results. You can open it directly in a new note to view the tips
Or check the files under this directory. Whenever an error occurs, a log will be generated
rewrite doesn’t work. . You need to first determine whether the file exists before rewriting
It’s best to post the error returned by the framework
Thank you everyone for your help. It is a pity that it can only be adopted by a great god in the end. The situation is like this, and I will explain it here in case someone else has the same situation as me.
If the same situation as me occurs, please first Check whether there are cache files in the bootstrap/cache directory of the server. If there are, please clear them and try again. It is indeed caused by the existence of cache.