Server Configuration

This section will go over a few basics of setting up your server for a Laravel application like PyroCMS.

NGINX Example

Below is an example NGINX configuration:

**Notice:** The web root should be set to your installation's **public** directory.
# --------------------------
#
# Redirect non-www > www
#
# --------------------------

server {
    listen      80;
    listen      443 ssl;
    server_name www.example.com;
    return 301 http://example.com$request_uri;
}

# --------------------------
#
# Redirect to HTTP > HTTPS
#
# --------------------------

#server {
#    listen      80;
#    server_name example.com www.example.com;
#    return      301 https://example.com$request_uri;
#}

server {
    listen      80;
    listen      443 ssl;

    server_name example.com;

    access_log /var/log/nginx/example.com_access_log combined;
    error_log /var/log/nginx/example.com_error_log error;

    index  index.php index.html;

    charset utf-8;

    root /var/www/vhosts/example.com/www.example.com/public;

    ssl_certificate      /var/www/vhosts/example.com/ssl/example.com.crt;
    ssl_certificate_key  /var/www/vhosts/example.com/ssl/example.com.key;

    gzip on;
    gzip_static on;
    gzip_http_version 1.0;
    gzip_disable "MSIE [1-6].";
    gzip_vary on;
    gzip_comp_level 9;
    gzip_proxied any;
    gzip_types text/plain text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript application/javascript image/svg+xml;

    fastcgi_intercept_errors off;
    fastcgi_buffers 8 16k;
    fastcgi_buffer_size 32k;
    fastcgi_read_timeout 180;

    # Remove trailing slashes
    rewrite ^/(.*)/$ /$1 permanent;

    expires $expires;

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

    location ~ \.php$ {

        fastcgi_pass unix:/var/run/php-fpm-default.sock;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;

        include        fastcgi_params;
    }

    location ~ /\.ht {

        access_log off;
        log_not_found off;

        deny all;
    }

    location ~* \.ico$ {

        expires 1w;
        access_log off;
    }

    location ~* \.(?:jpg|jpeg|gif|png|ico|gz|svg|svgz|ttf|otf|woff|eot|mp4|ogg|ogv|webm)$ {

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

        access_log off;
        log_not_found off;
    }

    location ~* \.(?:css|js)$ {

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

        access_log off;
        log_not_found off;
    }

    add_header "X-UA-Compatible" "IE=Edge,chrome=1";
}