环境:Ubuntu 16.0.4
Apache官网下载Apache httpd压缩包:httpd-2.4.27.tar.gz,安装之前请确定安装了make工具,我安装的是GNU make
解压文件
sudo tar -zxvf '/home/fanchao/桌面/share/apache http server/httpd-2.4.27.tar.gz' -C /etc/httpd
在解压后的文件目录下有个install文件,里面写着
For complete installation documentation, see [ht]docs/manual/install.html or
通过查看文档,安装所需要的环境 :
安装 APR(其实不用安装,后面说明):下载 apr-1.6.2.tar.gz
解压:
sudo tar -zxvf '/home/fanchao/桌面/share/apache http server/apr-1.6.2.tar.gz' -C /etc/httpd
编译和安装:
sudo
cd /etc/httpd/apr-1.6.2 #进入解压后的文件目录
sudo ./configure #这里可以添加参数 --prefix=你要安装的目录,我这里没有加,默认安装在/user/loacl目录下 以下所有的./configure都可以添加这个参数
sudo make
sudo make install
安装APR-UTIL(其实不用安装,后面说明):下载 apr-util-1.6.0.tar.gz
解压:
sudo tar -zxvf '/home/fanchao/ 桌面/share/apache http server/apr-util-1.6.0.tar.gz' -C /etc/httpd
编译和安装
cd /etc/httpd/apr-util-1.6.0 sudo ./configure --with-apr=/usr/local/apr/bin/apr-1-config sudo make
这里报错
xml/apr_xml.c:35:19: fatal error: expat.h: 没有那个文件或目录 compilation terminated. /etc/httpd/apr-util-1.6.0/build/rules.mk:206: recipe for target 'xml/apr_xml.lo' failed make[1]: *** [xml/apr_xml.lo] Error 1 make[1]: Leaving directory '/etc/httpd/apr-util-1.6.0' /etc/httpd/apr-util-1.6.0/build/rules.mk:118: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1
解决办法就是安装libexpat1-dev
sudo apt-get install libexpat1-dev
重新输
sudo make sudo make install
安装httpd所需要的prce库:下载prce-8.41.zip
解压:
sudo unzip '/home/fanchao/桌面/share/apache http server/pcre-8.41.zip' -d /etc/httpd
编译和安装:
cd /etc/httpd/pcre-8.41 sudo ./configure sudo make sudo make install
最后编译安装apache httpd
sudo ./configure --with-apr='/usr/local/apr/bin/apr-1-config' --with-apr-util='/usr/local/apr/bin/apu-1-config' --with-prce='/usr/local/bin/pcre-config' #这里还有其他参数可以配置,具体参照官方 sudo make sudo make install
到现在按照官方文档的说明应该就已经安装好了,但是我到make这步就报错了
collect2: error: ld returned 1 exit status Makefile:48: recipe for target 'htpasswd' failed make[2]: *** [htpasswd] Error 1 make[2]: Leaving directory '/etc/httpd-2.4.27/support' /etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed make[1]: *** [all-recursive] Error 1 make[1]: Leaving directory '/etc/httpd-2.4.27/support' /etc/httpd-2.4.27/build/rules.mk:75: recipe for target 'all-recursive' failed make: *** [all-recursive] Error 1