Linux系统下安装 apache2.4的过程
本以为linux下安装apache是件很简单的过程。三命令就可以搞定,jxvf解压,make 编译,make install 安装就OK了。没想到这个过程还颇费周折。可能和环境有关吧。先说一下我的环境。
---------------------------
linux : cenos5.5 (验证4.8也会碰到以下问题)
apache: httpd-2.4.1.tar.bz2
---------------------------
[root@localhost apache]# tar jxvf httpd-2.4.1.tar.bz2 //解压apache的压缩包
[root@localhost apache]# cd httpd-2.4.1 //定位到httpd-2.4.1 文件夹下
[root@localhost httpd-2.4.1]# ls //查看显示httpd-2.4.1 文件夹下内容
[root@localhost httpd-2.4.1]#./configure --help | more //查看安装apache配置参数
[root@localhost httpd-2.4.1]#./configure --prefix=/usr/local/apache --enable-so // 配置apache路径 ,后面跟 --enable-so 参数表示让apache核心装载DSO
[root@localhost httpd-2.4.1]# make //编译apache
出错了!提示:
configure: error: APR not found. Please read the documentation
在apache官网上可以下载到 apr-1.4.6.tar.gz
解决apr not found问题>>>>
APR和APR-UTIL的下载地址:http://apr.apache.org/download.cgi
[root@localhost apache]# tar -zxf apr-1.4.6.tar.gz
[root@localhost apache]# cd apr-1.4.6
[root@localhost apr-1.4.6]# ./configure --prefix=/usr/local/apr
[root@localhost apr-1.4.6]# make
[root@localhost apr-1.4.6]# make install
安装完成后,再来编译apache
[root@localhost httpd-2.4.1]# make
又出错了!提示:
configure: error: APR-util not found. Please read the documentation
好吧!还是上面的apache官网地址再下载 apr-util-1.4.1.tar.gz
解决APR-util not found问题>>>>
[root@localhost apache]# tar -zxf apr-util-1.4.1.tar.gz
[root@localhost apache]# cd apr-util-1.4.1
[root@localhost apr-util-1.4.1]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr/bin/apr-1-config
[root@localhost apr-util-1.4.1]# make
[root@localhost apr-util-1.4.1]# make install
再来编译apache ,再次出错!提示:
configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/ , 我X !linux 安装软件之间关联性有时能让人崩溃。
../configure仍提示APR-util not found,增加--with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util后出现>>>>>
[root@localhost apache]# ./configure –help | grep pcre
--with-pcre=PATH Use external PCRE library
下载地址:http://ftp.exim.llorien.org/pcre/
下载pcre-8.30.zip ,列表文件较多,一般浏览器会有搜索功能,你可ctrl+f 搜索定位后下载。
[root@localhost apache]#unzip -o pcre-8.30.zip
[root@localhost apache]#cd pcre-8.30
[root@localhost pcre-8.30]#./configure --prefix=/usr/local/pcre
[root@localhost pcre-8.30]#make
[root@localhost pcre-8.30]#make install
编译Apache
[root@yahoo httpd-2.3.12-beta]# ./configure --prefix=/usr/local/apache2 --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/
注意,这里后面跟的参数,一定要与前面安装apr 和apr-util的路径一致。
[root@localhost httpd-2.4.1]# make
[root@localhost httpd-2.4.1]# make install
这次编译安装应该不会再报任何错误了。哈哈!!
启动apache
[root@localhost bin]# pwd
/usr/local/apache/bin
[root@localhost bin]# apachectl stop 停止
[root@localhost bin]# apachectl start 启动
查看80端口是否被占用
[root@localhost conf]#netstat -an | grep :80
查看apache 启动服务是否启动
[root@localhost bin]# ps -aux | grep httpd
Warning: bad syntax, perhaps a bogus '-'? See /usr/share/doc/procps-3.2.7/FAQ
root 2866 0.0 1.2 25164 9556 ? Ss 22:45 0:00 /usr/sbin/httpd -k start
apache 2867 0.0 0.7 25300 5556 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2868 0.0 0.6 25300 5444 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2869 0.0 0.6 25300 5444 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2870 0.0 0.7 25300 5556 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2871 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2872 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2873 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
apache 2874 0.0 0.6 25164 4796 ? S 22:45 0:00 /usr/sbin/httpd -k start
root 3141 0.0 0.0 4244 676 pts/1 R+ 22:48 0:00 grep httpd