版本:Apache/2.4.41
参考:https://amon.org/apache-compile
参考:https://amon.org/apr
参考:https://www.dadcomputerclub.com/ubuntu-14-04-3-apache-http-2-web-server-setup/
【依赖】
相关依赖包 :
apt-get install openssl libssl-dev libpcre3 libpcre3-dev zlib1g-dev libxml2 libxml2-dev bison -y
编译安装nghttp2:
参考:https://amon.org/nghttp2-ubuntu
依赖:
sudo apt-get install libcunit1 libcunit1-dev libc-ares-dev libevent-dev libjansson-dev libjemalloc-dev libsystemd-dev libev-dev
编译:
git clone https://github.com/tatsuhiro-t/nghttp2.git && cd nghttp2 && autoreconf -i && automake && autoconf && ./configure && make && sudo make install
编译安装 apr + apr-util :
依赖:
apt-get install libexpat1-dev
编译:
wget http://archive.apache.org/dist/apr/apr-1.6.3.tar.bz2 && tar -xjvf apr-1.6.3.tar.bz2 && cd apr-1.6.3 && ./configure --prefix=/usr --disable-static --with-installbuilddir=/usr/share/apr-1/build && make && make install wget http://archive.apache.org/dist/apr/apr-util-1.6.1.tar.bz2 && tar -xjvf apr-util-1.6.1.tar.bz2 && cd apr-util-1.6.1 && ./configure --prefix=/usr --with-apr=/usr --with-gdbm=/usr --with-openssl=/usr --with-crypto && make && make install
【安装】
参考:https://amon.org/apache-compile
下载:http://httpd.apache.org/download.cgi
wget http://www-us.apache.org/dist/httpd/httpd-2.4.43.tar.gz && tar -zxvf httpd-2.4.43.tar.gz && cd httpd-2.4.43 ./configure --prefix=/usr/local/apache2 --enable-mods-shared=most --with-crypto --enable-rewrite --enable-headers --enable-deflate --enable-socache-shmcb --enable-negotiation --enable-ssl --with-ssl=/usr/lib --with-apr=/usr/bin/apr-1-config --with-apr-util=/usr/bin/apu-1-config --enable-http2 --with-nghttp2=/usr/local/lib make -j4 && make install
查看版本:
/usr/local/apache2/bin/httpd -v
输出:
Server version: Apache/2.4.43 (Unix) Server built: Jun 21 2020 04:31:40
【配置】
创建 apache 用户:
groupadd apache && useradd -g apache -s /sbin/nologin -M apache
授予 apache 用户执行权限:
chown -R apache:apache /usr/local/apache2/htdocs
设置启动命令:
将 apachectl 拷贝:
cp /usr/local/apache2/bin/apachectl /etc/init.d/httpd sudo update-rc.d -f httpd defaults
启动:
service httpd start
在浏览器中打开 IP :
It works!