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=<path> 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  终止占用端口的进程

[[email protected] sbin]# nginx

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

时间: 2024-08-11 10:19:22

linux命令:编译安装软件包的相关文章

Linux 下编译安装xDebug命令速记

下载xdebug-2.2.4.tgz软件链接: http://pan.baidu.com/s/1jGHYRMA #解压 xdebugtar -zxvf xdebug-2.2.4.tgz #进入xdebug源代码目录cd xdebug-2.2.4 #执行 phpize 配置/pathto-php/bin/phpize #开始安装配置./configure --prefix=/pathto-php/lib/php/extensions \--with-php-config=/pathto-php/b

Linux 下编译安装xCache命令速记

注意要先确保/path-to-php/bin/php-config存在下载链接: http://pan.baidu.com/s/1hqh5pDM #解压xcache源代码tar -zvxf xcache-3.1.0.tar.gz #进入安装目录cd xcache-3.1.0 #安装前执行phpize配置/path-to-php/bin/phpize #安装配置 ./configure --prefix=/path-to-php/lib/php/extensions \--with-php-con

linux中编译安装Apache、PHP、MySQL(上)

1.简介 在阿里云买了个云服务器,一直没时间折腾.过了近十天了吧,才有时间好好玩玩这个云服务器.自己是做Web开发的,所以我需要的开发环境是LAMP.之前打算是采用yum安装,不过yum安装apache可以安装到2.4版本,而PHP最高安装版本只能是5.4,这也是yum安装PHP的软肋,因此我这里主要涉及到的安装方式是源码安装.通过源码安装能够更好的管理这些软件,想安装到哪就放在哪. 云服务器: 阿里云CentOS 7.2 64位 阿帕奇版本:apache2.4 PHP版本:PHP5.6 主要的

Service系统服务(二):补充应用技巧、软连接与硬连接、man手册、zip备份、vim效率操作、自定义yum软件仓库、发布及测试yum仓库、编译安装软件包

一.补充应用技巧 目标: 本例要求掌握在运维中比较常用的一些扩展命令技巧的使用,完成下列小技巧操作: 1> 采用数值形式将目录/root的权限调整为 rwx------   2> 将记录的历史命令条数更改为 200 条   3> 统计 /boot./etc/pki 目录占用的空间大小   4> 以格式"yyyy-mm-dd HH:MM" 显示系统时间 方案: date日期时间工具: 1> 显示日期时间:date.date +"%Y-%m-%d %

Linux下编译安装qemu和libvirt

目录 [hide] 1 安装qemu 1.1 qemu介绍 1.2 下载源文件 1.3 编译安装 2 安装libvirt 2.1 libvirt介绍 2.2 下载libvirt 2.3 编译安装 3 参考资料 KVM虚拟机(英语:Kernel-based Virtual Machine),是一种用于Linux内核中的虚拟化基础设施.KVM目前支援Intel VT及AMD-V的原生虚拟技术.KVM在2007年2月被导入Linux 2.6.20核心中.它也被引入FreeBSD.在Mac OS X中,

Linux/RedHat 编译安装GNU gcc 4.9.0 (g++)

这里说的是编译安装,yum/apt-get 等安装方法比较简单,不阐述! 1.下载源码包:gcc.gnu.org 2.解压: tar -xjvf gcc-4.9.0.tar.bz2 3.下载编译所需的依赖包: 最简单的方法,直接执行: ./contrib/download_prerequisites 脚本自动下载依赖包 gmp, mpfr,mpc. 也可以手动下载然后移到/gcc-4.9.0目录下面自动一起安装,或者自行先编译安装 4.执行configure命令,产生makefile: mkdi

linux下编译安装boost库

转载:http://www.cnblogs.com/oloroso/p/4632848.html linux下编译安装boost库 linux下编译安装boost库 1.下载并解压boost 1.58 源代码 下载 解压 2.运行bootstrap.sh 3.使用b2进行构建 构建成功的提示 4.安装boost库到指定目录 5.测试一下 代码 编译运行 先看一下系统环境 Linux o-pc 3.19.0-22-generic #22-Ubuntu SMP Tue Jun 16 17:15:15

linux下编译安装nginx

1.首先下载稳定版nginx1.10.2 使用wget命令下载 wget http://nginx.org/download/nginx-1.10.2.tar.gz 2.然后解压 tar -zxvf nginx-1.10.2.tar.gz 3.安装依赖库 sudo apt-get install libpcre3-dev aptitude libssl-dev sudo apt-get install openssl sudo apt-get install libssl0.9.8 sudo a

linux PHP 编译安装参数详解

linux PHP 编译安装参数详解 ./configure --prefix=/usr/local/php --with-config-file-path=/usr/local/php/etc --with-mysql=/usr/local/mysql --with-mysqli=/usr/bin/mysql_config --with-iconv-dir=/usr/local --with-freetype-dir --with-jpeg-dir --with-png-dir --with-

linux 下编译安装php

系统环境: CentOS 6.5 x86_64 下载 PHP 源码包 # wget http://cn2.php.net/distributions/php-5.5.9.tar.bz2 # tar xf php-5.5.9.tar.bz2 -C /usr/local/src/ 添加 epel 源 # rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm 安装依赖 # yum insta