linux命令:编译安装软件包(举例安装tengine nginx)

简介:

 编译安装的步骤:

   1、下载源码包

   2、解压缩下载的源码包

   3、进入解压缩目录    *必须进入到解压缩目录中

   4、./configure 软件配置与检查

      1)定义需要的功能选项

      2)检测系统环境是否符合安装要求

      3)把定义好的功能选项和检测系统环境的信息都写入makefile文件,用于后续的编辑。

      4)make编译  4.1)make clean清空编译文件

      5)make install 编译安装

   步骤:./configure --prefix=/usr/local/squid   --prefix指定软件安装位置

        --sysconfdir=/PATH/TO/CONFFILE_PATH  --sysconfdir指定配置文件路径

        --config-path=/PATH/TO/CONFFILE_PATH  指定配置文件路径

        --help 获取配置帮助文件

       make  编译    如有报错,执行make clean 删除编译临时文件         

       make install 编译安装

 Usage: 编译安装squid    

    1、首先现在squid源码包

    2、解压下载的源码包

    3、进入源码包的解压缩目录

    4、./configure --prefix=/usr/local/squid  指定安装路径

    5、make 编译生成makefile文件   6、make install 编译安装完成 

编译安装完成后必须注意的几个问题:

注:

  1、修改PATH环境变量,以便能够识别此程序的二进制文件路径即把程序的执行程序的路径加入到PATH变量中 在/etc/profile 中添加PATH=$PATH:/usr/local/tengine/sbin

  2、默认情况下,系统搜索哭文件的路径/lib,/usr/lib,要增加额外搜寻路径

     在/etc/ld.so.conf.d/中创建以.conf为后缀名的文件,而后把要增添的路径直接写入至此      文件中;

     #领导config通知系统重新搜寻库文件

        -v:显示重新搜寻库的过程

  3、头文件,输出给系统

       默认:/usr/include

       增添头文件搜寻路径,使用链接进行

    /usr/local/tengine/include/   /usr/include/

    两种方式:

     ln -s /usr/local/tengine/include/* /usr/include/ 

或者 ln -s /usr/local/tengine/include /usr/include/tengine

  4、man文件路径:安装在--prefix指定的目录下的man目录下;

    两种方式:

      1、man -M /PATH/TO/MAN_DIR  把生成的man文件加入到默认帮助文档中

      2、在/etc/man.conf文档中添加MANPATH /PATH/TO/MAN_DIR

 

执行编译安装前提必须安装编译环境:(开发工具和开发函数库最好安装系统时选择安装)

必须安装有“Development Tools”和“Development Libraries”开发工具组和开发函数库

  yum groupinstall "Development Tools"

  yum groupinstall "Development Libraries"

实例:编译安装tengine

#tar xf tengine-1.5.1.tar.gz

#cd tegnine-1.5.1

#./configure -prefix=/usr/local/tengine --conf-path=/etc/tengine/tengine.con

#make

#make install

#/usr/local/tengine/sbin/nginx 执行程序

  #tar zxvf tengine-1.5.1.tar.gz

[root@xuelinux ~]# cd tengine-1.5.1

[root@xuelinux tengine-1.5.1]# ls

AUTHORS.te  CHANGES.cn  conf       docs     Makefile  README           tests

auto        CHANGES.ru  configure  html     man       README.markdown  THANKS.te

CHANGES     CHANGES.te  contrib    LICENSE  objs      src

[root@xuelinux tengine-1.5.1]# ./configure --prefix=/usr/local/tengine-1.5.1

checking for OS

 + Linux 2.6.32-431.el6.i686 i686

checking for C compiler ... found

 + using GNU C compiler

 + gcc version: 4.4.7 20120313 (Red Hat 4.4.7-4) (GCC) 

checking for gcc -pipe switch ... found

checking for gcc builtin atomic operations ... found

checking for C99 variadic macros ... found

checking for PCRE library in /opt/local/ ... not found


./configure: error: the HTTP rewrite module requires the PCRE library. #提示缺少pcre报错

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.


[root@xuelinux tengine-1.5.1]# yum install pcre-devel  安装相应的pcre函数库后再进行编译

Installed:

  pcre-devel.i686 0:7.8-6.el6                                                              

Complete!

[root@xuelinux tengine-1.5.1]# ./configure --prefix=/usr/local/tengine-1.5.1 指定安装路径

checking for OS

 + Linux 2.6.32-431.el6.i686 i686

checking for C compiler ... found

 nginx http uwsgi temporary files: "uwsgi_temp"

  nginx http scgi temporary files: "scgi_temp"


[root@xuelinux tengine-1.5.1]# make  进行编译

make -f objs/Makefile

make[1]: Entering directory `/root/tengine-1.5.1' 

make[1]: Entering directory `/root/tengine-1.5.1'

sed -e "s|%%PREFIX%%|/usr/local/tengine-1.5.1|" \

-e "s|%%PID_PATH%%|/usr/local/tengine-1.5.1/logs/nginx.pid|" \

-e "s|%%CONF_PATH%%|/usr/local/tengine-1.5.1/conf/nginx.conf|" \

-e "s|%%ERROR_LOG_PATH%%|/usr/local/tengine-1.5.1/logs/error.log|" \

< man/nginx.8 > objs/nginx.8

make[1]: Leaving directory `/root/tengine-1.5.1'    编译完成

[root@xuelinux tengine-1.5.1]# make install   执行编译安装

make -f objs/Makefile install

make[1]: Entering directory `/root/tengine-1.5.1'

cp objs/dso_tool '/usr/local/tengine-1.5.1/sbin/dso_tool'

chmod 0755 '/usr/local/tengine-1.5.1/sbin/dso_tool'

make[1]: Leaving directory `/root/tengine-1.5.1'    至此编译安装tengine完成

[root@xuelinux sbin]# nginx      执行该程序

-bash: nginx: command not found    提示没有找到命令因为环境变量未添加该执行程序路径

[root@xuelinux sbin]# vim /etc/profile  编辑环境变量配置文件把该路径添加进去


PATH=$PATH:/usr/local/tengine-1.5.1/sbin   添加该行

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

[root@xuelinux sbin]# source /etc/profile   重新读取该配置文件,使得修改生效

[root@xuelinux sbin]# nginx   执行后正常

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] still could not bind()  提示端口被占用

[root@xuelinux sbin]# fuser -n tcp 80   查看被占用端口的进程

80/tcp:              20340 20341

[root@xuelinux sbin]# kill -9 20340  终止占用端口的进程

[root@xuelinux sbin]# kill -9 20341  终止占用端口的进程

[root@xuelinux sbin]# nginx

[root@xuelinux sbin]# nginx

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)

nginx: [emerg] still could not bind()

[root@xuelinux sbin]# netstat -tlnp  查看监听端口

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:111                 0.0.0.0:*                   LISTEN      1235/rpcbind        

tcp        0      0 0.0.0.0:80                  0.0.0.0:*                   LISTEN      20340/nginx          已经取用了nginx

tcp        0      0 192.168.122.1:53            0.0.0.0:*                   LISTEN      1797/d

然后就可通过ip地址访问该地址了。













本文转自wang650108151CTO博客,原文链接: http://blog.51cto.com/woyaoxuelinux/1878174,如需转载请自行联系原作者


相关文章
|
1月前
|
Linux
Linux系统之whereis命令的基本使用
Linux系统之whereis命令的基本使用
73 24
Linux系统之whereis命令的基本使用
|
4天前
|
Linux
Linux od命令
本文详细介绍了Linux中的 `od`命令,包括其基本语法、常用选项和示例。通过这些内容,你可以灵活地使用 `od`命令查看文件内容,提高分析和调试效率。确保理解每一个选项和示例的实现细节,应用到实际工作中时能有效地处理各种文件查看需求。
41 19
|
15天前
|
缓存 Ubuntu Linux
Linux中yum、rpm、apt-get、wget的区别,yum、rpm、apt-get常用命令,CentOS、Ubuntu中安装wget
通过本文,我们详细了解了 `yum`、`rpm`、`apt-get`和 `wget`的区别、常用命令以及在CentOS和Ubuntu中安装 `wget`的方法。`yum`和 `apt-get`是高层次的包管理器,分别用于RPM系和Debian系发行版,能够自动解决依赖问题;而 `rpm`是低层次的包管理工具,适合处理单个包;`wget`则是一个功能强大的下载工具,适用于各种下载任务。在实际使用中,根据系统类型和任务需求选择合适的工具,可以大大提高工作效率和系统管理的便利性。
97 25
|
14天前
|
缓存 Linux
Linux查看内存命令
1. free free命令是最常用的查看内存使用情况的命令。它显示系统的总内存、已使用内存、空闲内存和交换内存的总量。 free -h • -h 选项:以易读的格式(如GB、MB)显示内存大小。 输出示例: total used free shared buff/cache available Mem: 15Gi 4.7Gi 4.1Gi 288Mi 6.6Gi 9.9Gi Swap: 2.0Gi 0B 2.0Gi • to
27 2
|
tengine 应用服务中间件 Linux
linux下tengine2.2.0编译安装、开机启动、反向代理配置及健康检查
tengine2.2.0编译安装、开机启动、反向代理配置及健康检查 tengine是由淘宝发起的一个基于nginx的开源项目,nginx的吞吐量比较高、快速、稳定,而且反向代理和负载均衡使用nginx,也是最常见的。
2053 0
|
4月前
|
Linux 网络安全 数据安全/隐私保护
Linux 超级强大的十六进制 dump 工具:XXD 命令,我教你应该如何使用!
在 Linux 系统中,xxd 命令是一个强大的十六进制 dump 工具,可以将文件或数据以十六进制和 ASCII 字符形式显示,帮助用户深入了解和分析数据。本文详细介绍了 xxd 命令的基本用法、高级功能及实际应用案例,包括查看文件内容、指定输出格式、写入文件、数据比较、数据提取、数据转换和数据加密解密等。通过掌握这些技巧,用户可以更高效地处理各种数据问题。
413 8
|
4月前
|
监控 Linux
如何检查 Linux 内存使用量是否耗尽?这 5 个命令堪称绝了!
本文介绍了在Linux系统中检查内存使用情况的5个常用命令:`free`、`top`、`vmstat`、`pidstat` 和 `/proc/meminfo` 文件,帮助用户准确监控内存状态,确保系统稳定运行。
1277 6
|
4月前
|
Linux
在 Linux 系统中,“cd”命令用于切换当前工作目录
在 Linux 系统中,“cd”命令用于切换当前工作目录。本文详细介绍了“cd”命令的基本用法和常见技巧,包括使用“.”、“..”、“~”、绝对路径和相对路径,以及快速切换到上一次工作目录等。此外,还探讨了高级技巧,如使用通配符、结合其他命令、在脚本中使用,以及实际应用案例,帮助读者提高工作效率。
269 3
|
2月前
|
网络协议 Unix Linux
深入解析:Linux网络配置工具ifconfig与ip命令的全面对比
虽然 `ifconfig`作为一个经典的网络配置工具,简单易用,但其功能已经不能满足现代网络配置的需求。相比之下,`ip`命令不仅功能全面,而且提供了一致且简洁的语法,适用于各种网络配置场景。因此,在实际使用中,推荐逐步过渡到 `ip`命令,以更好地适应现代网络管理需求。
53 11
|
4月前
|
Linux
在 Linux 系统中,`find` 命令
在 Linux 系统中,`find` 命令
126 56