Opterius runs Nginx by default for all domains — it is fast, memory-efficient, and handles the vast majority of PHP applications without any Apache-specific configuration. For sites that rely on .htaccess files (WordPress, Joomla, Drupal, Magento, legacy cPanel migrations), you can enable Apache as the PHP backend on a per-domain basis.
How It Works
When .htaccess support is enabled for a domain, Opterius switches that domain to a Nginx + Apache dual-stack setup:
| Layer | Role |
|---|---|
| Nginx (public, port 80/443) | SSL termination, static file serving, caching |
| Apache (internal, 127.0.0.1:8080) | PHP execution, .htaccess parsing, mod_rewrite |
Nginx serves images, CSS, JavaScript, fonts, and other static assets directly (faster than routing them through Apache). All other requests — PHP files and anything that might be controlled by .htaccess — are proxied to Apache. Apache reads the .htaccess file in the document root and applies its rules before running the PHP script.
Both layers share the same PHP-FPM socket, so there is no second PHP process and no performance penalty for the PHP execution itself.
Enabling .htaccess Support
- Go to Domains in the sidebar.
- Find the domain you want to enable it for.
- Click the .htaccess support toggle — it switches from Disabled (grey) to Enabled (orange).
The panel reconfigures Nginx and Apache for that domain and reloads both services. The change takes effect immediately — no downtime.
[!NOTE] Subdomains have their own
.htaccesstoggle independent of the parent domain.
Disabling .htaccess Support
Click the toggle again to switch the domain back to pure Nginx mode. Apache is removed from the request path and Nginx handles PHP directly via PHP-FPM. The Apache vhost for the domain is deleted.
What .htaccess Can Do
With Apache enabled, the full Apache feature set is available in .htaccess:
mod_rewrite— URL rewriting and redirects (RewriteEngine On,RewriteRule,RewriteCond)mod_headers— custom HTTP response headersmod_expires— browser cache control (ExpiresActive On)mod_deflate— gzip compression per-directoryOptionsdirectives —FollowSymLinks,-Indexes- Password protection via
AuthType Basic/htpasswd - Custom error pages (
ErrorDocument) - PHP ini overrides (
php_value,php_flag)
Migrating from cPanel
If you imported a cPanel backup, the .htaccess files from the original server are already in your document root. Enable .htaccess support for the domain and they will be read automatically — no conversion or editing required.
The most common cPanel .htaccess contents (WordPress permalink rewrites, Joomla SEF URLs, Magento URL rewrites) all work without modification.
When to Keep Nginx-Only Mode
If your application does not use .htaccess, leave the toggle off. Nginx-only mode is:
- Faster — no proxy hop between Nginx and Apache
- Lower memory — no Apache worker processes for that domain
- Simpler — one less service involved in the request path
Laravel, Symfony, custom PHP applications, and Node.js apps do not use .htaccess and should remain in Nginx-only mode.
Troubleshooting
Site returns 502 Bad Gateway after enabling
Apache may have failed to start or the vhost has a syntax error. Check systemctl status apache2 (or httpd) and journalctl -u apache2 -n 50.
.htaccess rules are not being applied
Confirm the toggle shows Enabled (orange). If enabled but rules still don't work, check that the .htaccess file is in the correct document root directory and that the syntax is valid.
Redirect loop
A common issue when .htaccess rewrites check HTTPS or SERVER_PORT. Apache sits behind Nginx and always sees HTTP internally. Use the X-Forwarded-Proto header instead:
RewriteCond %{HTTP:X-Forwarded-Proto} !https
RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301]
Password protection (htpasswd) not working
Make sure Apache has mod_auth_basic enabled. The .htpasswd file path in .htaccess should be an absolute server path, e.g.:
AuthUserFile /home/myuser/example.com/.htpasswd