有没有一种方法来声明基于名称的虚拟主机,但共享相同的目录声明? 因此,例如,这两个Vhost中的Directory部分是相同的,那么是否有一种方法只声明一次,并让它们被两个Vhost使用? 错误日志部分相同。 有没有一种方法只声明错误日志一次? (可能在目录内?)
<VirtualHost *:80> ServerName email.123456.com DocumentRoot /var/www/mail <Directory /var/www/mail> Options FollowSymLinks DirectoryIndex index.php AllowOverride All Order Allow,Deny Allow from All </Directory> ErrorLog ${APACHE_LOG_DIR}/mail/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/mail/access.log combined </VirtualHost> <IfModule mod_ssl.c> <VirtualHost *:443> ServerName email.123456.com DocumentRoot /var/www/mail <Directory /var/www/mail> Options FollowSymLinks DirectoryIndex index.php AllowOverride All Order Allow,Deny Allow from All </Directory> ErrorLog ${APACHE_LOG_DIR}/mail/error.log LogLevel warn CustomLog ${APACHE_LOG_DIR}/mail/access.log combined SSLEngine on SSLCertificateFile /var/certs/123456/123456.com.crt SSLCertificateKeyFile /var/certs/123456/123456.key SSLCertificateChainFile /var/certs/123456/sf_bundle.crt <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> BrowserMatch "MSIE [2-6]" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0 BrowserMatch MSIE [17-9] ssl-unclean-shutdown </VirtualHost> </IfModule>
如果是我,我会将共享configuration存储在“fragment”.conf文件中,并在每个VirtualHost或共享这些片段中的configuration的其他位置使用Include指令。 即
Include conf-fragments/error-log.conf Include conf-fragments/Directory-mail.conf