1. 程式人生 > >程序包編譯

程序包編譯

編譯 程序包 步驟

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



程序包編譯