日期:2014-05-16  浏览次数:20625 次

linux下apache的安装

一、下载

apache:http://httpd.apache.org/download.cgi

apache编译时依赖如下包,下载最新版即可:

apr&&apr-util:http://apr.apache.org/download.cgi

pcre:http://jaist.dl.sourceforge.net/project/pcre/pcre

?

二、安装

apr

?

tar -zxvf apr-1.4.x.tar.gz  
cd  apr-1.4.x  
./configure --prefix=/usr/local/apr  
make && make install  

?apr-util

?

?

tar -zxvf apr-util-1.3.xx.tar.gz  
cd apr-util-1.3.xx  
./configure --prefix=/usr/local/apr-util -with-apr=/usr/local/apr/bin/apr-1-config  
make && make install 

?pcre

?

?

tar -zxvf pcre-8.xx.tar.gz  
cd pcre-8.x  
./configure --prefix=/usr/local/pcre  
make && make install

?安装pcre是可能会遇到如下问题:

./configure --prefix=/usr/local/pcre  出现以下错误
configure: error: You need a C++ compiler for C++ support

解决方法:yum install -y gcc gcc-c++?

或者下载安装最新版本:http://gcc.gnu.org/

tar zxvf gcc-4.1.x.tar.gz
cd gcc-4.1.x
./configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --enable-checking=release --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-libgcj-multifile --enable-languages=c,c++,objc,obj-c++,java,fortran,ada --enable-java-awt=gtk --disable-dssi --disable-plugin --with-java-home=/usr/lib/jvm/java-1.4.2-gcj-1.4.2.0/jre --with-cpu=generic --host=x86_64-redhat-linux
make && make install

?

?

apache

tar -zxcf httpd-2.4.x.tar.gz 
cd httpd-2.4.x
./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --with-pcre=/usr/local/pcre
make && make install

?

?三、测试

cp /usr/local/apache/bin/apachectl /etc/rc.d/init.d/apache
#启动
service apache start
#停止
service apache stop

?启动后访问 http://apache.server.name

显示

It works!

?

查看端口:netstat -an | grep :80

查看进程:ps -aux | grep httpd

查看apache编译参数:cat /usr/local/apache/build/config.nice

?