Php laravel内部页面在AWS EC2 Nginx上不起作用
我正在一个Php laravel内部页面在AWS EC2 Nginx上不起作用,php,apache,laravel,amazon-web-services,Php,Apache,Laravel,Amazon Web Services,我正在一个laravelv5.1.11网站上工作,该网站位于AWS EC2 ubuntu和ngnix服务器上。我已成功设置网站,但我的内部页面不工作 配置为: server { listen 82; server_name www.example.com; return 301 https://$server_name$request_uri; } server { listen 83; server_name www.example.com; root /
laravelv5.1.11
网站上工作,该网站位于AWS EC2 ubuntu
和ngnix
服务器上。我已成功设置网站,但我的内部页面不工作
配置为:
server {
listen 82;
server_name www.example.com;
return 301 https://$server_name$request_uri;
}
server {
listen 83;
server_name www.example.com;
root /home/in4matic/example-website-dev/public;
location / {
index index.php;
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location ~* \.php$ {
fastcgi_index index.php;
fastcgi_pass 127.0.0.1:9000;
include fastcgi_params;
#fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
#fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_FILENAME $document_root/index.php;
#fastcgi_param PATH_TRANSLATED $document_root$fastcgi_path_info;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
}
}
如何解决这个问题。将laravel应用程序从apache移动到nginx不需要太多修改,但因为laravel使用.htaccess文件进行url重写,而这在nginx中不起作用,所以您必须修改nginx配置文件,以便nginx可以重写url。以下是我的配置文件的示例:
server {
listen 80;
server_name your-website.com;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000 # Keep this as per your old config;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我所有的laravel应用程序都使用了这个配置
并确保存储目录具有适当的权限。将laravel应用程序从apache移动到nginx不需要太多修改,但由于laravel使用.htaccess文件进行url重写,这在nginx中不起作用,因此您必须修改nginx配置文件,以便nginx可以重写url。以下是我的配置文件的示例:
server {
listen 80;
server_name your-website.com;
# note that these lines are originally from the "location /" block
root /usr/share/nginx/html;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000 # Keep this as per your old config;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
我所有的laravel应用程序都使用了这个配置
并确保存储目录具有适当的权限。您需要包括nginx配置。您还可以添加.htaccess文件。从共享主机迁移laravel应用程序有点棘手,因为您需要删除一些“调整”,以使laravel在共享主机上启动并运行。我需要在您的问题中包括
nginx配置
,看看有什么可能是错误的,并为您的问题提供解决方案或一些指导。到目前为止,我什么也没做。只需上传站点并在config/app.php
中设置base\u url
,以及一些数据库设置更改,您需要包括nginx配置。您还可以添加.htaccess文件。从共享主机迁移laravel应用程序有点棘手,因为您需要删除一些“调整”,以使laravel在共享主机上启动并运行。我需要在您的问题中包括nginx配置
,看看有什么可能是错误的,并为您的问题提供解决方案或一些指导。到目前为止,我什么也没做。只需上传站点,在config/app.php
中设置base\u url
,并更改一些数据库设置