科技常识:Ubuntu 16.04源码编译安装Apache 2.4.25教程

2021-04-09 09:38:14
导读 今天小编跟大家讲解下有关科技常识:Ubuntu 16 04源码编译安装Apache 2 4 25教程,相信小伙伴们对这个话题应该也很关注吧,小编也收集到

今天小编跟大家讲解下有关科技常识:Ubuntu 16.04源码编译安装Apache 2.4.25教程,相信小伙伴们对这个话题应该也很关注吧,小编也收集到了有关科技常识:Ubuntu 16.04源码编译安装Apache 2.4.25教程的相关资料,希望小伙伴会喜欢也能够帮助大家。

本文为大家介绍了Ubuntu 16.04源码编译安装Apache,供大家参考,具体内容如下

apache 安装指南:http://httpd.apache.org/docs/2.4/install.html

安装指南上面有详细的安装过程,这里我只说些注意事项:

1.编译安装apache有些依赖环境必须安装,不然后面编译会报找不到相应多文件:

APR(Apache portable Run-time libraries,Apache可移植运行库)和APR-Util,apr介绍可以参见:http://www.cnblogs.com/iLumia/p/4214886.html 下载地址:http://apr.apache.org/

PCRE库 如果没有安装过pcre的话,请先下载:http://www.pcre.org 除此之外,还有些磁盘空间要求,C编译器,时间同步,Perl5 可以根据需要,自行调整即可。

2.接下来是详细安装步骤: 这里我习惯把源码放在/usr/local/src下面,根据自己习惯切换目录。

1).安装apr-1.5.2切换到apr的源码目录

cd /usr/local/src/apr-1.5.2/

安装及编译

./configure --prefix=/usr/local/apache/aprmake -j4(根据自己电脑核数×2来设定并行编译参数,提高编译速度)sudo make install

2).安装apr-util-1.5.4

切换到apr-util的源码目录

cd /usr/local/src/apr-util-1.5.4/

安装及编译

./configure --prefix=/usr/local/apache/apr-util --with-apr=/usr/local/apache/aprmake -j4make install

3).安装pcre-8.39

进入安装目录

cd /usr/local/src/pcre-8.39/

安装及编译

./configure --prefix=/usr/local/pcremake -j4make install

4.安装完依赖就可以安装apache了 进入apache源码目录

cd /usr/local/src/httpd-2.4.25/

安装及编译

需要用Cwith参数指定我们刚才安装的依赖包位置

./configure --prefix=/usr/local/apache --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util/ --with-pcre=/usr/local/pcremake -j4make install

到此,就完成了apache的源码安装,接下来我们为apache服务 添加启动脚本:

cp /usr/local/apache/bin/apachectl /etc/init.d/httpd

添加环境变量:

echo 'export PATH=$PATH:/usr/local/apache/bin' > /etc/profile.d/httpd.shchmod a+x /etc/profile.d/httpd.shsource /etc/profile.d/httpd.sh

之后就可以多种方式管理httpd了,如果需要开机自启,将启动命令添加到/etc/rc.local 中即可。

sudo /usr/local/apache/bin/apachectl start

可能会报错说端口被占用,需要修改httpd.conf文件

sudo gedit /usr/local/apache/httpd/conf/httpd.conf

然后把ServerName行改成ServerName 127.0.0.1:80

把Listen 80行改成Listen 127.0.0.1:80

然后保存,启动apache服务.

service httpd start

注意: 如果启动服务时,报配置文件找不到,一种方法是,复制一份配置文件到相应路径, 或者你启动apache时,加-f 参数,指明配置文件绝对路径。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持爱蒂网。

来源:爱蒂网

免责声明:本文由用户上传,如有侵权请联系删除!

猜你喜欢

最新文章