2016-08-24 2 views
0

Я пытаюсь запустить приложение Symfony с Vagrant, установить Vagrant, скопируйте Symfony приложение в папке Vagrant (vagrantrasmus/clientproject) Я добавить в хостах 192.168.7.7 clientproject и добавить в client.conf из conf.dRun Symfony приложение с Vagrant

server { 
    server_name clientproject; 
    root /vagrantrasmus/clientproject/web; 

    location/{ 
     # try to serve file directly, fallback to app.php 
     try_files $uri /app.php$is_args$args; 
    } 
    # DEV 
    # This rule should only be placed on your development environment 
    # In production, don't include this and don't deploy app_dev.php or config.php 
    location ~ ^/(app_dev|config)\.php(/|$) { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     # When you are using symlinks to link the document root to the 
     # current version of your application, you should pass the real 
     # application path instead of the path to the symlink to PHP 
     # FPM. 
     # Otherwise, PHP's OPcache may not properly detect changes to 
     # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 
     # for more information). 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
    } 
    # PROD 
    location ~ ^/app\.php(/|$) { 
     fastcgi_pass unix:/var/run/php5-fpm.sock; 
     fastcgi_split_path_info ^(.+\.php)(/.*)$; 
     include fastcgi_params; 
     # When you are using symlinks to link the document root to the 
     # current version of your application, you should pass the real 
     # application path instead of the path to the symlink to PHP 
     # FPM. 
     # Otherwise, PHP's OPcache may not properly detect changes to 
     # your PHP files (see https://github.com/zendtech/ZendOptimizerPlus/issues/126 
     # for more information). 
     fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; 
     fastcgi_param DOCUMENT_ROOT $realpath_root; 
     # Prevents URIs that include the front controller. This will 404: 
     # http://domain.tld/app.php/some-path 
     # Remove the internal directive to allow URIs like this 
     internal; 
    } 

    # return 404 for all other php files not matching the front controller 
    # this prevents access to other php files you don't want to be accessible. 
    location ~ \.php$ { 
     return 404; 
    } 

    error_log /var/log/nginx/project_error.log; 
    access_log /var/log/nginx/project_access.log; 
} 

Но, не работает, я получил 502 Bad Gateway.

+0

, что у вас в журнале? –

ответ

0

изменить содержание client.conf в

server { 
    listen  80; 

    server_name localhost; 
    #root /var/www/default; 
    root /var/www/default/clientproject/web 
    index index.php index.html index.htm; 
    access_log /var/log/nginx/default-access.log main; 
    error_log /var/log/nginx/default-error.log; 

    error_page 500 502 503 504 /50x.html; 

    location = /50x.html { 
     root /var/www/default; 
    } 

    location/{ 
     #try_files $uri /app_dev.php$is_args$args; 
     try_files $uri $uri/ @rewrite; 
    } 
    location @rewrite { 
     rewrite ^(.*)$ /index.php; 
    } 

    location ~ \.php { 
     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/php-fpm.sock; 
    } 
} 

И я имею в журналах

==> /var/log/nginx/default-error.log <== 
2016/08/24 08:42:52 [error] 26472#0: *57 connect() to unix:/var/run/php-fpm.sock failed (111: Connection refused) while connecting to upstream, client: 192.168.7.1, server: clientproject, request: "GET /app_dev.php/translation HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm.sock:", host: "clientproject" 

==> /var/log/nginx/default-access.log <== 
192.168.7.1 - - [24/Aug/2016:08:42:52 +0000] "GET /app_dev.php/translation HTTP/1.1" 502 537 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36" "-" 
Смежные вопросы