Laravel Nginx 502坏网关
我尝试使用nginxweb服务器部署Laravel应用程序。但是,我得到了502坏网关错误。我已经检查了位于sites available文件夹中的默认文件,并做了一些更改 下面的代码段显示了默认的站点配置文件Laravel Nginx 502坏网关,laravel,nginx,nginx-config,Laravel,Nginx,Nginx Config,我尝试使用nginxweb服务器部署Laravel应用程序。但是,我得到了502坏网关错误。我已经检查了位于sites available文件夹中的默认文件,并做了一些更改 下面的代码段显示了默认的站点配置文件 server { listen 80 default_server; listen [::]:80 default_server; root /var/www/html/laravel/skill-tool-app/public;
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/laravel/skill-tool-app/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 18.130.196.144;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
我还检查了文件权限。当我尝试访问该网站时。它使浏览器下载index.php文件。您应该从该配置文件启用php: 请更新您的位置栏:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# PLEASE UPDATE php version with your current installed version
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
整个文件应如下所示:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/laravel/skill-tool-app/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 18.130.196.144;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
您必须从以下配置文件启用php: 请更新您的位置栏:
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
# PLEASE UPDATE php version with your current installed version
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
整个文件应如下所示:
server {
listen 80 default_server;
listen [::]:80 default_server;
root /var/www/html/laravel/skill-tool-app/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 18.130.196.144;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
切断defatult_服务器。解除阻止以下部分的第一部分
server {
listen 80;
listen [::]:80;
root /var/www/html/laravel/skill-tool-app/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 18.130.196.144;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
现在,您需要启用配置,创建一个指向已启用站点的符号链接:
ln -s /etc/sites-available/YOUR_FILE_NAME /etc/sites-enabled/
然后
或
切断defatult_服务器。解除阻止以下部分的第一部分
server {
listen 80;
listen [::]:80;
root /var/www/html/laravel/skill-tool-app/public;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name 18.130.196.144;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404 /index.php?$query_string;
}
# pass PHP scripts to FastCGI server
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php-fpm (or other unix sockets):
fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
# # With php-cgi (or other tcp sockets):
#fastcgi_pass 127.0.0.1:9000;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
现在,您需要启用配置,创建一个指向已启用站点的符号链接:
ln -s /etc/sites-available/YOUR_FILE_NAME /etc/sites-enabled/
然后
或