Created
May 8, 2016 14:43
-
-
Save marcelog/77eaba22a26a7136ab3a1c4fc63bb9e3 to your computer and use it in GitHub Desktop.
Part of: http://marcelog.github.io/articles/configure_nginx_php_5.3_5.2_fastcgi.html NGINX configuration file to support different (multiple) PHP versions in different virtual hosts by using FastCGI
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Useful to debug rewrite rules and other stuff | |
error_log logs/error.log notice; | |
http { | |
# Debug rewrite rules | |
rewrite_log on; | |
} | |
server { | |
listen 80; | |
server_name php53; | |
root /www/php53; | |
index index.php; | |
fastcgi_index index.php; | |
location / { | |
index index.php; | |
} | |
location ~ \.htaccess { | |
deny all; | |
} | |
# These lines will allow to redirect any request that does not match | |
# an existant file to a front controller (zf, yii, symfony, etc) | |
error_page 404 = /index.php; | |
if (!-e $request_filename) { | |
rewrite ^.*$ /index.php last; | |
} | |
location ~ \.php { | |
# Workaround PHP vulnerability: | |
# http://forum.nginx.org/read.php?2,88845,page=3 | |
try_files $uri =404; | |
# Alternatively you can set | |
# cgi.fix_pathinfo = false | |
# in php.ini | |
include /etc/nginx/fastcgi_params; | |
keepalive_timeout 0; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass 127.0.0.1:9001; | |
} | |
} | |
server { | |
listen 80; | |
server_name php52; | |
root /www/php52; | |
index index.php; | |
fastcgi_index index.php; | |
location / { | |
index index.php; | |
} | |
location ~ \.htaccess { | |
deny all; | |
} | |
# These lines will allow to redirect any request that does not match | |
# an existant file to a front controller (zf, yii, symfony, etc) | |
error_page 404 = /index.php; | |
if (!-e $request_filename) { | |
rewrite ^.*$ /index.php last; | |
} | |
location ~ \.php { | |
# Workaround PHP vulnerability: | |
# http://forum.nginx.org/read.php?2,88845,page=3 | |
try_files $uri =404; | |
# Alternatively you can set | |
# cgi.fix_pathinfo = false | |
# in php.ini | |
include /etc/nginx/fastcgi_params; | |
keepalive_timeout 0; | |
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; | |
fastcgi_pass 127.0.0.1:9000; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment