阿里云-云小站(无限量代金券发放中)
【腾讯云】云服务器、云数据库、COS、CDN、短信等热卖云产品特惠抢购

CentOS 7安装配置Apache HTTP Server

105次阅读
没有评论

共计 2426 个字符,预计需要花费 7 分钟才能阅读完成。

CentOS 7 下 Apache HTTP Server 安装配置。

RPM 安装 httpd

# yum -yinstall httpd
// 安装 httpd 会自动安装一下依赖包:
apr
apr-util
httpd-tools
mailcap
# rpm -qi httpd
Name      : httpd
Version    : 2.4.6
Release    : 18.el7.centos
Architecture: x86_64
Install Date: Mon 11 Aug 2014 02:44:55 PMCST
Group      : System Environment/Daemons
Size      : 9793373
License    : ASL 2.0
Signature  : RSA/SHA256, Wed 23 Jul 2014 11:21:22 PM CST, Key ID 24c6a8a7f4a80eb5
Source RPM : httpd-2.4.6-18.el7.centos.src.rpm
Build Date : Wed 23 Jul 2014 10:49:10 PM CST
Build Host : worker1.bsys.centos.org
Relocations : (not relocatable)
Packager  : CentOS BuildSystem <http://bugs.centos.org>
Vendor    : CentOS
URL        : http://httpd.apache.org/
Summary    : Apache HTTP Server
Description :
The Apache HTTP Server is a powerful,efficient, and extensible web server.

修改配置文件

# cd
/etc/httpd/conf
# ls
httpd.conf
magic
#cp httpd.conf httpd.conf.origin    // 将原有配置文件备份
# more httpd.conf
// 查看配置文件, 我们注意到以一配置:
DocumentRoot”/var/www/html”
 
// 特别是要注意这个配置
// 这是 Apache 2.4 的一个新的默认值,拒绝所有的请求!
 
<Directory />
  AllowOverride none
    Require all denied
</Directory>
 
// 设置为自动启动
# systemctl enable httpd.service
ln -s’/usr/lib/systemd/system/httpd.service’ ‘/etc/systemd/system/multi-user.target.wants/httpd.service’
// 在 centos7 中 chkconfig httpd on 被替换成 systemctl enable httpd

配置 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>

————————————– 分割线 ————————————–

Ubuntu 13.04 安装 LAMP\Vsftpd\Webmin\phpMyAdmin 服务及设置 http://www.linuxidc.com/Linux/2013-06/86250.htm

CentOS 5.9 下编译安装 LAMP(Apache 2.2.44+MySQL 5.6.10+PHP 5.4.12) http://www.linuxidc.com/Linux/2013-03/80333p3.htm

RedHat 5.4 下 Web 服务器架构之源码构建 LAMP 环境及应用 PHPWind http://www.linuxidc.com/Linux/2012-10/72484p2.htm

LAMP 源码环境搭建 WEB 服务器 Linux+Apache+MySQL+PHP http://www.linuxidc.com/Linux/2013-05/84882.htm

LAMP+Xcache 环境搭建 http://www.linuxidc.com/Linux/2014-05/101087.htm

————————————– 分割线 ————————————–

更多 CentOS 相关信息见 CentOS 专题页面 http://www.linuxidc.com/topicnews.aspx?tid=14

正文完
星哥说事-微信公众号
post-qrcode
 0
星锅
版权声明:本站原创文章,由 星锅 于2022-01-20发表,共计2426字。
转载说明:除特殊说明外本站文章皆由CC-4.0协议发布,转载请注明出处。
【腾讯云】推广者专属福利,新客户无门槛领取总价值高达2860元代金券,每种代金券限量500张,先到先得。
阿里云-最新活动爆款每日限量供应
评论(没有评论)
验证码
【腾讯云】云服务器、云数据库、COS、CDN、短信等云产品特惠热卖中