【linux安裝軟件步驟】


一、解析linux應用軟件安裝包:

通常Linux應用軟件的安裝包有三種:

  • tar包,如software-1.2.3-1.tar.gz。它是使用UNIX系統的打包工具tar打包的。
  • rpm包,如software-1.2.3-1.i386.rpm。它是Redhat Linux提供的一種包封裝格式。
  • dpkg包,如software-1.2.3-1.deb。它是Debain Linux提供的一種包封裝格式。

大多數Linux應用軟件包的命名也有一定的規律,它遵循:

名稱-版本-修正版-類型

例如:

  • software-1.2.3-1.tar.gz 意味着:
    • 軟件名稱:software
    • 版本號:1.2.3
    • 修正版本:1
    • 類型:tar.gz,說明是一個tar包。
  • sfotware-1.2.3-1.i386.rpm
    • 軟件名稱:software
    • 版本號:1.2.3
    • 修正版本:1
    • 可用平台:i386,適用於Intel 80x86平台。
    • 類型:rpm,說明是一個rpm包。
    注:由於rpm格式的通常是已編譯的程序,所以需指明平台。
  • 對於software-1.2.3-1.deb就請大家自己練習一下。

二、了解包里面的內容

一個Linux應用程序的軟件包中可以包含兩種不同的內容:

  • 一種就是可執行文件,也就是解開包后就可以直接運行的。在Windows中所 有的軟件包都是這種類型。安裝完這個程序后,你就可以使用,但你看不到源程序。而且下載時要注意這個軟件是否是你所使用的平台,否則將無法正常安裝。
  • 另一種則是源程序,也就解開包后,你還需要使用編譯器將其編譯成為可執行文件。這在Windows系統中是幾乎沒有的,因為Windows的思想是不開放源程序的。

通常,用tar打包的,都是源程序;而用rpm、dpkg打包的則常是可執行程序。一般來說,自己動手編譯源程序能夠更具靈活性,但也容易遇到各種問題和困難。而相對來說,下載那些可執行程序包,反而是更容易完成軟件的安裝,當然那樣靈活性就差多了。所以一般一個軟件總會提供多種打包格式的安裝程序的。你可以根據自己的情況來選擇。

三、搞定使用tar包的應用原件

  • 安裝

    整個安裝過程可以分為以下幾步:

    1. 取得應用軟件:通過下載、購買光盤的方法獲得;
    2. 解壓縮文件:一般tar包,都會再做一次壓縮,如gzip、bz2等,所以你需要先解壓。如果是最常見的gz格式,則可以執行:“tar –xvzf 軟件包名”,就可以一步完成解壓與解包工作。如果不是,則先用解壓軟件,再執行“tar –xvf 解壓后的tar包”進行解包;
    3. 閱讀附帶的INSTALL文件、README文件;
    4. 執行“./configure”命令為編譯做好准備;
    5. 執行“make”命令進行軟件編譯;
    6. 執行“make install”完成安裝;
    7. 執行“make clean”刪除安裝時產生的臨時文件。

    好了,到此大功告成。我們就可以運行應用程序了。但這時,有的讀者就會問,我怎么執行呢?這也是一個Linux特色的問題。其實,一般來說,Linux的應用軟件的可執行文件會存放在/usr/local/bin目錄下!不過這並不是“放四海皆准”的真理,最可靠的還是看這個軟件的INSTALL和README文件,一般都會有說明。

  • 卸載

    通常軟件的開發者很少考慮到如何卸載自己的軟件,而tar又僅是完成打包的工作,所以並沒有提供良好的卸載方法。

    那么是不是說就不能夠卸載呢!其實也不是,有兩個軟件能夠解決這個問題,那就是Kinstall和Kife,它們是tar包安裝、卸載的黃金搭檔。它們的使用方法,筆者會另行文介紹。在此就不加贅述了。

四、搞定使用rpm打包的應用軟件

