您当前的位置: 首页 > 学无止境 > 网站建设 网站首页网站建设
redhat5.8搭建apache2.2与vhost多虚拟主机配置
发布时间:2018-12-15 17:46:49编辑:雪饮阅读()
apache安装:
解压httpd-2.2.22.tar.gz
进入解压后目录直接运行:
./configure --prefix=/usr/local/apache
make
make install
注意:如果是安装apache2.4的则还需要apr-util和pcre等的支持
vhost多虚拟主机配置
以配置两个虚拟主机为例,假定这两个虚拟主机分别是www.snowdrink.com和www.dmj.com
则:
cp -pr /usr/local/apache/htdocs /usr/local/apache/snowDrink
cp -pr /usr/local/apache/htdocs /usr/local/apache/dmj
然后分别修改/usr/local/apache/snowDrink/index.html与/usr/local/apache/htdocs /usr/local/apache/dmj中的显示内容,便于后面分别访问这两个站点时可以区分
然后解禁/usr/local/apache/conf中的这项配置
# Virtual hosts
Include conf/extra/httpd-vhosts.conf
接着配置/usr/local/apache/conf/extra/httpd-vhosts.conf如下:
[root@localhost extra]# cat httpd-vhosts.conf
#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.
#
# Use name-based virtual hosting.
#
NameVirtualHost *:80
#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host.example.com
DocumentRoot "/usr/local/apache/snowDrink"
ServerName www.snowdrink.com
ServerAlias www.dummy-host.example.com
ErrorLog "logs/dummy-host.example.com-error_log"
CustomLog "logs/dummy-host.example.com-access_log" common
<Directory "/usr/local/apache/snowDrink">
Allow from all
</Directory>
</VirtualHost>
<VirtualHost *:80>
ServerAdmin webmaster@dummy-host2.example.com
DocumentRoot "/usr/local/apache/dmj"
ServerName www.dmj.com
ErrorLog "logs/dummy-host2.example.com-error_log"
CustomLog "logs/dummy-host2.example.com-access_log" common
<Directory "/usr/local/apache/dmj">
Allow from all
</Directory>
</VirtualHost>
本地域名解析:
[root@localhost extra]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost www.dmj.com www.snowdrink.com
::1 localhost6.localdomain6 localhost6
服务重启:
/usr/local/apache/bin/apachectl restart
任务完成:
关键字词:redhat,apache,vhost
相关文章
- nginx-反向代理实现nginx+apache动静分离
- apache假死崩溃的解决
- 解决linux下Apache下403 Forbidden错误(apache-2.4)
- centos配置apache2.4.23+php5.3.29+apc3.1.13
- windows+apache+php+mysql环境下配置MP4视频流拖拽插
- RedhatEnterpriseLinux4-硬盘添加、分区、格式化、swa
- RedhatEnterpriseLinux4-搭建文件传输专用ftp服务器及
- RedhatEnterpriseLinux4-ssh的文件传输(linux之间)
- RedhatEnterpriseLinux4-ssh远程登录
- RedhatEnterpriseLinux4-telnet远程登录的配置