Skip to content

Web Server Setup Tips

Apache

Configure URL rewriting in .htaccess or your site's VirtualHost. Ensure .htacces (if you're using one) and index.php files are in the same public-accessible directory — usually your site's DOCUMENT_ROOT. Additionally, if you're using .htaccess make sure your VirtualHost is configured with the AllowOverride option so that the .htaccess rewrite rules can be used.

Some hosts may require you to use the RewriteBase directive. If you need to use the RewriteBase directive, it should be the absolute physical path to the directory that contains the .htaccess file.

# In .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ index.php [QSA,L]

### OR ###

# In apached VirtualHost

<Directory PATH_TO_YOUR_DOCUMENT_ROOT>
    Options -MultiViews +FollowSymLinks
    AllowOverride All
    RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule ^ /index.php [L]
</Directory>

Nginx

The nginx configuration file should contain this code (along with other settings you may need) in your location block:

   try_files $uri $uri/ /index.php?$args;

This assumes that Skinny's index.php is in the root folder of your project (www root).

This is an example Nginx virtual host configuration for the domain example.com. It listens for inbound HTTP connections on port 80. It assumes a PHP-FPM server is running on port 9000. You should update the server_name, error_log, access_log, and root directives with your own values. The root directive is the path to your application’s public document root directory; your Skinny app’s index.php front-controller file should be in this directory.

server {
    listen 80;
    server_name example.com;
    index index.php;
    error_log /path/to/example.error.log;
    access_log /path/to/example.access.log;
    root /path/to/public;

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

    location ~ \.php {
        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name;
        fastcgi_param SCRIPT_NAME $fastcgi_script_name;
        fastcgi_index index.php;
        fastcgi_pass 127.0.0.1:9000;
    }
}

HipHop Virtual Machine for PHP

Your HipHop Virtual Machine configuration file should contain this code (along with other settings you may need). Be sure you change the ServerRoot setting to point to your Skinny app's document root directory.

Server {
    SourceRoot = /path/to/public/directory
}

ServerVariables {
    SCRIPT_NAME = /index.php
}

VirtualHost {
    * {
        Pattern = .*
        RewriteRules {
            * {
                pattern = ^(.*)$
                to = index.php/$1
                qsa = true
            }
        }
    }
}

lighttpd

Your lighttpd configuration file should contain this code (along with other settings you may need). This code requires lighttpd >= 1.4.24.

    url.rewrite-if-not-file = ("(.*)" => "/index.php/$0")

This assumes that Skinny's index.php is in the root folder of your project (www root).

IIS

Ensure the Web.config and index.php files are in the same public-accessible directory. The Web.config file should contain this code:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <rewrite>
            <rules>
                <rule name="skinny" patternSyntax="Wildcard">
                    <match url="*" />
                    <conditions>
                        <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
                        <add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
                    </conditions>
                    <action type="Rewrite" url="index.php" />
                </rule>
            </rules>
        </rewrite>
    </system.webServer>
</configuration>

Google App Engine

Two steps are required to successfully run your Skinny application on Google App Engine. First, ensure the app.yaml file includes a default handler to index.php:

application: your-app-name
version: 1
runtime: php
api_version: 1

handlers:
# ...
- url: /.*
  script: public_html/index.php

Next, edit your index.php file so Skinny knows about the incoming URI:

$app = \Skinny\Skinny::newInstance();

// Google App Engine doesn't set $_SERVER['PATH_INFO']
$app->environment['PATH_INFO'] = $_SERVER['REQUEST_URI'];

// ...
$app->run();