<VirtualHost *:443> documentRoot /var/www/HTML/www.example1.com Servername www.example1.com SSLEngine on SSLCertificatefile /var/www/ssl/www.example1.com/certificate.crt SSLCertificateKeyfile /var/www/ssl/www.example1.com/private.key SSLCACertificatefile /var/www/ssl/www.example1.com/bundle.crt</VirtualHost><VirtualHost *:443> documentRoot /var/www/HTML/www.example2.com Servername www.example2.com SSLEngine on SSLCertificatefile /var/www/ssl/www.example2.com/certificate.crt SSLCertificateKeyfile /var/www/ssl/www.example2.com/private.key SSLCACertificatefile /var/www/ssl/www.example2.com/bundle.crt</VirtualHost>
我希望能够将“Servername”存储在某种类型的变量中,以便能够简化文件(如下所示):
define server_name = Servername<VirtualHost *:443> documentRoot /var/www/HTML/${server_name} Servername ${server_name} SSLEngine on SSLCertificatefile /var/www/ssl/${server_name}/certificate.crt SSLCertificateKeyfile /var/www/ssl/${server_name}/private.key SSLCACertificatefile /var/www/ssl/${server_name}/bundle.crt</VirtualHost>
我有什么方法可以做这样的事情吗?我环顾四周,找不到任何有助于此的解决方案,但我可能采取了错误的方法.
解决方法 尝试mod_macro
这是一个例子:
## define a VHost Macro for repetitive configurations<Macro VHost $host $port $dir> Listen $port <VirtualHost *:$port> Servername $host documentRoot $dir # Public document root <Directory $dir> Require all granted </Directory> # limit access to intranet subdir. <Directory $dir/intranet> Require ip 10.0.0.0/8 </Directory> </VirtualHost></Macro>## Use of VHost with different arguments.Use VHost www.apache.org 80 /vhosts/apache/htdocsUse VHost example.org 8080 /vhosts/example/htdocsUse VHost www.example.fr 1234 /vhosts/example.fr/htdocs总结
以上是内存溢出为你收集整理的linux – 使用ServerName作为httpd.conf文件中的变量全部内容,希望文章能够帮你解决linux – 使用ServerName作为httpd.conf文件中的变量所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)