Solved!
Hi,
For apache server I do not have any problems. But when I try to install the advanced template on Nginx server, I always get 502 Bad gateway response. (I am newbie with nginx)
[i]The Nginx works, because I have an index.php file which contains the
<?php phpinfo(); ?>
code and when I visit the localhost in the browser I get the phpinfo response fine. So it is work for a simple php file. So I think I installed the nginx fine.[/i]
I use Ubuntu 16.04 with php7.0
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.php index.html index.htm index.nginx-debian.html;
server_name _;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
location ~ \.php$ {
include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# With php7.0-fpm:
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
location ~ /\.ht {
deny all;
}
}
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name myapp.dev;
root /var/www/html/myapp/frontend/web/;
index index.php;
access_log /var/www/html/myapp/frontend/runtime/log/frontend-access.log;
error_log /var/www/html/myapp/frontend/runtime/log/frontend-error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#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_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php7.0-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
server {
charset utf-8;
client_max_body_size 128M;
listen 80; ## listen for ipv4
#listen [::]:80 default_server ipv6only=on; ## listen for ipv6
server_name admin.myapp.dev;
root /var/www/html/myapp/backend/web/;
index index.php;
access_log /var/www/html/myapp/backend/runtime/log/backend-access.log;
error_log /var/www/html/myapp/backend/runtime/log/backend-error.log;
location / {
# Redirect everything that isn't a real file to index.php
try_files $uri $uri/ /index.php?$args;
}
# uncomment to avoid processing of calls to non-existing static files by Yii
#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_params;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
fastcgi_pass 127.0.0.1:9000;
#fastcgi_pass unix:/var/run/php7.0-fpm.sock;
try_files $uri =404;
}
location ~ /\.(ht|svn|git) {
deny all;
}
}
And here is the host:
127.0.1.1 admin.myapp.dev
127.0.1.1 myapp.dev
And I have the following log entries:
[b]Access log
[/b]
127.0.0.1 - - [01/May/2016:11:43:30 +0200] "GET /favicon.ico HTTP/1.1" 200 318 "http://myapp.dev/" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.94 Safari/537.36"
[b]Error log
[/b]
2016/05/01 09:54:45 [error] 10729#10729: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 127.0.0.1, server: myapp.dev, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "myapp.dev"