Apache2.4.6 添加虚拟主机

apache2.4 与 apache2.2 的虚拟主机配置写法有所不同

apache2.2的写法:

<VirtualHost *:80>  
 ServerName domain.com  
 DocumentRoot "/home/www"  
 DirectoryIndex index.html index.php  
  
 <Directory "/home/www">  
  Options -Indexes +FollowSymlinks  
  AllowOverride All  
  Order deny,allow  
  Allow from all  
 </Directory>  
  
</VirtualHost> 

如果在2.4中使用以上写法就会出现apache AH01630: client denied by server configuration异常。

apache2.4中的写法为

<VirtualHost *:80>  
 ServerName domain.com  
 DocumentRoot "/home/www"  
 DirectoryIndex index.html index.php  
  
 <Directory "/home/www">  
  Options -Indexes +FollowSymlinks  
  AllowOverride All  
  Require all granted  
 </Directory>  
  
</VirtualHost> 

解决方法,apache2.4中需要将

Order deny,allow  
Allow from all  
Allow from host ip  

改为

Require all granted  
Require host ip

 注:yum安装的httpd,在/etc/httpd/conf.d/目录下添加vhosts.conf后重启即可。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
以下是在Apache 2.4.6上部署SSL证书的步骤: 1. 获取SSL证书文件 你可以从证书颁发机构(CA)或自行签名的证书中获取SSL证书文件。通常,这个文件包括以下内容: - 证书文件(.crt) - 私钥文件(.key) - 中间证书文件(.ca-bundle) 确保你拥有这些文件,并将它们保存在一个安全的地方。 2. 配置Apache 在配置文件中启用SSL模块。在CentOS中,配置文件通常位于`/etc/httpd/conf/httpd.conf`或`/etc/httpd/conf.d/ssl.conf`。在Ubuntu中,通常位于`/etc/apache2/sites-available/default-ssl.conf`。 在配置文件中找到以下语句,并启用它们: ``` LoadModule ssl_module modules/mod_ssl.so ``` 3. 配置虚拟主机 在配置文件中找到要启用SSL的虚拟主机,并添加以下配置: ``` <VirtualHost *:443> ServerName example.com ServerAlias www.example.com DocumentRoot /var/www/html SSLEngine on SSLCertificateFile /path/to/cert.pem SSLCertificateKeyFile /path/to/key.pem SSLCACertificateFile /path/to/ca-bundle.pem </VirtualHost> ``` 在这个示例中,`example.com`和`www.example.com`是你的网站域名,`/var/www/html`是你的网站根目录。`/path/to/cert.pem`是你的证书文件,`/path/to/key.pem`是你的私钥文件,`/path/to/ca-bundle.pem`是你的中间证书文件。 4. 重启Apache 完成上述步骤后,保存配置文件,并重新启动Apache: ``` sudo systemctl restart httpd.service # CentOS sudo systemctl restart apache2.service # Ubuntu ``` 现在你的网站应该已经启用了SSL证书。你可以在浏览器中输入你的网站地址来验证证书是否已正确部署。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值