程序包编译

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了程序包编译相关的知识,希望对你有一定的参考价值。

C语言源代码编译安装三步骤

1——./configure

(1) 通过选项传递参数,指定启用特性、安装路径等;执行时会参考用户的指定以及Makefile.in文件生成Makefile

(2) 检查依赖到的外部环境,如依赖的软件包

2——make  根据Makefile文件,构建应用程序

3——make install  复制文件到相应路径

QuickStart - Unix

  $ ./configure --prefix=PREFIX

  $ make

  $ make install

  $ PREFIX/bin/apachectlstart  指定路径 开启软件

1编译安装准备

(1)查看相同软件并卸载,下载源码(建议官网下载) ,rz传入 建议放在/usr/local/src里并解包 。以httpd-2.2.34.tar.bz2 为例

[[email protected]~]#cd /usr/local/src  

[[email protected] src]#tar -xf httpd-2.2.34.tar.bz2  默认解压在当前目录

[[email protected]]#ls

httpd-2.2.34  httpd-2.2.34.tar.bz2

[[email protected] httpd-2.2.34]#ls  显示开发工具 

ABOUT_APACHE  buildconf     emacs-style  INSTALL        LICENSE        os                srclib

acinclude.m4      CHANGES        httpd.dep    InstallBin.dsp  Makefile.in              README                     support

Apache.dsw        config.layout  httpd.dsp     LAYOUT            Makefile.win          README.platforms  test

build                     configure        httpd.mak    libhttpd.dep    modules                  README-win32.txt  VERSIONING

BuildAll.dsp         configure.in    httpd.spec   libhttpd.dsp     NOTICE                   ROADMAP

BuildBin.dsp        docs                 include          libhttpd.mak   NWGNUmakefile  server

(2)安装"开发包组"提供开发组件  

[[email protected]]#yum grouplist "Developmet Tools"

2看说明

[[email protected]]#cat INSTALL

[[email protected]]#cat README

3生成Makefile

cd进入configure脚本所在目录

[[email protected]]#./configure --help

Installationdirectories:

  --prefix=PREFIX         install architecture-independent filesin PREFIX

                          [/usr/local/apache2]     默认安装目录路径  建议指定目录方便管理

 ……

[[email protected] httpd-2.2.34]#./configure --prefix=/app/httpd22--enable-ssl 指定目录路径  启用功能加密

checkingfor OpenSSL version... checking openssl/opensslv.h usability... no

……

noOpenSSL headers found

checkingfor SSL-C version... checking sslc.h usability... no

checkingsslc.h presence... no

checkingfor sslc.h... no

no SSL-Cheaders found

configure: error: ...No recognized SSL/TLStoolkit detected    openssl-devel

[[email protected]]#echo $?

1            外部环境出错

[[email protected] httpd-2.2.34]#yuminstall openssl-devel.x86_64   安装所缺少依赖的包

[[email protected]]#./configure --prefix=/app/httpd22 --enable-ssl         再次执行使其完成  

[[email protected]]#echo $?

0                                                 完成

[[email protected]]#ll

……

-rw-r--r--.  1 root root   8954 Aug 5 10:59 Makefile          ./configure执行时参考用户的指定以及Makefile.in生成Makefile

-rw-r--r--.  1 1001 1001  8739 Nov 26  2008 Makefile.in

-rw-r--r--.  1 1001 1001 34759 Jan 20  2014 Makefile.win

……

[[email protected] httpd-2.2.34]#make &&  make install     开始编译 安装生成到指定目录 指定目录自动生成

[[email protected]]#ls /app/httpd22 

bin  build cgi-bin  conf  error htdocs  icons  include lib  logs  man manual  modules

[[email protected]]#pwd

/usr/local/src/httpd-2.2.34      可删除当前目录


4软件配置 (PREFIX/bin/apachectl start 生效配置文件路径)

(1)二进制程序目录导入至PATH环境变量中

 编辑文件/etc/profile.d/NAME.shexport PATH=/PATH/TO/BIN:$PATH

(2)导入库文件路径 

编辑/etc/ld.so.conf.d/NAME.conf添加新的库文件所在目录至此文件中   让系统重新生成缓存: ldconfig

(3)导入帮助手册

编辑/etc/man.config |man_db.conf文件添加一个MANPATH

                      centos6    |    centos7      

[[email protected]]#ss -ntl

State      Recv-Q Send-Q          Local Address:Port                         Peer Address:Port             

LISTEN     0     5              192.168.122.1:53                                       *:*                 

LISTEN     0     128                        *:22                                                *:*                 

LISTEN    0     128                               127.0.0.1:631                                 *:*                                   

LISTEN     0     32                            :::21                                             :::*                 

LISTEN     0     128                         :::22                                                :::*                 

LISTEN     0     128                         ::1:631                                            :::* 

httpd提供web服务端口为80端口

[[email protected]]#echo ‘export PATH=/app/httpd22/bin:$PATH‘>/etc/profile.d/httpd22.sh

(单引号防止变量展开生效   自己路径放前面防止系统的配置文件先生效)

[[email protected]]#. /etc/profile.d/httpd22.sh

[[email protected]]#echo $PATH

/app/httpd22/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin

[[email protected]]#which apachectl

/app/httpd22/bin/apachectl

[[email protected] httpd22]#apachectl start 启动命令   配置文件/app/httpd22/bin

[[email protected]]#ss -ntl

State      Recv-Q Send-Q          Local Address:Port                         Peer Address:Port             

LISTEN     0      5              192.168.122.1:53                                       *:*                 

LISTEN     0     128                         *:22                                                *:*                 

LISTEN     0     128                127.0.0.1:631                                        *:*                 

LISTEN    0        128                          :::80                                                    :::*                              

LISTEN     0     32                            :::21                                                :::*                 

LISTEN     0     128                          :::22                                                :::*  

 80端口打开

[[email protected] man]#vim /etc/man_db.conf 修改httpdman帮助文档

MANDATORY_MANPATH                     /app/httpd22/man

   


以上是关于程序包编译的主要内容,如果未能解决你的问题,请参考以下文章

java 程序包systerm不存在

Linux程序包管理之rpm包管理

windows 驱动程序包iar systems能卸载吗

java 找不到程序包

解析程序包时出现问题如何解决?

程序包管理的前端工具yum程序包管理器编译安装sed命令