rpm可謂是Redhat公司的一大貢獻,它使Linux的軟件安裝工作變得更加簡單容易。

  • 安裝

    執行:

    rpm –ivh rpm軟件包名

    更高級的,請見下表:

    rpm參數 參數說明
    -i 安裝軟件
    -t 測試安裝,不是真的安裝
    -p 顯示安裝進度
    -f 忽略任何錯誤
    -U 升級安裝
    -v 檢測套件是否正確安裝

    這些參數可以同時采用。更多的內容可以參考RPM的命令幫助。

  • 卸載

    我同樣只需簡單的一句話,就可以說完。執行:

    rpm –e 軟件名

    不過要注意的是,后面使用的是軟件名,而不是軟件包名。例如,要安裝software-1.2.3-1.i386.rpm這個包時,應執行:

    rpm –ivh software-1.2.3-1.i386.rpm

    而當卸載時,則應執行:

    rpm –e software。

    另外,在Linux中還提供了象GnoRPM、kpackage等圖形化的RPM工具,使得整個過程會更加簡單。這些軟件的具體應用,筆者會另行文介紹。

五、搞定使用deb打包得讓應用程序

這是Debian Linux提供的一個包管理器,它與RPM十分類似。但由於RPM出現得更早,所以在各種版本的Linux都常見到。而debian的包管理器dpkg則只出現在Debina Linux中,其它Linux版本一般都沒有。我們在此就簡單地說明一下:

  • 安裝
    dpkg –i deb軟件包名

    如:

    dpkg –i software-1.2.3-1.deb
  • 卸載
    dpkg –e 軟件名

    如:

    dpkg –e software

 

  • Linux下安裝nginx    

1:將下載下來的Nginx上傳到/opt/nginx目錄下。運行“tar -zxvf nginx-1.6.2.tar.gz”進行解壓

  

 

2:進入解壓縮目錄,運行./configure進行初始化配置。如出現下面的提示,說明該機器沒有安裝PCRE,而Nginx需要依賴PCRE,需要手動安裝PCRE。

  

  

Linux下安裝PCRE:

  

PCRE(Perl Compatible Regular Expressions)是一個輕量級的Perl函數庫,包括 perl 兼容的正則表達式庫。它比Boost之類的正則表達式庫小得多。PCRE十分易用,同時功能也很強大,性能超過了POSIX正則表達式庫和一些經典的正則表達式庫。

1. PCRE目前最新版本為8.36,可以點這里進行下載。

2. 使用tar -zxvf pcre-8.36.tar.gz進行解壓。

3. 運行 chmod -R 777 /pcre-8.36 對當前文件夾授予全部讀寫權限。

  在執行chmod 時出現:【linux-command not find解決方法 】 參見解決方法

4. 切換到/pcre-8.36目錄下,運行 ./configure 進行pcre初始化配置,會在控制台打印出一大堆的輸出信息。

  在執行./configure時出現:

解決方法:參見:【linux-./configure 配置文件時出錯問題】

5. 執行make操作,進行編譯。

