Catalog / Cherokee Web Server Cheatsheet

Cherokee Web Server Cheatsheet

A comprehensive cheat sheet for the Cherokee web server, covering configuration, common tasks, and useful modules.

Basic Configuration

Installation

Install Cherokee on Debian/Ubuntu:

sudo apt-get update
sudo apt-get install cherokee

Install Cherokee on CentOS/RHEL:

sudo yum install cherokee

Start Cherokee:

sudo systemctl start cherokee

Stop Cherokee:

sudo systemctl stop cherokee

Restart Cherokee:

sudo systemctl restart cherokee

Check Cherokee status:

sudo systemctl status cherokee

Web Administration Interface

Access the Cherokee admin interface by navigating to http://your_server_ip:9090 in your web browser.

Default username is admin and password is admin.

Change the default password immediately after logging in for security reasons.

Configuration Files

cherokee.conf

Main configuration file. Located in /etc/cherokee/.

vhost/

Directory containing virtual host configurations. Located in /etc/cherokee/.

Virtual Host Configuration

Creating a Virtual Host

Using the Web Admin Interface:

  1. Go to Virtual Servers.
  2. Click Add to create a new virtual host.
  3. Configure the Document Root, Server Name, and other settings as needed.
  4. Save the configuration.

Manually Editing Configuration Files:

  1. Create a new file in /etc/cherokee/vhost/ (e.g., mysite.conf).
  2. Add the virtual host configuration (see example below).
  3. Restart Cherokee.

Example Virtual Host Configuration

<Cherokee>
    <VServer>
        ServerName = "mysite.com"
        DocumentRoot = "/var/www/mysite"
        <Source>
            <Rule>
                Match = default
                Handler = static
            </Rule>
        </Source>
    </VServer>
</Cherokee>

Explanation:

  • ServerName: The domain name for the virtual host.
  • DocumentRoot: The directory where website files are stored.
  • Source: Defines how requests are handled.

Common Virtual Host Directives

ServerName

Specifies the domain name for the virtual host.

DocumentRoot

Defines the root directory for the website files.

ErrorLog

Specifies the path to the error log file.

AccessLog

Specifies the path to the access log file.

Advanced Configuration

Enabling SSL/TLS

Using the Web Admin Interface:

  1. Go to Virtual Servers.
  2. Select the virtual host.
  3. Enable SSL.
  4. Specify the paths to the Certificate and Private Key files.
  5. Save the configuration.

Manually Editing Configuration Files:

  1. Add the following directives to your virtual host configuration:
<VServer>
    SSL = "On"
    SSL_Certificate = "/path/to/certificate.pem"
    SSL_Key = "/path/to/private_key.pem"
</VServer>
  1. Restart Cherokee.

Reverse Proxy Configuration

Using the Web Admin Interface:

  1. Go to Virtual Servers.
  2. Select the virtual host.
  3. Add a new Source.
  4. Set Handler to Reverse Proxy.
  5. Specify the Upstream server address (e.g., http://localhost:8080).
  6. Save the configuration.

Manually Editing Configuration Files:

<Source>
    <Rule>
        Match = default
        Handler = proxy
        Upstream = "http://localhost:8080"
    </Rule>
</Source>

Load Balancing

Cherokee supports load balancing by configuring multiple upstream servers.

<Source>
    <Rule>
        Match = default
        Handler = proxy
        Upstream = "http://server1:8080, http://server2:8080"
        Type = round_robin
    </Rule>
</Source>

Type can be round_robin, least_conn, or random.

Modules and Handlers

Common Handlers

static

Serves static files (HTML, CSS, JavaScript, images).

proxy

Acts as a reverse proxy, forwarding requests to upstream servers.

php-fastcgi

Handles PHP requests using FastCGI.

cgi

Handles CGI scripts.

Configuring PHP-FastCGI

Using the Web Admin Interface:

  1. Go to Virtual Servers.
  2. Select the virtual host.
  3. Add a new Source.
  4. Set Match to *.php.
  5. Set Handler to php-fastcgi.
  6. Specify the Executable path (e.g., /usr/bin/php-cgi).
  7. Save the configuration.

Manually Editing Configuration Files:

<Source>
    <Rule>
        Match = "*.php"
        Handler = php-fastcgi
        Executable = "/usr/bin/php-cgi"
    </Rule>
</Source>

Logging

ErrorLog

Specifies the path to the error log file. Example: /var/log/cherokee/error.log

AccessLog

Specifies the path to the access log file. Example: /var/log/cherokee/access.log