Install and configure Cherokee web server with FastCGI and virtual hosts

Intermediate 45 min Apr 03, 2026 42 views
Ubuntu 24.04 Ubuntu 22.04 Debian 12 AlmaLinux 9 Rocky Linux 9 Fedora 41

Set up Cherokee web server with web-based administration, FastCGI support for PHP applications, SSL-enabled virtual hosts, and performance optimizations for lightweight web hosting environments.

Prerequisites

  • Root or sudo access
  • Domain names pointing to your server
  • Basic understanding of web server concepts

What this solves

Cherokee is a lightweight, high-performance web server that provides an intuitive web-based administration interface and excellent FastCGI support. This tutorial walks you through installing Cherokee, configuring it with the cherokee-admin interface, setting up SSL-enabled virtual hosts, and optimizing it for PHP applications with FastCGI.

Step-by-step installation

Update system packages

Start by updating your package manager to ensure you get the latest versions available.

sudo apt update && sudo apt upgrade -y
sudo dnf update -y

Install Cherokee web server

Install Cherokee and its PHP FastCGI module. Cherokee provides excellent FastCGI support out of the box.

sudo apt install -y cherokee php-fpm php-cli php-mysql php-curl php-gd php-xml
sudo dnf install -y epel-release
sudo dnf install -y cherokee php-fpm php-cli php-mysqlnd php-curl php-gd php-xml

Configure PHP-FPM

Configure PHP-FPM to work with Cherokee by ensuring it listens on a Unix socket for better performance.

listen = /var/run/php/php8.3-fpm.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm.max_children = 50
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 35

Start and enable services

Enable Cherokee and PHP-FPM services to start automatically on boot.

sudo systemctl enable --now cherokee
sudo systemctl enable --now php8.3-fpm
sudo systemctl status cherokee
sudo systemctl status php8.3-fpm

Configure firewall access

Open the necessary ports for HTTP, HTTPS, and Cherokee admin interface access.

sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw allow 9090/tcp
sudo firewall-cmd --permanent --add-port=80/tcp
sudo firewall-cmd --permanent --add-port=443/tcp
sudo firewall-cmd --permanent --add-port=9090/tcp
sudo firewall-cmd --reload

Configure Cherokee admin interface

Launch Cherokee admin

Start the Cherokee admin interface to configure your web server through the web-based interface.

sudo cherokee-admin -b -t 60
Note: The -b flag binds to all interfaces, and -t 60 sets a 60-minute timeout. Keep this terminal session open while configuring.

Access admin interface

Open your web browser and navigate to the admin interface. Cherokee admin will display the access URL and one-time password.

http://your-server-ip:9090

Configure basic settings

In the Cherokee admin interface, configure the basic server settings including server name and administrator email.

  • Navigate to "General" in the admin interface
  • Set your server name to your domain (example.com)
  • Configure the administrator email
  • Set the server timeout to 60 seconds

Set up virtual hosts

Create directory structure

Create directories for your virtual host websites with proper ownership and permissions.

sudo mkdir -p /var/www/example.com/public_html
sudo mkdir -p /var/www/test.example.com/public_html
sudo chown -R www-data:www-data /var/www/
sudo chmod -R 755 /var/www/
Never use chmod 777. It gives every user on the system full access to your files. Use 755 for directories and 644 for files with proper ownership instead.

Create test pages

Create simple test pages to verify your virtual host configuration works correctly.

<?php
echo "<h1>Welcome to example.com</h1>";
echo "<p>Server: " . $_SERVER['SERVER_NAME'] . "</p>";
echo "<p>PHP Version: " . phpversion() . "</p>";
?>
<?php
echo "<h1>Welcome to test.example.com</h1>";
echo "<p>Server: " . $_SERVER['SERVER_NAME'] . "</p>";
echo "<p>PHP Version: " . phpversion() . "</p>";
?>

Configure virtual hosts in Cherokee admin

Use the Cherokee admin interface to create and configure virtual hosts with FastCGI support.

  1. In Cherokee admin, go to "Virtual Servers"
  2. Click "Add new Virtual Server"
  3. Set the nickname to "example.com"
  4. Set document root to "/var/www/example.com/public_html"
  5. In "Host Match", add "example.com" and "www.example.com"
  6. Repeat for test.example.com

Configure PHP FastCGI handler

Set up PHP processing through FastCGI for each virtual host in the Cherokee admin interface.

  1. Select your virtual host in Cherokee admin
  2. Go to "Behavior" tab
  3. Click "Add new rule"
  4. Select "Extensions" and add "php"
  5. Set handler to "FastCGI"
  6. Configure FastCGI source to use Unix socket: "/var/run/php/php8.3-fpm.sock"
  7. Click "Add" to create the information source if needed

Configure SSL certificates

Install Certbot

Install Certbot to obtain free Let's Encrypt SSL certificates for your domains.

