Created
June 25, 2016 14:34
-
-
Save adnanfajr/34f9ed4c6ab6d82b92179d5892ae6274 to your computer and use it in GitHub Desktop.
Nginx configuration for PHP applications. Copy at /etc/nginx/sites-available/domain.com
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
server { | |
listen 80; | |
#listen 80 default_server; if default server | |
root /var/www/DOMAIN; | |
index index.php index.html index.htm; | |
server_name DOMAIN.COM www.DOMAIN.COM; | |
if ($http_x_forwarded_proto = "http") { | |
return 301 | |
https://$server_name$request_uri; | |
} | |
location / { | |
# try_files $uri $uri/ =404; | |
try_files $uri $uri/ /index.php?q=$uri&$args; | |
} | |
error_page 404 /404.php; | |
error_page 500 502 503 504 /50x.html; | |
location = /50x.html { | |
root /usr/share/nginx/html; | |
} | |
location ~ \.php$ { | |
try_files $uri =404; | |
fastcgi_split_path_info ^(.+\.php)(/.+)$; | |
fastcgi_pass unix:/var/run/php5-fpm.sock; | |
fastcgi_index index.php; | |
fastcgi_param DOMAIN.COM $document_root$fastcgi_script_name; | |
include fastcgi_params; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment