首页 > 代码库 > 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
[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地址访问该地址了。
本文出自 “学linux历程” 博客,请务必保留此出处http://woyaoxuelinux.blog.51cto.com/5663865/1878174
linux命令:编译安装软件包