服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - 详解CentOS7安装配置Apache HTTP Server

详解CentOS7安装配置Apache HTTP Server

2021-12-22 16:40李豪leaus Centos

本篇文章主要介绍了CentOS7安装配置Apache HTTP Server,具有一定的参考价值,有兴趣的可以了解一下。

RPM安装httpd

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# 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.

修改配置文件

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# 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目录下的文档)

?
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
//创建两个网站的目录结构及测试用页面文件
 
# mkdir/wwwroot/www
 
# echo"www.bigcloud.local" > /wwwroot/www/index.html
 
# mkdir/wwwroot/crm
 
# echo"crm.bigcloud.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.bigcloud.local
 
 DocumentRoot /wwwroot/www/
 
</VirtualHost>
 
<Directory /wwwroot/www/>
 
  Requireall granted
 
</Directory>
 
 
 
<VirtualHost *:80>
 
  ServerNamecrm.bigcloud.local
 
 DocumentRoot /wwwroot/crm/
 
</VirtualHost>
 
<Directory /wwwroot/crm/>
 
  Require ip192.168.188.0/24  //可以设置访问限制
 
</Directory>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持服务器之家。

原文链接:http://leaus.blog.51cto.com/9273485/1540717

延伸 · 阅读

精彩推荐
  • CentosCentOS下Uptime命令详解

    CentOS下Uptime命令详解

    在Linux下,我们可以使用uptime命令,而且此命令不必使用root权限。uptime命令在系统中已经默认安装了。今天小编为大家带来的是CentOS下Uptime命令详解;希望...

    CentOS之家11482019-06-19
  • CentosCentOS 6.6实现永久修改DNS地址的方法

    CentOS 6.6实现永久修改DNS地址的方法

    这篇文章主要介绍了CentOS 6.6实现永久修改DNS地址的方法,涉及针对CentOS配置文件的相关设置技巧,具有一定参考借鉴价值,需要的朋友可以参考下 ...

    Linux社区4472020-08-21
  • CentosCentOS6.5下Redis安装与配置详细步骤

    CentOS6.5下Redis安装与配置详细步骤

    本篇文章主要介绍了CentOS6.5下Redis安装与配置详细步骤,详细介绍redis单机单实例安装与配置,服务及开机自启动。有兴趣的可以了解一下。...

    飞流11452021-12-24
  • Centoscentos 安装与操作方法

    centos 安装与操作方法

    这篇文章主要介绍了centos 安装与操作方法,需要的朋友可以参考下...

    centos之家5272019-07-11
  • Centoscentos不小心删除/root目录该如何解决?

    centos不小心删除/root目录该如何解决?

    一些朋友最近在问小编centos不小心删除/root目录该如何解决?今天小编就为大家分享centos不小心删除/root目录解决办法;希望对大家会有帮助,有需要的朋友...

    脚本之家8022019-05-29
  • CentosCentos 7开启网卡自动获取IP的详细方法

    Centos 7开启网卡自动获取IP的详细方法

    本篇文章主要介绍了Centos 7开启网卡自动获取IP的详细方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    凌锋8972021-12-29
  • CentosCentos7运用/dev/shm进行网站优化

    Centos7运用/dev/shm进行网站优化

    这篇文章主要介绍了LINUX中Centos7运用/dev/shm进行网站优化相关知识点,对此有兴趣的朋友参考学习下。...

    彬菌9912022-03-02
  • CentosCentOS7设置日期和时间方法以及基本概念介绍

    CentOS7设置日期和时间方法以及基本概念介绍

    这篇文章主要介绍了CentOS7设置日期和时间方法以及基本概念介绍,本文讲解使用CentOS7中的新命令timedatectl设置日期时间方法,需要的朋友可以参考下 ...

    CentOS之家6522019-09-19