Answer the question
In order to leave comments, you need to log in
Yii2 Nginx 502 Bad Gateway?
I'm trying to set up nginx to work with Yii2, I got the following config:
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on;
server_name site.ru;
root /var/www/html/site/web;
index index.php;
access_log /var/www/html/log/access.log;
error_log /var/www/html/log/error.log;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ {
try_files $uri =404;
}
error_page 404 /404.html;
location ~ \.php$ {
include fastcgi.conf;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
#fastcgi_pass unix:/var/run/php5-fpm.sock;
}
location ~ /\.(ht|svn|git) {
deny all;
}
location /phpmyadmin {
root /usr/share/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
try_files $uri =404;
root /usr/share/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $request_filename;
include /etc/nginx/fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
root /usr/share/;
}
}
location /phpMyAdmin {
rewrite ^/* /phpmyadmin last;
}
}
Answer the question
In order to leave comments, you need to log in
The settings of the locations responsible for php are completely different. On the main site, there is nothing but fastcgi_pass, and what is in fastcgi.conf (and whether it was connected at all) is still a big question. include /etc/nginx/fastcgi_params must be written on the very first line (for this reason ).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question