本分類下有一個環境一鍵安裝.那這背后發生了什么呢?咱們手動使用源碼進行安裝.
1.首先保證有一個能聯網的centos.
2.百度 ningx 官網 點download http://nginx.org/en/download.html 找到最新版的nginx下載地址. 發貼時最新的是1.12 http://nginx.org/download/nginx-1.12.0.tar.gz
3.進行centos 執行命令
#安裝wget
yum
install
wget -y
#安裝gcc和c++編譯器
yum
install
gcc gcc-c++ -y
錯誤提示:
./configure: error: the HTTP rewrite module requires the PCRE library.
安裝pcre-devel與openssl-devel解決問題
yum -y install pcre-devel openssl openssl-devel
./configure --prefix=/usr/local/nginx
make
make install
4.新建臨時目錄 /temp 然后下載並解壓. 命令如下
mkdir
/temp
;
cd
/temp
;
wget http:
//nginx
.org
/download/nginx-1
.12.0.
tar
.gz
tar
zxvf .
/nginx-1
.12.0.
tar
.gz
cd
/temp/nginx-1
.12.0
得到路徑:
[root@localhost nginx-1.12.0]# pwd
/temp/nginx-1.12.0
[root@localhost nginx-1.12.0]# ll
total 724
drwxr-xr-x. 6 1001 1001 4096 Apr 17 11:42 auto
-rw-r--r--. 1 1001 1001 277049 Apr 12 22:46 CHANGES
-rw-r--r--. 1 1001 1001 421985 Apr 12 22:46 CHANGES.ru
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 conf
-rwxr-xr-x. 1 1001 1001 2481 Apr 12 22:46 configure
drwxr-xr-x. 4 1001 1001 4096 Apr 17 11:42 contrib
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 html
-rw-r--r--. 1 1001 1001 1397 Apr 12 22:46 LICENSE
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 man
-rw-r--r--. 1 1001 1001 49 Apr 12 22:46 README
drwxr-xr-x. 9 1001 1001 4096 Apr 17 11:42 src
/temp/nginx-1.12.0
[root@localhost nginx-1.12.0]# ll
total 724
drwxr-xr-x. 6 1001 1001 4096 Apr 17 11:42 auto
-rw-r--r--. 1 1001 1001 277049 Apr 12 22:46 CHANGES
-rw-r--r--. 1 1001 1001 421985 Apr 12 22:46 CHANGES.ru
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 conf
-rwxr-xr-x. 1 1001 1001 2481 Apr 12 22:46 configure
drwxr-xr-x. 4 1001 1001 4096 Apr 17 11:42 contrib
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 html
-rw-r--r--. 1 1001 1001 1397 Apr 12 22:46 LICENSE
drwxr-xr-x. 2 1001 1001 4096 Apr 17 11:42 man
-rw-r--r--. 1 1001 1001 49 Apr 12 22:46 README
drwxr-xr-x. 9 1001 1001 4096 Apr 17 11:42 src
5.linux三大安裝步驟 配置,編譯,安裝 第一步,配置
--prefix=/安裝后的路徑 注意這基本是所有安裝程序的通用的配置屬性
輸入命令
--prefix=/安裝后的路徑 注意這基本是所有安裝程序的通用的配置屬性
輸入命令
.
/configure
--prefix=
/usr/local/nginx-mytest
接下來會報錯 如下
./configure: error: the HTTP rewrite module requires the PCRE library.
You can either disable the module by using --without-http_rewrite_module
option, or install the PCRE library into the system, or build the PCRE library
statically from the source with nginx by using --with-pcre=<path> option.
咱們需要安裝一個這樣的環境對能繼續 . 根據上面的意思.咱們先安裝 pcre 再指定路徑 指定方法在上面就是 --with-pcre=<path>
6.安裝pcre.百度這個詞得到官網. 然后找到下載路徑如下
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 這里面有一些列表.咱們找到最新的即可 . 目前是
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz下載,解壓,編譯
6.安裝pcre.百度這個詞得到官網. 然后找到下載路徑如下
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/ 這里面有一些列表.咱們找到最新的即可 . 目前是
ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.39.tar.gz下載,解壓,編譯
mkdir
/temp
;
cd
/temp
;
wget
ftp
:
//ftp
.csx.cam.ac.uk
/pub/software/programming/pcre/pcre-8
.39.
tar
.gz
tar
zxvf pcre-8.39.
tar
.gz
到此得到了pcre的源碼路徑 為/temp/pcre-8.39
7.上一步得到安裝路徑/usr/local/pcre-8.39 接下來咱們從新編譯 nginx 注意別忘記 --with-pcre=<path>
7.上一步得到安裝路徑/usr/local/pcre-8.39 接下來咱們從新編譯 nginx 注意別忘記 --with-pcre=<path>
cd
/temp/nginx-1
.12.0
.
/configure
--prefix=
/usr/local/nginx-mytest
--with-pcre=
/temp/pcre-8
.39
發現完成
第二個命令就是 make 也就是編譯, 一般可以跟第三步一起執行,第三步是make install .所以我們得到命令
第二個命令就是 make 也就是編譯, 一般可以跟第三步一起執行,第三步是make install .所以我們得到命令
make
&&
make
install
接下來去/usr/local/nginx-mytest看看吧.安裝成功了