注意事项
- 如果需要通过Apache搭建Bugzilla或MediaWiki,请选择Apache 2.2.22版本,2.4版本无法兼容。详情可参考:(还没写)
安装准备
下载所需文件
- 下载Apache Protable Runtime (APR), 下载地址:http://apr.apache.org/download.cgi
- 下载Apache Protable Runtime Utility (APR-Util), 下载地址:http://apr.apache.org/download.cgi (和APR在同一个页面上下载)
- 下载Apache HTTP Server (Apache Httpd), 下载地址:http://httpd.apache.org/download.cgi
- 下载Perl-Compatible Regular Expressions Library (PCRE), 下载地址:http://pcre.org/
安装所需依赖
1
2
|
# 安装libtool
shell
>
yum
install
libtool
-
y
|
安装APR
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# 解压缩APR到任意目录
shell
>
tar
zxvf
apr
-
1.4.6
-
C
/
opt
/
sources
# 进入APR源码目录
shell
>
cd
/
opt
/
sources
/
apr
-
1.4.6
# 创建APR安装目录
shell
>
mkdir
/
usr
/
local
/
apr
# 配置安装APR
shell
>
.
/
configure
--
prefix
=
/
usr
/
local
/
apr
shell
>
make
shell
>
make
install
|
安装APR-Util
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# 解压缩APR-Util到任意目录
shell
>
tar
zxvf
apr
-
util
-
1.4.1
-
C
/
opt
/
sources
# 进入APR-Util源码目录
shell
>
cd
/
opt
/
sources
/
apr
-
util
-
1.4.1
# 创建APR-Util安装目录
shell
>
mkdir
/
usr
/
local
/
apr
-
util
# 配置安装APR-Util
shell
>
.
/
configure
--
prefix
=
/
usr
/
local
/
apr
-
util
--
with
-
apr
=
/
usr
/
local
/
apr
shell
>
make
shell
>
make
install
|
安装PCRE
1
2
3
4
5
6
7
8
9
10
11
12
13
|
# 解压缩PCRE到任意目录
shell
>
tar
zxvf
pcre
-
8.31
-
C
/
opt
/
sources
# 进入PCRE源码目录
shell
>
cd
/
opt
/
sources
/
pcre
-
8.31
# 创建PCRE安装目录
shell
>
mkdir
/
usr
/
local
/
pcre
# 配置安装PCRE
shell
>
.
/
configure
--
prefix
=
/
usr
/
local
/
pcre
shell
>
make
shell
>
make
install
|
安装Apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
# 解压缩Apache
shell
>
tar
zxvf
httpd
-
2.4.3.tar.gz
-
C
/
opt
/
sources
# 进入Apache源码目录
shell
>
cd
/
opt
/
sources
/
httpd
-
2.4.3
# 创建Apache安装目录及访问软链接
shell
>
mkdir
/
opt
/
software
/
develop
/
httpd
-
2.4.3
shell
>
ln
-
s
/
opt
/
software
/
develop
/
httpd
-
2.4.3
/
usr
/
local
/
apache2
# 配置安装Apache
# 由于Apache用处不同,此处应根据文档选择所需要的参数进行安装
# 此处笔者需要通过Apache搭建MediaWiki和Bugzilla,所以要支持PHP及Perl模块
# 对于PHP的配置请参见:
shell
>
.
/
configure
--
prefix
=
/
usr
/
local
/
apache2
--
enable
-
so
--
with
-
mpm
=
prefork
--
with
-
apr
=
/
usr
/
local
/
apr
--
with
-
apr
-
util
=
/
usr
/
local
/
apr
-
util
--
with
-
pcre
=
/
usr
/
local
/
pcre
# 如果没报pcre的错上面的的--with-pcre=/usr/local/pcre就可以不加上了
shell
>
make
shell
>
make
install
|
测试Apache
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
# 通过apachectl启动Apache
shell
>
/
usr
/
local
/
apache2
/
bin
/
apachectl
start
# 检查是否有Apache进程
shell
>
ps
aux
|
grep
apachectl
# 关闭Apache
shell
>
ps
aux
|
grep
apachectl
stop
# 创建Apache服务
shell
>
cp
/
usr
/
local
/
apache2
/
bin
/
apachectl
/
etc
/
init
.d
/
httpd
# 通过服务启动Apache
shell
>
service
httpd
start
# 通过服务关闭Apache
shell
>
service
httpd
stop
# 通过服务重起Apache
shell
>
service
httpd
restart
|
配置Apache
从Apache的文档来讲,其配置可以写成一本书了,在这里我一章一章的来写,其中内容大多参考Apache官方文档,如果读者英文能力足够,可以直接查看官方文档。
此外,也可参考Apache配置索引