linux编译安装命令,linux命令:编译安装软件包(示例代码)

编译安装的步骤:

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

[[email protected] ~]# cd tengine-1.5.1

[[email protected] 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

[[email protected] 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= option.

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

Installed:

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

Complete!

[[email protected] 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"

[[email protected] 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‘    编译完成

[[email protected] 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完成

[[email protected] sbin]# nginx      执行该程序

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

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

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

export PATH USER LOGNAME MAIL HOSTNAME HISTSIZE HISTCONTROL

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

[[email protected] 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()  提示端口被占用

[[email protected] sbin]# fuser -n tcp 80   查看被占用端口的进程

80/tcp:              20340 20341

[[email protected] sbin]# kill -9 20340  终止占用端口的进程

[[email protected] sbin]# kill -9 20341  终止占用端口的进程

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()

[[email protected] 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地址访问该地址了。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值