tmas
tmas

Reputation: 442

Vhost settings for nginx + symfony2 + hhvm

I'm unable to find anyone clearly explaining on how the vhost for symfony2 should be setup, it's my first time with puphpet, nginx and hhvm. Hopefully some of you can help me out.

I can easily surf redwood.thomas.dev/app.php or redwood.thomas.dev/app_dev.php and it works but as soon as I go to an actual url redwood.thomas.dev/app.php/login it stops working. Also if I go to address.dev than I get a file overview and it doesn't go to an index file (app.php)

puphpet settings I tried several variations, I post this one because it works fine for an old Yii application.

            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'

it results in this config:

     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;
     }

Upvotes: 0

Views: 264

Answers (1)

tmas
tmas

Reputation: 442

After many attempts I settled on this configuration which seem to be working. Hopefully it helps someone.

    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'

Upvotes: 3

Related Questions