The kernel ships a complete Apache virtual host for one installation as doc/eng-us/examples/ezpublish.conf (the file keeps its historical name). Port 80 redirects to HTTPS and serves certificate challenge files; port 443 serves the site over HTTP/2 with PHP-FPM, with the routing rules of .htaccess_root in the virtual host itself. Apache then reads no .htaccess at all (AllowOverride None), which saves a file lookup per folder on every request.
Install it
- Load the modules rewrite, proxy, proxy_fcgi, ssl, headers, expires and http2. On Debian: a2enmod rewrite proxy_fcgi ssl http2 headers expires.
- Copy the file to /etc/apache2/sites-available/example.com.conf (Debian, then a2ensite example.com) or /etc/httpd/conf.d/example.com.conf (Red Hat style), and replace example.com, /var/www/example.com, the PHP-FPM socket and the certificate paths.
- Create the PHP-FPM pool the socket belongs to. See The PHP-FPM pool.
- Get the certificate. The port 80 host serves /.well-known/acme-challenge/ for a client that uses the webroot method.
- Check and reload.
apachectl configtest # Syntax OK systemctl reload apache2 # httpd on Red Hat style systems curl -sI https://example.com/ | head -1
Uploads
The example sets LimitRequestBody 0, so Apache sets no limit of its own; upload_max_filesize and post_max_size in the PHP-FPM pool decide.
With a control panel
A hosting panel such as Plesk writes the virtual host itself, so do not edit its files. Keep .htaccess instead: ./console exp:setup:htaccess --apply puts .htaccess_root into place as .htaccess. With the example virtual host (AllowOverride None) a .htaccess in the root is not read, but copying it does no harm and keeps the rules in force should the tree ever be served with AllowOverride All.
After an upgrade
Compare the rules with the new .htaccess_root after every upgrade. ./console exp:setup:htaccess (without --apply) shows the difference between your .htaccess and the new .htaccess_root, which is also the list of rules to carry over into your virtual host.
The static cache
With the static cache on, add the rules of doc/eng-us/examples/staticcache_offload.conf to the virtual host, or use .htaccess_root_static, which is .htaccess_root with those rules already in place.