[root@server06 pcre-8.36]# make 
rm -f pcre_chartables.c 
ln -s ./pcre_chartables.c.dist pcre_chartables.c 
make  all-am 
make[1]: Entering directory `/opt/nginx/pcre-8.36' 
  CC      libpcre_la-pcre_byte_order.lo 
  CC      libpcre_la-pcre_compile.lo 
  CC      libpcre_la-pcre_config.lo 
  CC      libpcre_la-pcre_dfa_exec.lo 
  CC      libpcre_la-pcre_exec.lo 
  CC      libpcre_la-pcre_fullinfo.lo 
  CC      libpcre_la-pcre_get.lo 
  CC      libpcre_la-pcre_globals.lo 
  CC      libpcre_la-pcre_jit_compile.lo 
  CC      libpcre_la-pcre_maketables.lo 
  CC      libpcre_la-pcre_newline.lo 
  CC      libpcre_la-pcre_ord2utf8.lo 
  CC      libpcre_la-pcre_refcount.lo 
  CC      libpcre_la-pcre_string_utils.lo 
  CC      libpcre_la-pcre_study.lo 
  CC      libpcre_la-pcre_tables.lo 
  CC      libpcre_la-pcre_ucd.lo 
  CC      libpcre_la-pcre_valid_utf8.lo 
  CC      libpcre_la-pcre_version.lo 
  CC      libpcre_la-pcre_xclass.lo 
  CC      libpcre_la-pcre_chartables.lo 
  CCLD    libpcre.la 
  CC      libpcreposix_la-pcreposix.lo 
  CCLD    libpcreposix.la 
  CXX      libpcrecpp_la-pcrecpp.lo 
  CXX      libpcrecpp_la-pcre_scanner.lo 
  CXX      libpcrecpp_la-pcre_stringpiece.lo 
  CXXLD    libpcrecpp.la 
  CC      pcretest-pcretest.o 
  CC      pcretest-pcre_printint.o 
  CCLD    pcretest 
  CC      pcregrep-pcregrep.o 
  CCLD    pcregrep 
  CXX      pcrecpp_unittest-pcrecpp_unittest.o 
  CXXLD    pcrecpp_unittest 
  CXX      pcre_scanner_unittest-pcre_scanner_unittest.o 
  CXXLD    pcre_scanner_unittest 
  CXX      pcre_stringpiece_unittest-pcre_stringpiece_unittest.o 
  CXXLD    pcre_stringpiece_unittest 
make[1]: Leaving directory `/opt/nginx/pcre-8.36'

6. 運行 [root@server06 pcre-8.36]# make install,進行安裝,至此PCRE安裝完成。   
 
[root@server06 pcre-8.36]# make install

 

3: 安裝完PCRE后,再次運行./configure進行初始化即可。注意這里生成的配置文件,尤其箭頭所指的方向,是啟動nginx時的路徑。

=================================================================

[root@localhost javaSoft]# ls
nginx-1.8.0 nginx-1.8.0.tar.gz pcre-8.40 pcre-8.40.tar.gz
[root@localhost javaSoft]# cd nginx-1.8.0
[root@localhost nginx-1.8.0]# ls
auto CHANGES.ru configure html Makefile objs src
CHANGES conf contrib LICENSE man README
[root@localhost nginx-1.8.0]# pwd
/javaSoft/nginx-1.8.0