sudo apt install -y certbot
sudo dnf install -y certbot

Obtain SSL certificates

Use Certbot in webroot mode to obtain SSL certificates for your domains while Cherokee is running.

sudo certbot certonly --webroot -w /var/www/example.com/public_html -d example.com -d www.example.com
sudo certbot certonly --webroot -w /var/www/test.example.com/public_html -d test.example.com

Configure SSL in Cherokee admin

Configure SSL certificates for your virtual hosts through the Cherokee admin interface.

  1. In Cherokee admin, select your virtual host
  2. Go to "Security" tab
  3. Enable "SSL/TLS"
  4. Set certificate file: "/etc/letsencrypt/live/example.com/fullchain.pem"
  5. Set certificate key: "/etc/letsencrypt/live/example.com/privkey.pem"
  6. Enable "HTTPS only" redirect if desired
  7. Repeat for other virtual hosts

Set up certificate renewal

Configure automatic SSL certificate renewal using systemd timer.

sudo systemctl enable certbot-renew.timer
sudo systemctl start certbot-renew.timer
sudo systemctl status certbot-renew.timer

Performance optimization

Configure Cherokee performance settings

Optimize Cherokee for better performance by adjusting connection limits and timeouts through the admin interface.

  1. In Cherokee admin, go to "General"
  2. Set "Max connection reuse" to 500
  3. Set "Connection timeout" to 60
  4. Enable "Keep alive"
  5. Set "Max keep alive requests" to 500

Enable compression

Enable gzip compression to reduce bandwidth usage and improve page load times.

  1. In Cherokee admin, go to virtual host "Advanced"
  2. Enable "Content Encoding"
  3. Select "gzip" and "deflate"
  4. Set compression level to 6
  5. Add MIME types: text/html, text/css, text/javascript, application/javascript

Configure static file caching

Set up browser caching for static files to improve performance.

  1. In Cherokee admin, select virtual host
  2. Go to "Behavior" and add new rule
  3. Select "Extensions" and add: css, js, png, jpg, jpeg, gif, ico
  4. Set handler to "Static files"
  5. In "Expiration", set "Time" to "1 month"

Apply configuration changes

Save and apply all Cherokee configuration changes, then restart services.

sudo systemctl restart cherokee
sudo systemctl restart php8.3-fpm
sudo systemctl status cherokee

Security hardening

Hide server information

Configure Cherokee to hide version information and server details from HTTP headers.

  1. In Cherokee admin, go to "General"
  2. Disable "Server tokens"
  3. Set custom "Server string" if needed

Configure security headers

Add security headers to protect against common web vulnerabilities.

  1. In Cherokee admin, select virtual host
  2. Go to "Advanced" → "Custom Headers"
  3. Add headers:
  • X-Frame-Options: DENY
  • X-Content-Type-Options: nosniff
  • X-XSS-Protection: 1; mode=block
  • Strict-Transport-Security: max-age=31536000; includeSubDomains

Restrict access to sensitive files

Configure Cherokee to deny access to sensitive configuration files and directories.

  1. In Cherokee admin, go to virtual host "Behavior"
  2. Add new rule with "Regular Expression"
  3. Pattern: \.(conf|ini|log|sh|sql)$
  4. Set handler to "HTTP error" with 403 Forbidden
  5. Add another rule for directories like .git, .svn with same settings

Verify your setup

Test your Cherokee installation, virtual hosts, SSL certificates, and PHP functionality.

sudo systemctl status cherokee
sudo systemctl status php8.3-fpm
curl -I http://example.com
curl -I https://example.com
curl https://example.com/
ssl-cert check-ssl example.com

You can also test the configuration by visiting your domains in a web browser. You should see your PHP test pages with proper SSL certificates.

Common issues

SymptomCauseFix
Cherokee won't startPort 80/443 already in useCheck with sudo netstat -tlnp | grep :80 and stop conflicting services
PHP files download instead of executingFastCGI not configured properlyVerify PHP-FPM is running and FastCGI source is correctly configured in Cherokee admin
Permission denied errorsWrong file ownershipRun sudo chown -R www-data:www-data /var/www/ and use chmod 755 for directories, 644 for files
SSL certificate errorsCertificate path incorrectVerify paths in Cherokee admin match /etc/letsencrypt/live/domain/
Virtual host not workingHost match configuration wrongCheck "Host Match" settings in Cherokee admin include all domain variants
Cherokee admin interface inaccessibleFirewall blocking port 9090Open port 9090 in firewall or use SSH tunnel: ssh -L 9090:localhost:9090 user@server

Next steps

Automated install script

Run this to automate the entire setup

#cherokee #web-server #fastcgi #virtual-hosts #ssl-certificates

Need help?

Don't want to manage this yourself?

We handle infrastructure for businesses that depend on uptime. From initial setup to ongoing operations.

Talk to an engineer