1.下载apache服务器软件 ,这里使用的是2.2.25版本
http://mirrors.hust.edu.cn/apache//httpd/httpd-2.2.25.tar.gz
2.解压压缩包
tar -xvf httpd-2.2.25.tar.gz
这里我们解压到/home/kevin/software/httpd-2.2.25目录
3.到解压目录下执行命令
[root@www httpd-2.2.25]# ./configure
如果你是第一次安装,应该得到如下的安装提示错误信息:
[root@www httpd-2.2.25]# ./configure checking for chosen layout... Apache checking for working mkdir -p... yes 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 Configuring Apache Portable Runtime library ... checking for APR... yes setting CC to "gcc" setting CPP to "gcc -E" setting CFLAGS to " -g -O2 -pthread" setting CPPFLAGS to " -DLINUX -D_REENTRANT -D_GNU_SOURCE" setting LDFLAGS to " " Configuring Apache Portable Runtime Utility library... checking for APR-util... reconfig configure: error: Cannot use an external APR with the bundled APR-util [root@www httpd-2.2.25]#
按照安装的说明,这两个软件包已经包含在下载后的apache软件包中了,我们查看解压后的/home/kevin/software/httpd-2.2.25/srclib下有3个文件夹
apr,apr-util,pcre
[root@www httpd-2.2.25]# ./configure --with-included-apr --enable-proxy
然后安装pcre(以下命令均切换到root帐号执行)
命令行切换到/home/kevin/software/httpd-2.2.25/srclib/pcre目录
[root@www pcre]# ./configure
[root@www pcre]# make
[root@www pcre]# make install
执行完毕后在命令行依次执行如下命令
[root@www httpd-2.2.25]# make
[root@www httpd-2.2.25]# make install
4.启动apache服务
切换到安装后的apache所在目录
[root@www bin]# cd /usr/local/apache2/bin
运行:
[root@www bin]# ./apachectl start
5.测试启动情况
浏览器输入localhost,如果出现成功展示页面表示启动成功