编译源码 cd httpd-2.4.33 ./buildconf ./configure --enable-ssl --enable-so --enable-http2 --with-mpm=event --with-included-apr --with-ssl=/usr/local/openssl --prefix=/usr/local/apache2 make
configure 参数说明 --enable-ssl will build Apache with SSL support, so you can enable HTTPS on your websites. --enable-so will enable dynamically loaded modules. So you can enable and disable modules without recompilation (I will describe modules in configuration part) --enable-http2 will enable HTTP/2 support. --with-mpm will set multiprocessing modules for Apache. I'm using event, but you can use worker or prefork instead. event works best for me and I think that it is mpm that will give you most performance. --with-included-apr It will use APR library that you copied to srclib directory --with-ssl will point compiler to newer version of OpenSSL. Make sure that you compiled it first! --prefix is the installation path for Apache httpd compiled package
# Set ServerName to prevent warning on Apache start ServerName localhost
# Set user and group User httpd Group www
# Configure entry file for your application. If you plan to use PHP make sure that it's as first possible file DirectoryIndex index.php index.html
# If you are using PHP with PHP-FPM which I highly suggest enable proxy modules LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
# Enable pretty links and mod_rewrite that is highly used in all frameworks and CMSes LoadModule rewrite_module modules/mod_rewrite.so
# Useful for WordPress sites - enables Require for setting up access to given resources. LoadModule access_compat_module modules/mod_access_compat.so
# One more useful thing for WordPress and Let's Encrypt - enables Alias. If you are using composer and wpackagist it's a must, otherwise if you don't plan to use aliases, leave that disabled LoadModule alias_module modules/mod_alias.so
# Enable status module for monitoring Apache. If you don't plan to use that, leave that commented out LoadModule authz_host_module modules/mod_authz_host.so LoadModule status_module modules/mod_status.so
<IfModule mod_expires.c> # Enable expirations ExpiresActive On
# Default directive for types not specified below ExpiresDefault "access plus 1 week"
# Expirations for given mime type ExpiresByType image/gif "access plus 1 month" ExpiresByType image/ico "access plus 1 month" ExpiresByType image/jpg "access plus 1 month" ExpiresByType image/jpeg "access plus 1 month" ExpiresByType image/png "access plus 1 month" ExpiresByType text/css "access plus 1 month" ExpiresByType text/javascript "access plus 1 month" </IfModule>