Skip to content

[HOW TO] Using Nginx with Phile

Schlaefer edited this page Mar 17, 2018 · 3 revisions

Using Phile with Nginx

Using Phile from root

Use this if you plan to host Phile from http://yourdomain.com/ or the root of a subdomain.

An example Nginx config:

  location / {
    try_files $uri $uri/ /index.php$args;
  }

Using Phile from a subdirectory

Use this if you plan to host Phile from http://yourdomain.com/blog

An example Nginx config:

  location /blog {
    try_files $uri $uri/ @blog;
  }

  location @blog {
    rewrite ^/blog/(.*)$ /blog/index.php/$1;
  }

Blocking access to files that users should not see

You should spend some time making sure that at least your config.php file cannot be accessed. Especially since it holds an encryption key.

I think the following is a fairly comprehensive list of the files that you should block

location ~ /.git/ { access_log off; log_not_found off; deny all; }
  location ~ /(.gitignore|.gitmodules) { access_log off; log_not_found off; deny all; }
  location ~ /(build.xml|composer.json|composer.phar|generator.php|lib|phing|README.md) { access_log off; log_not_found off; deny all; }
  location ~ /(Changelog.md|composer.lock|config.php|default_config.php|LICENSE) { access_log off; log_not_found off; deny all; }
  location ~ /\.          { access_log off; log_not_found off; deny all; }