centos7.1下yum安装并使用apache web服务器

一、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>
  • 1
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值