编译安装Apache
环境:Ubuntu 16.04 LTS , root身份
apache手册:http://httpd.apache.org/docs/current/install.html
在安装apache之前,需要先安装APR、APR-util、PCRE
另外Ubuntu需要安装libexpat1-dev,CentOS和RHEL需要安装expat-devel
软件下载地址:
apr:http://mirrors.hust.edu.cn/apache/apr/
apr-util:http://mirrors.hust.edu.cn/apache/apr/
PCRE:https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz
apache:http://mirrors.hust.edu.cn/apache//httpd
安装PCRE
wget https://ftp.pcre.org/pub/pcre/pcre-8.42.tar.gz tar -zxf pcre-8.42.tar.gz mv pcre-8.42 pcre cd pcre ./configure --prefix=/usr/local/pcre make make install
安装Apache
因为是Ubuntu环境,那么需要安装libexpat1-dev,可以直接执行apt-get install libexpat1-dev即可。
apt-get install libexpat1-dev
下载apr、apr-util、httpd的二进制包。
然后解压三个压缩包,将apr和apr-util拷贝到http的srclib目录中。
#下载文件apr、apt-util、httpd源码 #解压 tar zxf httpd-2.4.34.tar.gz tar -zxf apr-1.6.3.tar.gz tar -zxf apr-util-1.6.1.tar.gz #将apr和apr-util拷贝到httpd的srclib目录下 cp -r apr-1.6.3 httpd-2.4.34/srclib/apr cp -r apr-util-1.6.1 httpd-2.4.34/srclib/apr-util #进入apache源码目录 cd httpd-2.4.34 #编译并安装 ./configure --prefix=/usr/local/apache2 --with-pcre=/usr/local/pcre make -j 3 && make install
最好执行pcre的路径,否则在make的时候,系统可能找不到pcre库
测试
尝试启动apache
-> # /usr/local/apache2/bin/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to suppress this message
上面的报错是因为配置文件(/usr/local/apache2/conf/httpd.conf)中,ServerName设置有问题,
修改ServerName项为localhost,然后在尝试重启apache
-> # #修改apache配置文件ServerName项 -> # vi /usr/local/apache2/conf/httpd.conf -> # -> # #重启apache -> # /usr/local/apache2/bin/apachectl restart
浏览器访问:localhost
如需转载,请注明文章出处,谢谢!!!