[root@localhost nginx-1.8.0]# ll
總用量 660
drwxr-xr-x. 6 1001 1001 4096 4月 11 22:04 auto
-rw-r--r--. 1 1001 1001 249124 4月 21 2015 CHANGES
-rw-r--r--. 1 1001 1001 379021 4月 21 2015 CHANGES.ru
drwxr-xr-x. 2 1001 1001 4096 4月 11 22:04 conf
-rwxr-xr-x. 1 1001 1001 2478 4月 21 2015 configure
drwxr-xr-x. 4 1001 1001 4096 4月 11 22:04 contrib
drwxr-xr-x. 2 1001 1001 4096 4月 11 22:04 html
-rw-r--r--. 1 1001 1001 1397 4月 21 2015 LICENSE
-rw-r--r--. 1 root root 46 4月 11 22:07 Makefile
drwxr-xr-x. 2 1001 1001 4096 4月 11 22:04 man
drwxr-xr-x. 2 root root 4096 4月 11 22:07 objs
-rw-r--r--. 1 1001 1001 49 4月 21 2015 README
drwxr-xr-x. 8 1001 1001 4096 4月 11 22:04 src
[root@localhost nginx-1.8.0]# ./configure
checking for OS
+ Linux 2.6.32-504.el6.x86_64 x86_64
checking for C compiler ... found
+ using GNU C compiler
+ gcc version: 4.4.7 20120313 (Red Hat 4.4.7-18) (GCC)
checking for gcc -pipe switch ... found
checking for gcc builtin atomic operations ... found
checking for C99 variadic macros ... found
checking for gcc variadic macros ... found
checking for unistd.h ... found
checking for inttypes.h ... found
checking for limits.h ... found
checking for sys/filio.h ... not found
checking for sys/param.h ... found
checking for sys/mount.h ... found
checking for sys/statvfs.h ... found
checking for crypt.h ... found
checking for Linux specific features
checking for epoll ... found
checking for EPOLLRDHUP ... found
checking for O_PATH ... not found
checking for sendfile() ... found
checking for sendfile64() ... found
checking for sys/prctl.h ... found
checking for prctl(PR_SET_DUMPABLE) ... found
checking for sched_setaffinity() ... found
checking for crypt_r() ... found
checking for sys/vfs.h ... found
checking for nobody group ... found
checking for poll() ... found
checking for /dev/poll ... not found
checking for kqueue ... not found
checking for crypt() ... not found
checking for crypt() in libcrypt ... found
checking for F_READAHEAD ... not found
checking for posix_fadvise() ... found
checking for O_DIRECT ... found
checking for F_NOCACHE ... not found
checking for directio() ... not found
checking for statfs() ... found
checking for statvfs() ... found
checking for dlopen() ... not found
checking for dlopen() in libdl ... found
checking for sched_yield() ... found
checking for SO_SETFIB ... not found
checking for SO_ACCEPTFILTER ... not found
checking for TCP_DEFER_ACCEPT ... found
checking for TCP_KEEPIDLE ... found
checking for TCP_FASTOPEN ... not found
checking for TCP_INFO ... found
checking for accept4() ... found
checking for eventfd() ... found
checking for int size ... 4 bytes
checking for long size ... 8 bytes
checking for long long size ... 8 bytes
checking for void * size ... 8 bytes
checking for uint64_t ... found
checking for sig_atomic_t ... found
checking for sig_atomic_t size ... 4 bytes
checking for socklen_t ... found
checking for in_addr_t ... found
checking for in_port_t ... found
checking for rlim_t ... found
checking for uintptr_t ... uintptr_t found
checking for system byte ordering ... little endian
checking for size_t size ... 8 bytes
checking for off_t size ... 8 bytes
checking for time_t size ... 8 bytes
checking for setproctitle() ... not found
checking for pread() ... found
checking for pwrite() ... found
checking for sys_nerr ... found
checking for localtime_r() ... found
checking for posix_memalign() ... found
checking for memalign() ... found
checking for mmap(MAP_ANON|MAP_SHARED) ... found
checking for mmap("/dev/zero", MAP_SHARED) ... found
checking for System V shared memory ... found
checking for POSIX semaphores ... not found
checking for POSIX semaphores in libpthread ... found
checking for struct msghdr.msg_control ... found
checking for ioctl(FIONBIO) ... found
checking for struct tm.tm_gmtoff ... found
checking for struct dirent.d_namlen ... not found
checking for struct dirent.d_type ... found
checking for sysconf(_SC_NPROCESSORS_ONLN) ... found
checking for openat(), fstatat() ... found
checking for getaddrinfo() ... found
checking for PCRE library ... found
checking for PCRE JIT support ... found
checking for md5 in system md library ... not found
checking for md5 in system md5 library ... not found
checking for md5 in system OpenSSL crypto library ... not found
checking for sha1 in system md library ... not found
checking for sha1 in system OpenSSL crypto library ... not found
checking for zlib library ... not found

./configure: error: the HTTP gzip module requires the zlib library.
You can either disable the module by using --without-http_gzip_module
option, or install the zlib library into the system, or build the zlib library
statically from the source with nginx by using --with-zlib=<path> option.

===================================================================

[root@localhost nginx-1.8.0]# make install
make: *** 沒有規則可以創建目標“install”。 停止。

解決方法:

 

 

4: 運行 make install 進行編譯。

5: 切換到步驟4生成的nginx運行目錄下,運行./nginx,啟動Nginx。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM