CentOS 6.5 下離線安裝nginx


一、由於linux下安裝nginx 需要 

zlib zlib-devel openssl openssl-devel pcre pcre-devel gcc
這些依賴,而這些依賴打安裝包在我們系統的光盤里有一個packages目錄,里邊包含這些依賴,所以我們掛載我們打CentOS.iso文件,並將其packages目錄搭建為yum倉庫:
[root@all /]# mkdir /mnt/cdrom
[root@all /]# mount /dev/cdrom  /mnt/cdrom

二、搭建yum倉庫

yum使用倉庫保存管理rpm的軟件包、倉庫的配置文件保存在/etc/yum.repos.d/目錄下格式如下:
[LinuxCast]    #倉庫的名字 
name = 對名字的解釋      #描述倉庫的基本信息 
baseurl = 倉庫的地址 #本地的或者以http、ftp、file、ntfs 
enable = 1              #是否啟用 
gpgcheck = 1            #是否校驗

[root@all /]# mkdir /home/yum.repos.d/
[root@all /]# mv /etc/yum.repos.d/* /home/yum.repos.d/
[root@all /]# vi /etc/yum.repos.d/centos.repo

 

這里我的centos.repo配置文件如下:

[centos]    #倉庫的名字 
name = centos     #描述倉庫的基本信息 
baseurl = file:///mnt/cdrom/packages
enable = 1              #是否啟用 
gpgcheck = 1            #是否校驗

注意:這里由於系統自帶了許多yum倉庫,但又是需要聯網的,所有需要把/etc/yum.repos.d/目錄下其他文件都刪除。

三、測試yum倉庫環境

[root@all /]# yum repolist
會看到如下信息:

Loaded plugins: fastestmirror, security
Loading mirror speeds from cached hostfile
base | 4.0 kB 00:00 ...
repo id repo name status
base CentOs 6.5 6,367
repolist: 6,367

這時表示你配置成功了。

 

 四、配置nginx,並安裝依賴

第一步:從http://nginx.org/download/上下載相應的版本(或者wget http://nginx.org/download/nginx-1.5.9.tar.gz直接在Linux上用命令下載)

第二步:解壓 tar -zxvf nginx-1.5.9.tar.gz 

第三步:設置一下配置信息 

./configure --with-http_ssl_module \
--with-http_stub_status_module \
--with-http_gzip_static_module \
--with-mail \
--with-mail_ssl_module 

第四步:

make 編譯 (make的過程是把各種語言寫的源碼文件,變成可執行文件和各種庫文件)

make install 安裝 (make install是把這些編譯出來的可執行文件和庫文件復制到合適的地方)

 

在配置信息的時候,也就是在第三步,出現了一下錯誤:

錯誤為:./configure: error: the HTTP rewrite module requires the PCRE library.

安裝pcre-devel解決問題
yum -y install pcre-devel

還有可能出現:

錯誤提示:./configure: error: the HTTP cache module requires md5 functions
from OpenSSL library.   You can either disable the module by using
--without-http-cache option, or install the OpenSSL library into the system,
or build the OpenSSL library statically from the source with nginx by using
--with-http_ssl_module --with-openssl=<path> options.

 

解決辦法:

yum -y install openssl openssl-devel

 


免責聲明!

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



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