源代码编译安装Apache2

首先准备我们需要的软件及我所使用版本如下:
httpd-2.4.33.tar.gz(官网要求)
apr-1.6.3.tar.gz(官网要求)
apr-util-1.6.1.tar.gz(官网要求)
pcre-8.42.tar.gz(官网要求)
expat-2.1.0.tar.gz(非必须,用于解决apr-util make时出现的make[1]: * [xml/apr_xml.lo] Error 1)

1 解压httpd

tar -zxvf httpd-2.4.33.tar.gz

2 解压编译apr

tar -zxvf apr-1.6.3.tar.gz 
cd apr-1.6.3
#备份cp -rf apr-1.6.3 /httpd-安装路径根目录/srclib/apr
./configure --prefix=/httpd-安装路径根目录/srclib/apr
make
make install

3 解压apt-util (此文无需编译)

tar -zxvf apr-util-1.6.1.tar.gz
cd apr-util-1.6.1
#备份cp -rf apr-util-1.6.1 /httpd-安装路径根目录/srclib/apr-util
./configure --prefix=/httpd-安装路径根目录/srclib/apr-util --with-apr=/httpd-安装路径根目录/srclib/apr
make 
make install

4 编译安装pcre

tar -zxvf pcre-8.42.tar.gz
cd pcre-8.42
./configure --prefix=/httpd-安装路径根目录/srclib/pcre
make 
make install

5 编译httpd

cd /httpd-安装路径根目录
#prefix用于指定安装路径,这里为/usr/apache2
./configure --prefix=/usr/apache2 --with-includer-apr=/httpd-安装路径根目录/srclib/apr --with-includer-apr-util=/httpd-安装路径根目录/srclib/apr-util
make
make install

6 启动apache2

cd /usr/apache2
#修改ServerName
vim conf/httpd.conf
修改:ServerName localhost:80
#启动
cd ..
cd bin
./apachectl start
#访问网址:localhost 是否出现It works!字样,表示成功!

附:

(1)上述软件下载路径
https://download.csdn.net/download/u014271612/10334082
(2)apache2配置ssl
https://blog.csdn.net/u014271612/article/details/79854031

你可能感兴趣的:(Linux)