CentOS Apache 安装 配置 启动
下载Apache安装包httpd-2.4.23.tar.gz下载地址:http://apache.fayea.com/httpd/
Apache 安装要求
必须安装APR、APR-Util、PCRE,gcc-c++等包
编译命令:(除了指定Apache的安装目录外,还要安装apr、apr-util、pcre,并指定参数)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# tar -zxvf httpd-2.4.23.tar.gz
# cd httpd-2.4.23
# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
checking for chosen layout... Apache
checking for working mkdir -p... yes
checking for grep that handles long lines and -e... /usr/bin/grep
checking for egrep... /usr/bin/grep -E
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking target system type... x86_64-unknown-linux-gnu
configure:
configure: Configuring Apache Portable Runtime library...
configure:
checking for APR... configure: error: the --with-apr parameter is incorrect. It must specify an install prefix, a build directory, or an apr-config file.
#
在编译Apache时出现了问题
http://apr.apache.org/download.cgi下载apr-1.5.2.tar.gz、apr-util-1.5.4.tar.gz
http://www.pcre.org/ 官网
https://sourceforge.net/projects/pcre/files/pcre/选择pcre下载,不用pcre2
下载最新版本pcre-8.39.tar.gz
解决apr问题
1
2
3
4
5
# tar -zxvfapr-1.5.2.tar.gz
# cd apr-1.5.2/
# ./configure --prefix=/usr/local/apr
# make
# make install
解决APR-util问题
1
2
3
4
5
# tar -zxvf apr-util-1.5.4.tar.gz
# cd apr-util-1.5.4/
# ./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config
# make
# make install
解决pcre-config问题
1
2
3
4
5
# tar -zxvf pcre-8.39.tar.gz
# cd pcre-8.39
# ./configure --prefix=/usr/local/pcre
# make
# make install
再次编译httpd-2.4.23:
1
2
3
4
# cd httpd-2.4.23
# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
# make
# make install
启动Apache:/usr/local/apache2/bin/apachectl start
停止Apache:/usr/local/apache2/bin/apachectl stop
重启Apache:/usr/local/apache2/bin/apachectl restart
网站放在/usr/local/apache2/htdocs目录下
在IE中通过http://localhost:80,如果看到页面中显示“It works!”字样,则代表Apache验证通过。如果网站的index后缀是PHP格式的,则要修改httpd.conf配置文件(/usr/local/apache2/conf),在DirectoryIndex增加 index.php。
1
2
3
4
5
6
7
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
DirectoryIndex index.html index.php
</IfModule>
页:
[1]