nginx + symfony2 + hhvm的Vhost设置

时间:2015-10-06 10:12:03

标签: symfony nginx hhvm puphpet

我无法找到任何人清楚地解释如何设置vm for symfony2,这是我第一次使用puphpet,nginx和hhvm。希望你们中的一些人可以帮助我。

我可以轻松浏览redwood.thomas.dev/app.php或redwood.thomas.dev/app_dev.php并且它可以正常工作,但是一旦我找到一个实际的网址redwood.thomas.dev/app.php/login它停止工作。此外,如果我去address.dev而不是我获得文件概述并且它没有转到索引文件(app.php)

puphpet设置我尝试了几种变体,我发布了这个,因为它适用于旧的Yii应用程序。

            location_redwood_1:
                location: /
                autoindex: 'off'
                internal: false
                try_files:
                    - $uri
                    - $uri/
                    - /app.php$is_args$args
                fastcgi: ''
                fastcgi_index: ''
                fastcgi_split_path: ''
            location_redwood_2:
                location: '~ \.php$'
                autoindex: 'off'
                internal: false
                try_files:
                    - $uri
                    - $uri/
                    - /app.php$is_args$args
                fastcgi: '127.0.0.1:9000'
                fastcgi_index: app_dev.php
                fastcgi_split_path: '^(.+\.php)(/.*)$'
                fast_cgi_params_extra:
                    - 'SCRIPT_FILENAME $request_filename'
                    - 'APP_ENV dev'

导致此配置:

     server {
       listen                *:80;

       server_name           redwood.thomas.dev www.redwood.thomas.dev;
       client_max_body_size 1m;

       root /var/www/redwood/web;
         index  app.php app_dev.php;

       access_log            /var/log/nginx/nxv_8kzrp075w1ra.access.log;
       error_log             /var/log/nginx/nxv_8kzrp075w1ra.error.log;

       location ~ \.php$ {

         root  /var/www/redwood/web;
         fastcgi_index app_dev.php;
         fastcgi_split_path_info ^(.+\.php)(/.*)$;
         try_files $uri $uri/ /app.php$is_args$args;
         include /etc/nginx/fastcgi_params;
         fastcgi_pass 127.0.0.1:9000;

         fastcgi_param SCRIPT_FILENAME $request_filename;
         fastcgi_param APP_ENV dev;

       }
       location / {

         root  /var/www/redwood/web;
         try_files $uri $uri/ /app.php$is_args$args;
          autoindex on;
         index  index.html index.htm index.php;


       }
       sendfile off;
     }

1 个答案:

答案 0 :(得分:3)

经过多次尝试后,我确定了这种配置似乎正在起作用。希望它可以帮助某人。

    nxv_8kzrp075w1ra:
        server_name: redwood.thomas.dev
        server_aliases:
            - www.redwood.thomas.dev
        www_root: /var/www/redwood/web
        listen_port: '80'
        index_files:
        client_max_body_size: 20m
        ssl: '0'
        ssl_cert: ''
        ssl_key: ''
        ssl_port: '443'
        ssl_protocols: ''
        ssl_ciphers: ''
        rewrite_to_https: '1'
        spdy: '1'
        locations:
            location_redwood_1:
                location: /
                try_files:
                    - $uri
                    - '@rewriteapp'
            location_redwood_2:
                location: '@rewriteapp'
                rewrite_rules:
                    - '^(.*)$ /app.php/$1 last'
            location_redwood_3:
                location: '~ ^/(app|app_dev|config)\.php(/|$)'
                autoindex: 'off'
                internal: false
                try_files:
                    - $uri
                    - $uri/
                    - /app.php$is_args$args
                fastcgi: '127.0.0.1:9000'
                fastcgi_index: app_dev.php
                fastcgi_split_path: '^(.+\.php)(/.*)$'
                fast_cgi_params_extra:
                    - 'SCRIPT_FILENAME $document_root$fastcgi_script_name'
                    - 'APP_ENV dev'