Skip to Content
GuidesSetup Web Server

Web Server Setup

Proper web server configuration is critically important for Flute CMS operation. This guide covers setting up the most popular web servers: Apache, Nginx, and Lighttpd.

⚠️

Make sure your server meets the minimum requirements before starting configuration.

General Requirements

Document Root

The web server’s document root should point to the public folder of your Flute CMS installation, not the root folder of the project.

Correct structure:

/var/www/html/ ├── app/ ├── config/ ├── public/ ← Document root should point here │ ├── index.php │ └── .htaccess ├── storage/ └── vendor/

URL Rewriting

Flute CMS requires URL rewriting support to work correctly. All requests should be redirected to public/index.php.

PHP Configuration

Make sure the following PHP extensions are enabled:

  • PDO
  • GD
  • BCMath
  • JSON
  • Mbstring
  • SimpleXML
  • Zip
  • Curl
  • GMP

Apache Configuration

Apache is the most popular web server and usually requires minimal configuration.

Virtual Host Configuration

Create a virtual host configuration file:

<VirtualHost *:80> ServerName yoursite.com ServerAlias www.yoursite.com DocumentRoot /var/www/html/yoursite/public <Directory /var/www/html/yoursite/public> AllowOverride All Require all granted # Enable URL rewriting RewriteEngine On # Redirect to HTTPS (optional) RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] </Directory> # Logs ErrorLog ${APACHE_LOG_DIR}/yoursite_error.log CustomLog ${APACHE_LOG_DIR}/yoursite_access.log combined </VirtualHost> <VirtualHost *:443> ServerName yoursite.com ServerAlias www.yoursite.com DocumentRoot /var/www/html/yoursite/public # SSL Configuration SSLEngine on SSLCertificateFile /path/to/certificate.crt SSLCertificateKeyFile /path/to/private.key <Directory /var/www/html/yoursite/public> AllowOverride All Require all granted </Directory> # Logs ErrorLog ${APACHE_LOG_DIR}/yoursite_ssl_error.log CustomLog ${APACHE_LOG_DIR}/yoursite_ssl_access.log combined </VirtualHost>

Enable the site:

sudo a2ensite yoursite.conf sudo systemctl reload apache2

Nginx Configuration

Nginx requires manual configuration as it doesn’t support .htaccess files.

Basic Nginx Configuration

server { listen 80; server_name yoursite.com www.yoursite.com; root /var/www/html/yoursite/public; index index.php index.html; # Security headers add_header X-Frame-Options "SAMEORIGIN" always; add_header X-XSS-Protection "1; mode=block" always; add_header X-Content-Type-Options "nosniff" always; add_header Referrer-Policy "no-referrer-when-downgrade" always; add_header Content-Security-Policy "default-src 'self' http: https: data: blob: 'unsafe-inline'" always; # Main location location / { try_files $uri $uri/ /index.php?$query_string; } # PHP processing location ~ \.php$ { fastcgi_pass unix:/var/run/php/php8.2-fpm.sock; fastcgi_param SCRIPT_FILENAME $realpath_root$fastcgi_script_name; include fastcgi_params; fastcgi_hide_header X-Powered-By; } # Deny access to sensitive files location ~ /\. { deny all; } location ~ /(storage|config|app)/ { deny all; } # Static files caching location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { expires 1M; add_header Cache-Control "public, immutable"; } }

Lighttpd Configuration

Lighttpd is a lightweight web server suitable for high-load sites.

# /etc/lighttpd/conf-available/yoursite.conf $HTTP["host"] == "yoursite.com" { server.document-root = "/var/www/html/yoursite/public" # URL rewriting url.rewrite-if-not-file = ( "^/(.*)$" => "/index.php/$1" ) # PHP FastCGI fastcgi.server = ( ".php" => (( "bin-path" => "/usr/bin/php-cgi", "socket" => "/tmp/php.socket", "max-procs" => 2, "idle-timeout" => 20, "bin-environment" => ( "PHP_FCGI_CHILDREN" => "4", "PHP_FCGI_MAX_REQUESTS" => "10000" ), "bin-copy-environment" => ( "PATH", "SHELL", "USER" ), "broken-scriptfilename" => "enable" )) ) # Security $HTTP["url"] =~ "^/(storage|config|app)/" { url.access-deny = ( "" ) } # Static file caching $HTTP["url"] =~ "\.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$" { expire.url = ( "" => "access plus 1 months" ) } }

Troubleshooting

404 Error on All Pages

Cause: URL rewriting not working.

Solution:

  • Apache: Make sure mod_rewrite is enabled and AllowOverride All is set
  • Nginx: Check that try_files directive is configured correctly
  • Lighttpd: Verify url.rewrite-if-not-file configuration

500 Internal Server Error

Cause: PHP errors or incorrect permissions.

Solution:

  1. Check web server error logs
  2. Enable PHP error display in config/app.php
  3. Check file permissions (755 for folders, 644 for files)
  4. Make sure storage/ folder is writable

Static Files Not Loading

Cause: Incorrect document root or security restrictions.

Solution:

  1. Make sure document root points to public/ folder
  2. Check that static files exist in public/ folder
  3. Verify there are no security rules blocking access to static files

Performance Issues

Solutions:

  1. Enable caching: Configure browser caching for static files
  2. Enable compression: Use Gzip/Brotli compression
  3. Optimize PHP: Enable OPcache and configure PHP-FPM
  4. Use CDN: For static content delivery

After configuring the web server, test your site thoroughly and check that all functions work correctly.