Table of ContentsInstallation
PHP method #1: Apache module
PHP method #2: FastCGI
PHP method #3: PHP-FPM
Virtual host template
SSL Support (HTTPS)
The main configuration file - apache24/httpd.conf - has a section with LoadModule lines. This is where you enable/disable Apache modules. Out of the box many modules are commented out, you might want to uncomment some of them. For example, mod_rewrite module, which you will probably need.
Near the end of that file you will find some extra config files also commented out. Uncomment these two:
- Include etc/apache24/extra/httpd-mpm.conf - configure the MPM you selected
- Include etc/apache24/extra/httpd-default.conf - some default values you might want to change, for example, increase Timeout to match PHP's max_execution_time.
Place your virtual host definition files in apache24/Includes directory. Each file should end with '.conf' otherwise it will be ignored.
Apache will load these *.conf files in alphabetical order. First virtual host loaded becomes the default host, i.e. it will be shown on direct access to the server via IP address not name. You can start name of the file of such host with a digit to make sure it is loaded first.
# Default vhost for *:80 <VirtualHost _default_:80> ServerName localhost DocumentRoot "/usr/local/www/apache24/data" </VirtualHost> ## Default vhost for *:443 (https) #<VirtualHost _default_:443> # ServerName localhost # DocumentRoot "/usr/local/www/apache24/data" # # SSLEngine on # # You need to specify the certificate and the key: # SSLCertificateFile "/etc/certs/localhost.crt" # SSLCertificateKeyFile "/etc/certs/localhost.unencrypted.key" #</VirtualHost>
Add to /etc/rc.conf:
# service apache24 start
To rotate Apache logs daily and keep 7 rotations of them add to /etc/newsyslog.conf:
/var/log/httpd-*.log root:wheel 640 7 * @T00 BJG /var/run/httpd.pid 30
# service newsyslog restart