ubuntu 安装apache2 二进制包
官方安装教程 http://httpd.apache.org/docs/2.4/install.html
一.下载安装包
进入https://httpd.apache.org/download.cgi#apache24
下载 tar.gz包
wget https://mirrors.tuna.tsinghua.edu.cn/apache//httpd/httpd-2.4.39.tar.gz
二.安装
1.解压
tar -xzvf httpd-2.4.39.tar.gz mv httpd-2.4.39 httpd
正确的安装(这个是安装失败后的总)
wget http://us.mirrors.quenda.co/apache//apr/apr-1.7.0.tar.gz wget http://us.mirrors.quenda.co/apache//apr/apr-util-1.6.1.tar.gz
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
#解压后进入各自目录运行
cd /usr/local/httpd/srclib/apr
./configure
make
make install
cd /usr/local/httpd/srclib/apr-util
./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr
make
make install
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz
mv pcre httpd/srclib/pcre
./configure --prefix=/usr/local/pcre
make
make install
./configure -with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
2.安装
./configure --enable-rewrite=shared
错误解决参考:https://blog.csdn.net/zhtking120/article/details/9762315
报错1. APR not found. Please read the documentation.
sudo apt-get install libapr1-dev libaprutil1-dev
报错2. 还是报错
可能上一个问题没有解决: 进入这里 从Apache APR下载APR和APR-Util的最新版本,将它们解压缩到./srclib/apr和./srclib/apr-util(确保域名没有版本号;例如,APR分发必须在./srclib/apr/下
wget http://us.mirrors.quenda.co/apache//apr/apr-1.7.0.tar.gz wget http://us.mirrors.quenda.co/apache//apr/apr-util-1.6.1.tar.gz tar -xzvf apr-1.7.0.tar.gz tar -xzvf apr-util-1.6.1.tar.gz mkdir ./srclib apr-1.7.0 ./srclib/apr mv apr-util-1.6.1 ./srclib/apr-util cd /usr/local/httpd/srclib/apr ./configure make make install cd /usr/local/httpd/srclib/apr-util ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr make make install
又报错ubuntu xml/apr_xml.c:35:10: fatal error: expat.h:
apt-get install libexpat1-dev
报错3. no acceptable C compiler found in $PATH
apt-get install build-essential
报错4. configure: error: pcre-config for libpcre not found. PCRE is required and available from http://pcre.org/
wget https://ftp.pcre.org/pub/pcre/pcre-8.43.tar.gz mv pcre httpd/srclib/pcre ./configure --prefix=/usr/local/pcre make make install
继续编译
./configure -with-apr=/usr/local/apr/ --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcre
make
make install
中途如有乱七八糟的报错将上面安装的东西删除重新装一边
安装成功
三.启动测试
ln -s /usr/local/apache2/bin/apachectl /sbin/
apachectl start
报错1. AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0
解决方法:进入apache的安装目录 编辑httpd.conf文件,搜索"#ServerName",添加ServerName localhost:80
ServerName localhost:80 #亦可以用域名