一、centos7.1下yum安装apache web服务器
首先安装Apache,查看系统是否安装httpd和apr、apr-util并卸载
#rpm -qa|grep apr
apr-util-1.5.2-6.el7.x86_64
apr-1.4.8-3.el7.x86_64
#rpm -e --nodeps --allmatches apr-util-1.5.2-6.el7
#rpm -e --nodeps --allmatches apr-1.4.8-3.el7
#rpm -qa httpd
httpd-2.4.6-31.el7.centos.x86_64
# rpm -e --nodeps --allmatches httpd-2.4.6-31.el7.centos
重新安装httpd和apr、apr-util
#yum install httpd apr apr-util
Apache扩展模块
#yum install httpd-manual mod_ssl mod_perl mod_auth_mysql
二、centos7.1下配置并使用apache web服务器
//设置为自动启动
# systemctl enable httpd.service
(1)简单的配置使用
apache web服务器默认使用/var/www/html目录,我们在该目录下为自己设置好的文件目录做一个软链接
ln -s */repo /var/www/html/
这样 访问 http://x.x.x.x/repo便可访问我们的文件了
(2)较复杂的配置
配置WEB站点 (假设使用/wwwroot目录下的文档)
//创建两个网站的目录结构及测试用页面文件
# mkdir/wwwroot/www
# echo"www.linuxidc.local" > /wwwroot/www/index.html
# mkdir/wwwroot/crm
# echo"crm.linuxidc.local" > /wwwroot/crm/index.html
//配置虚拟机主机
# cd/etc/httpd/
# mkdirvhost-conf.d
# echo"Include vhost-conf.d/*.conf" >> conf/httpd.conf
# vi/etc/httpd/vhost-conf.d/vhost-name.conf
//添加如下内容
<VirtualHost *:80>
ServerNamewww.linuxidc.local
DocumentRoot /wwwroot/www/
</VirtualHost>
<Directory /wwwroot/www/>
Requireall granted
</Directory>
<VirtualHost *:80>
ServerNamecrm.linuxidc.local
DocumentRoot /wwwroot/crm/
</VirtualHost>
<Directory /wwwroot/crm/>
Require ip192.168.188.0/24 //可以设置访问限制
</Directory>
首先安装Apache,查看系统是否安装httpd和apr、apr-util并卸载
#rpm -qa|grep apr
apr-util-1.5.2-6.el7.x86_64
apr-1.4.8-3.el7.x86_64
#rpm -e --nodeps --allmatches apr-util-1.5.2-6.el7
#rpm -e --nodeps --allmatches apr-1.4.8-3.el7
#rpm -qa httpd
httpd-2.4.6-31.el7.centos.x86_64
# rpm -e --nodeps --allmatches httpd-2.4.6-31.el7.centos
重新安装httpd和apr、apr-util
#yum install httpd apr apr-util
Apache扩展模块
#yum install httpd-manual mod_ssl mod_perl mod_auth_mysql
二、centos7.1下配置并使用apache web服务器
//设置为自动启动
# systemctl enable httpd.service
(1)简单的配置使用
apache web服务器默认使用/var/www/html目录,我们在该目录下为自己设置好的文件目录做一个软链接
ln -s */repo /var/www/html/
这样 访问 http://x.x.x.x/repo便可访问我们的文件了
(2)较复杂的配置
配置WEB站点 (假设使用/wwwroot目录下的文档)
//创建两个网站的目录结构及测试用页面文件
# mkdir/wwwroot/www
# echo"www.linuxidc.local" > /wwwroot/www/index.html
# mkdir/wwwroot/crm
# echo"crm.linuxidc.local" > /wwwroot/crm/index.html
//配置虚拟机主机
# cd/etc/httpd/
# mkdirvhost-conf.d
# echo"Include vhost-conf.d/*.conf" >> conf/httpd.conf
# vi/etc/httpd/vhost-conf.d/vhost-name.conf
//添加如下内容
<VirtualHost *:80>
ServerNamewww.linuxidc.local
DocumentRoot /wwwroot/www/
</VirtualHost>
<Directory /wwwroot/www/>
Requireall granted
</Directory>
<VirtualHost *:80>
ServerNamecrm.linuxidc.local
DocumentRoot /wwwroot/crm/
</VirtualHost>
<Directory /wwwroot/crm/>
Require ip192.168.188.0/24 //可以设置访问限制
</Directory>