Linux下源码安装软件

本文详细介绍了从零开始编译安装nginx的过程,包括检查与准备编译环境、解决依赖问题如gcc、pcre及openssl的安装,以及最终的编译、安装与启动步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

自己编译安装软件,需要经历以下步骤:
检查编译环境——>准备编译环境(需要依赖很多的第三方软件)——>编译——>安装——>使用

  • 配置文件:Makefile
  • 编译,安装命令:make
    编译安装,现在有个名词,叫模块化。模块越多,代码越多,bug也就越多。
    下面会以编译安装nginx的案例来说明!

编译安装nginx

下载源码
首先需要我们把tomcat、jdk、nginx三个压缩安装包通过xftp传送至节点。

解压
执行以下命令,得到tengine源码(x撕毁,f文件)

tar   xf   tengine-2.1.0.tar.gz

进入到源码目录:

cd  tengine-2.1.0

查看README
进入README,执行 /install命令查看相关安装命令。打开configure里面有安装提示,configure一般支持 configure --help
./configure:创建Makefile
这里开始尝试执行 ./configure命令,会有一些提示信息:

[root@node1 tengine-2.1.0]# ./configure
checking for OS
 + Linux 2.6.32-642.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found

安装gcc:

yum install -y gcc

经过短暂的等待,安装好了gcc。重新执行命令 ./configure,还是会有提示信息:

//省略了N多行......
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.

缺少pcre,可以通过yum来搜索pcre:

yum search pcre

安装确实的pcre,执行以下命令,并在提示中给出y的指令:

yum  install  pcre-devel

再次执行./configure命令,提示还缺少东西:

//省略了N行...
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.

根据刚才pcre的经验,我直接安装openssl-devel,并给出指令y:

yum  install openssl-devel

一切就绪后,重新执行./configure !
接下来编译:

make

执行make install新建目录、文件夹、拷贝目录:

make install

历经艰难,终于安装好了:
在这里插入图片描述
去到nginx目录下,看到有个sbin目录,sbin下还有个nginx:
在这里插入图片描述
最后,我们执行 ./nginx 启动外部server检验(80端口不写也行):
在这里插入图片描述

最后

尽量不要使用编译安装,太麻烦了…

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值