Skip to content

Instantly share code, notes, and snippets.

@kenzie
Last active May 17, 2018 17:48
Show Gist options
  • Save kenzie/5811327 to your computer and use it in GitHub Desktop.
Save kenzie/5811327 to your computer and use it in GitHub Desktop.
Nginx virtual host configuration for Craft CMS, PHP5-FPM, NGINX 1.2.1 and craft/config/general.php for friendly URLs.
server {
listen 80;
root /var/www/craft.dev/public;
index index.php index.html index.htm;
server_name craft.dev;
location / {
try_files $uri $uri/ @rewrites;
}
location @rewrites {
rewrite ^(.*) /index.php?p=$1 last;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
error_page 404 /index.php;
}
<?php
/**
* General Configuration
*
* All of your system's general configuration settings go in here.
* You can see a list of the default settings in craft/app/etc/config/defaults/general.php
*/
return array(
/**
* Whether generated URLs should be formatted using PATH_INFO, e.g. http://domain.com/index.php/path/,
* as opposed to using the query string, e.g. http://domain.com/index.php?p=path
*
* Possible values: true, false, 'auto'
*/
'usePathInfo' => true
);
@jessehudl
Copy link

@keithmancuso I know your comment is years old, but here's a more efficient way to make that config:

        location / {
            try_files $uri $uri/ @rewrites;
        }
        location @rewrites {
            rewrite ^(/en_gb|de|fr|es)?/(.*)$ $1/index.php?p=$2&$args? last;
        }

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