dev*_*evo 3 php ubuntu nginx laravel laravel-5
我Laravel 5.4
在Ubuntu 16.04
服务器中使用nginx
和安装了我的应用php7.0-fpm
,
502 Bad Gateway
Run Code Online (Sandbox Code Playgroud)
Nginx virtualhost配置,
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/laravel/public;
index index.php index.html;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
try_files $uri /index.php =404;
include fastcgi_params;
fastcgi_keep_conn on;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param PATH_INFO $fastcgi_path_info;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_intercept_errors on;
fastcgi_pass unix:/var/run/php7.0-fpm.sock;
}
}
Run Code Online (Sandbox Code Playgroud)
尝试了以下方法,但仍然无法正常工作,
改变fastcgi_pass unix:/var/run/php7.0-fpm.sock;
以fastcgi_pass 127.0.0.1:9000;
改变try_files $uri $uri/ /index.php?$query_string;
以try_files $uri $uri/ /index.php$is_args$args;
每次更改后重新启动服务,
service nginx restart
service php7.0-fpm restart
Run Code Online (Sandbox Code Playgroud)
我只能使用此配置访问主路由,
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/laravel/public;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
Inf*_*ter 13
首次安装:sudo apt install php-fpm
然后检查/etc/php/7.4/fpm
,确保你的版本是 php 7.0 -fpm.sock、php 7.4 -fpm.sock 或7.x
fastcgi_pass unix:/run/php/php7.4-fpm.sock;
Run Code Online (Sandbox Code Playgroud)
使用默认的基于php的配置更新一行,
server {
listen 80; ## listen for ipv4; this line is default and implied
#listen [::]:80 default ipv6only=on; ## listen for ipv6
root /var/www/html/laravel/public;
index index.html index.htm index.php;
# Make site accessible from http://localhost/
server_name localhost;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ~ \.php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
Run Code Online (Sandbox Code Playgroud)
这里更改try_files $uri $uri/ =404;
为try_files $uri $uri/ /index.php?$query_string;