admin管理员组

文章数量:1202361

I deployed a CakePHP v4.5 application on AWS Elastic Beanstalk. The deployment was successful, and the environment status was set to "OK". However, when testing the application through the link provided by AWS, I encountered an issue:

The root route (/) works perfectly, but accessing any other route results in a 404 Not Found error. After checking the logs, I found the following error message whenever a 404 is triggered:

[error] 26495#26495: *25 open() "/var/www/html/webroot/painel" failed (2: No such file or directory)

Based on some research, I created a custom configuration for Nginx by adding the file

.platform/nginx/conf.d/custom.conf

to the root directory of the project. The file content was as follows:

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

However, after adding this configuration and deploying the application, the deployment failed and produced the following error:

[ERROR] An error occurred during execution of command [app-deploy] - [start proxy with new configuration]. Stop running the command. 
Error: copy proxy conf from staging failed with error validate nginx configuration failed with error Command /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf failed with error exit status 1. 
Stderr:nginx: [emerg] open() "/var/proxy/staging/nginx/fastcgi_params" failed (2: No such file or directory) in /var/proxy/staging/nginx/conf.d/custom.conf:13 nginx: configuration file 
/var/proxy/staging/nginx/nginx.conf test failed

Additionally, the AWS environment variable for the project root is set to /webroot.

I deployed a CakePHP v4.5 application on AWS Elastic Beanstalk. The deployment was successful, and the environment status was set to "OK". However, when testing the application through the link provided by AWS, I encountered an issue:

The root route (/) works perfectly, but accessing any other route results in a 404 Not Found error. After checking the logs, I found the following error message whenever a 404 is triggered:

[error] 26495#26495: *25 open() "/var/www/html/webroot/painel" failed (2: No such file or directory)

Based on some research, I created a custom configuration for Nginx by adding the file

.platform/nginx/conf.d/custom.conf

to the root directory of the project. The file content was as follows:

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

However, after adding this configuration and deploying the application, the deployment failed and produced the following error:

[ERROR] An error occurred during execution of command [app-deploy] - [start proxy with new configuration]. Stop running the command. 
Error: copy proxy conf from staging failed with error validate nginx configuration failed with error Command /usr/sbin/nginx -t -c /var/proxy/staging/nginx/nginx.conf failed with error exit status 1. 
Stderr:nginx: [emerg] open() "/var/proxy/staging/nginx/fastcgi_params" failed (2: No such file or directory) in /var/proxy/staging/nginx/conf.d/custom.conf:13 nginx: configuration file 
/var/proxy/staging/nginx/nginx.conf test failed

Additionally, the AWS environment variable for the project root is set to /webroot.

Share Improve this question asked Jan 21 at 19:23 Maike Da Silva CastilhoMaike Da Silva Castilho 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 0

It seems like /var/proxy/staging/nginx/fastcgi_params file is missing. You are referencing properties $uri and $query_string which could be located there.
Maybe you should try this: https://github.com/nginx/nginx/blob/master/conf/fastcgi_params

本文标签: amazon web servicesCannot configure any route aside from rootStack Overflow