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后重启即可。

时间: 2024-08-09 10:38:55

Apache2.4.6 添加虚拟主机的相关文章

Apache2.4.6添加虚拟主机提示:NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/extra/httpd-vhosts.conf

[[email protected] conf]# service httpd restart 停止 httpd: [确定] 启动 httpd:AH00548: NameVirtualHost has no effect and will be removed in the next release /usr/local/apache/conf/extra/httpd-vhosts.conf:1 文件 /usr/local/apache/conf/extra/httpd-vhosts.conf

apache 如何添加虚拟主机?

apache添加虚拟主机很简单,修改配置文件:httpd.conf文件 一.分别去掉下面两行文字前面的#号. #LoadModule vhost_alias_module modules/mod_vhost_alias.so 去掉#意思是启用apache的虚拟主机功能. #Include conf/extra/httpd-vhosts.conf 去掉这一行的#意思是从conf/extra/httpd-vhosts.conf这个文件导入虚拟主机配置 二.打开该文件,看到以下类似内容.虚拟主机的配置

apache添加虚拟主机配置+本地hosts绑定域名

1.本地hosts 什么是本地hosts?我们知道访问一个域名,通过dns服务器得到该域名所指向的服务器ip地址,然后通过ip地址和服务器建立连接,完成剩下的事情.那么当开发过程中我们没有域名的时候如何才能模拟一个域名呢?答案就是hosts文件,一般开发环境都是在win下,所以这里就以win为例,玩linux的相信自己都能摸索到. 我们找到c:\windows\system32\drivers\etc\hosts文件,用记事本打开它,在末尾添加一行: 127.0.0.1 www.xxx.com

centos7 安装 iRedmail 后 给nginx添加虚拟主机

iRedmail安装参考官方文档和 https://ywnz.com/linuxyffq/4563.html 准备工作 更新操作系统 yum update -y 安装必要组件 yum install perl perl-core ntpl nmap sudo libidn gmp libaio libstdc++ unzip sysstat wget nc -y 停止任何安装在该Centos7 Server上面的 MTA服务 systemctl stop postfix systemctl di

ubuntu4.04服务器添加虚拟主机

buntu 14.04配置虚拟主机 虚拟主机常用于在一个单独的IP地址上提供多个域名的网站服务.如果有人想在单个VPS的单个IP地址运行多个网站,这是非常有用的.在这个教程中,让我告诉你如何设置在Ubuntu 14.04 LTS的Apache网页服务器设置虚拟主机.请注意,这个教程只针对Ubuntu14.04的32位版本. 我不保证它也可以工作在其它更低的Ubuntu版本或者Ubuntu衍生版本(虽然可能过程是类似的). 方案 在这个教程中,我会使用Ubuntu 14.04 32位 LTS,并搭

Linux系统下Apache2.4.6配置虚拟主机

实验环境:一台Linux虚拟机:CentOS 7.6,Apache 2.4.6,IP地址为192.168.80.100:一台客户端:Windows XP,IP地址为192.168.80.200.虚拟主机:即可以在一台web服务器上运行多个网站.实现方法有3种:1.基于IP地址的虚拟主机,一台web服务器配置多个IP地址,一个IP地址对应一个网站.2.基于端口的虚拟主机,一台web服务器只用一个IP地址提供web服务,开放多个端口,客户端访问web服务器时,需要在网址的后边加上相应的端口号.3.基

apache2.4.27配置虚拟主机

1:在httpd.conf中,把这行打开 Include conf/extra/httpd-vhosts.conf 2:进到conf/extra/里,修改httpd-vhosts.conf 原文件是这样的 <VirtualHost *:80> ServerAdmin [email protected] (邮箱) DocumentRoot "/web/www1" (发布目录) ServerName www.luo.com (域名) ServerAlias www.luo2.c

apache-2.4.12之虚拟主机配置问题与觖决办法

apache-2.4.12基于域名访问的多虚拟主机配置 原始配置: <VirtualHost *:80> ServerAdmin [email protected] DocumentRoot "/data/cms" ServerName www.etiantian.org ServerAlias etiantian.org ErrorLog "logs/www.etiantian.org-error_log" CustomLog "logs/w

httpd添加虚拟主机

有三种实现方法: 基于ip: 为每个虚拟主机准备至少一个ip地址 基于port: 为每个虚拟机准备至少一个专用port        基于hostname: 为每个虚拟主机准备至少一个专用hostname 可混合使用上述三种方式 注意: 一般虚拟机不要和中心主机一起使用,所以,要使用虚拟主机,先禁用中心主机 示例1,基于ip: ip addr add 192.168.1.111/24 dev eth0 ip addr add 192.168.1.121/24 dev eth0       //增