Skip to content

Instantly share code, notes, and snippets.

@ghalusa
Last active Oct 12, 2021
Embed
What would you like to do?
nginx default configuration file (ubuntu path: /etc/nginx/sites-available/default) with conversions of .htaccess environment variables and mod_rewrite logic, along with parameters supporting a fastcgi-based php setup
server {
listen 80;
root /var/www/YOUR_DIRECTORY;
index index.php index.html index.htm;
###################################################
# Change "yoururl.com" to your host name
server_name yoururl.com;
location / {
try_files $uri $uri/ /index.php?q=$uri&$args;
}
location /site/ {
if (!-e $request_filename){
rewrite ^/site/(.*)$ /site/index.php break;
}
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param PATH_TO_FRAMEWORKS /var/www/frameworks/;
fastcgi_param CORE_TYPE frameworks;
fastcgi_param IS_DEV true;
include fastcgi_params;
}
location = /favicon.ico {
log_not_found off;
access_log off;
}
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
location ~ /\. {
deny all;
}
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
}
@ItsAdventureTime

This comment has been minimized.

Copy link

@ItsAdventureTime ItsAdventureTime commented Apr 12, 2016

Thanks for this one. I was having an issue installing HVVM because of it. It seems that when instaling the fastcgi script, it looks for the default file of "sites-available" yet Ubuntu 14.04 didn't install anything, be it on aptitude or apt-get.

@talhawish

This comment has been minimized.

Copy link

@talhawish talhawish commented Oct 16, 2020

I'm having this error 502 bad gateway nginx 1.18.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment