在Linux下安裝軟體,可分為三種方式:使用制作好的rpm包安裝、使用yum源進行安裝、編譯源代碼的方式安裝軟體包。使用編譯源代碼的方式安裝軟體包步驟:
【1】.執行"./configure" 其作用就是編譯源代碼生成makefile.in即makefile檔案
【2】.使用"make" 作用是自動調用gcc進行編譯
【3】.安裝"make install"
【4】.PATH的附加,編寫庫檔案
4.1、導出軟體的庫檔案方法:
(1)、在/etc/ld.so.conf下建立一個以.conf結尾的檔案,為了友善明了,一般使用軟體名作為該檔案名,并将此程式的庫檔案路徑添加到此檔案中,例如安裝一個httpd,則命名為httpd.conf并在該檔案下寫入該軟體的庫檔案所在的路徑
如:/usr/local/httpd/lib
(2)、執行"ldconfig",讓系統重新裝載庫檔案。
4.2、環境變量PATH中存放的都是可執行的二進制檔案的路徑,在執行一個軟體或指令時首先就會到PATH中去查找,如果查找不到則無法使用,是以需要将其路徑加入到PATH中
(1)、執行#export PATH=$PATH:/usr/local/httpd/bin 暫時有效
(2)、對所有使用者生效,則寫入/etc/profile檔案中
PATH=$PATH:/usr/local/httpd/bin
(3)、對某個使用者生效,則寫入~/profile檔案中
4.3、man檔案路徑的導出
編輯/etc/man.config檔案,新增加如下一行
MANPATH /usr/local/httpd/man
4.4、頭檔案的導出
(1)、建立頭檔案的軟連接配接
#ln -sv /usr/local/include /usr/local/httpd/include
(2)、将頭檔案複制到/usr/local/include下
例如:1.展開歸檔http
#tar xvf httpd-2.2.19.tar.bz2
<a href="http://blog.51cto.com/attachment/201202/124447944.jpg" target="_blank"></a>
2.進入展開的目錄中
#cd httpd-2.2.19
<a href="http://blog.51cto.com/attachment/201202/124507889.jpg" target="_blank"></a>
3.使用./configure --help 檢視具體的安裝選項
#./configure --help
這裡我隻指定安裝路徑和配置檔案的安裝路徑
#./configure --prefix=/usr/ --sysconfdir=/etc/httpd
<a href="http://blog.51cto.com/attachment/201202/124520307.jpg" target="_blank"></a>
4.檢視指令是否執行成功
#echo $?
<a href="http://blog.51cto.com/attachment/201202/124631960.jpg" target="_blank"></a>
5.使用make進行編譯
#make
<a href="http://blog.51cto.com/attachment/201202/124641125.jpg" target="_blank"></a>
6.使用make install進行安裝
#make install
<a href="http://blog.51cto.com/attachment/201202/124651719.jpg" target="_blank"></a>
7.導出庫檔案
#vim /etc/ld.so.conf.d/httpd.conf
<a href="http://blog.51cto.com/attachment/201202/124701887.jpg" target="_blank"></a>
<a href="http://blog.51cto.com/attachment/201202/124711426.jpg" target="_blank"></a>
執行"ldconfig" 重新加載庫檔案
<a href="http://blog.51cto.com/attachment/201202/124741499.jpg" target="_blank"></a>
8.導出可執行程式路徑
#vim /etc/profile
增加:/usr/local/httpd/bin
<a href="http://blog.51cto.com/attachment/201202/124805731.jpg" target="_blank"></a>
9.man檔案路徑導出
#vim /etc/man.config
增加一行:MANPATH /usr/local/httpd/man
<a href="http://blog.51cto.com/attachment/201202/124833133.jpg" target="_blank"></a>
10.建立頭檔案軟連接配接
<a href="http://blog.51cto.com/attachment/201202/124854286.jpg" target="_blank"></a>
這樣一個就完成了使用源碼編譯安裝軟體了!
本文轉自 向陽草米奇 51CTO部落格,原文連結:http://blog.51cto.com/grass51/787605,如需轉載請自行聯系原作者