Web server configuration

Here's how to set up different web servers.

Apache

The .htaccess configuration file for the Apache web server:

<IfModule mod_rewrite.c>
RewriteEngine on

DirectoryIndex index.html yellow.php
RewriteRule ^(cache|content|system)/ error [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ yellow.php [L]
</IfModule>

When your website doesn't work, please check the following steps. If Yellow has been installed in a subfolder, you should add RewriteBase to your configuration file. This will fix most web server problems. Here's an example:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /yellow/
DirectoryIndex index.html yellow.php
RewriteRule ^(cache|content|system)/ error [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^ yellow.php [L]
</IfModule>

When your website still doesn't work, please check the Apache web server. If Yellow has been installed on a selfhosted web server, you have to enable the rewrite module and configure AllowOverride All in the web server.

Make sure that the web server can read and write files. You can manually adjust file permissions so that the web server can overwrite files, for example with command chmod -R a+rw *. As an alternative you can assign the group www-data and umask 002 to the web server and users.

Nginx

The nginx.conf configuration file for the Nginx web server:

server {
    listen 80;
    server_name website.com;
    root /var/www/website/;
    index index.html yellow.php;

    location /cache {
        rewrite ^(.*)$ /error break;
    }

    location /content {
        rewrite ^(.*)$ /error break;
    }

    location /system {
        rewrite ^(.*)$ /error break;
    }

    location / {
        if (!-e $request_filename) {
            rewrite ^/(.*)$ /yellow.php last;
            break;
        }
    }

    location ~ \.php$ {
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_index yellow.php;
        include fastcgi_params;
    }
}

When your website doesn't work, please check server_name and root. If the configuration file has been changed, you need to restart/reload the Nginx web server.

Make sure that the web server can read and write files. You can manually adjust file permissions so that the web server can overwrite files, for example with command chmod -R a+rw *. As an alternative you can assign the group www-data and umask 002 to the web server and users.

Static website

Yellow is a flat-file CMS and a static site generator. As a static site generator, it offers a build command that you can run from within a folder containing the Yellow installation. It then generates a static website, that works on any web server.

You can create a static website from the command line.

  1. Open a terminal window.
  2. Go to your Yellow installation, where the yellow.php is.
  3. Type the following line: php yellow.php build /var/www/website

This will build a static website in folder /var/www/website. Upload the folder to your web hosting and build a new version when needed. The URL can be defined in the system settings, for example StaticUrl: http://website/.

As an alternative to a static website you can build a cache. This speeds up your website, but you have to update the cache repeatedly. Here's an example: php yellow.php build. To clean the cache type the following line: php yellow.php clean.

Error page

When there are problems an error page is shown. When a web browser requests a file that the web server cannot find your website will show a “File not found” page. The file system/config/page-error-404.txt defines how a missing file looks like:

---
Title: File not found
---
The requested file was not found. Oh no...

If you use Yellow as a flat-file CMS there's nothing more to do. If you use Yellow to create a static website there's one additional step. Configure your web server to display your custom error page instead of its default 404 page.

For Apache add the following to your configuration file:

ErrorDocument 404 /404.html

For Nginx add the following to your configuration file:

error_page 404 /404.html;

Next: Yellow themes →