Symfony2 configuration tutorial under Nginx

  

This configuration uses example.com as the domain name, please replace it according to your actual situation.

Reminder this configuration only allows the two entry files app.php and app_dev.php in the web directory to run in PHP
script mode, other PHP
existing in the web directory Files (such as other definitions of other Symfony2 entry files, or other PHP
programs installed in this directory) will be downloaded by the user if they are accessed.
server { listen 80; server_name example.com; # domain root /var/www/symfony2/web; # site root directory error_log /var/log/nginx/symfony2.error.log; access_log /var/log/nginx /symfony2.access.log; # If the URL contains app.php, it is forwarded to the pseudo-static format rewrite ^/app\\.php/?(.*)$ /$1 permanent; location /{ index app.php; try_files $ Uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app.php/$1 last; } # This section is a very popular option for handing over PHP requests to the FastCGI service. Location ~ ^/(app| App_dev)\\.php(/| $) { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS off; }}

The following is the HTTPS configuration:
server { listen 443; server_name example.com; root /var/www/symfony2/web; ssl on; ssl_certificate /etc/ssl/certs/symfony2.crt; ssl_certificate_key /etc/ssl/private/symfony2.key; Error_log /var/log/nginx/symfony2.error.log; access_log /var/log/nginx/symfony2.access.log; rewrite ^/app\\.php/?(.*)$ /$1 permanent; location /{ index App.php; try_files $uri @rewriteapp; } location @rewriteapp { rewrite ^(.*)$ /app.php/$1 last; } location ~ ^/(app| App_dev)\\.php(/| $) { fastcgi_pass 127.0.0.1:9000; fastcgi_split_path_info ^(.+\\.php)(/.*)$; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_param HTTPS on; }}



Copyright © Windows knowledge All Rights Reserved