Caddy

Summary: How to set up Caddy for a working PmWiki installation, including a working CleanURLs configuration
Users: (view? / edit)
Discussion: Caddy-Talk?

Questions answered by this recipe

How to set up Caddy with a Caddyfile for PHP and CleanURLs so PmWiki works appropriately

All sections are optional, you can remove those that do not apply to your recipe, and add new ones.

Description

A description and configuration snippet for getting Caddy to work correctly with PmWiki, including CleanURLs.

Installation

After installing Caddy (it works with just a simple binary), make sure a version of php-fpm is installed. Take note of the socket-location to fill in later.

Configuration

You can add the following snippet to your configuration to set up PmWiki sites with a simple import pmwiki statement. The only other thing you need to define is the root of your PmWiki-installation with a root * /path/to/pmwik directive pointing to the directory where your index.php is. Replace unix//var/run/php-fpm/php-fpm.sock with the location of the php-fpm socket on your system. This snippet creates PmWiki on the root level of the domain you put the import statement at.

(pmwiki) {

        @page {
                path_regexp page "^/([A-Z0-9\xa0-\xff].*)$"
        }
        encode gzip
        php_fastcgi unix//var/run/php-fpm/php-fpm.sock
        rewrite @page /pmwiki/pmwiki.php?n={http.regexp.page.1}&{query}
        file_server

}

A full Caddyfile could then look like this:

(pmwiki) {

        @page {
                path_regexp page "^/([A-Z0-9\xa0-\xff].*)$"
        }
        encode gzip
        php_fastcgi unix//var/run/php-fpm/php-fpm.sock
        rewrite @page /pmwiki/pmwiki.php?n={http.regexp.page.1}&{query}
        file_server

}

example.com {

        root * /srv/http/wiki
        import pmwiki

}

and a simple one with CleanURLs off even works with:

example.com {

        root * /srv/http/wiki
        encode gzip
        php_fastcgi unix//var/run/php-fpm/php-fpm.sock
        file_server

}

Notes

The contents of the snippet can be included directly as well, and the snippet should be easy to adapt for other configurations.

Comments

See discussion at Caddy-Talk?