如何快速安裝方向盤套,mac安裝nginx

下面介紹一下Centos下安裝Nginx的方法
Nginx的官網:***/,Nginx有三個版本:穩定版、開發版和歷史穩定版 。開發版更新快,包含最新的功能和bug修復,但同時也可能會出現新的bug 。開發版一旦更新穩定下來,就會被加入穩定版分支,穩定版更新較慢,但bug較少,所以生產環境優先選擇穩定版 。

一、下載Nginx安裝文件
目前最新穩定版:***/download/nginx-1.16.0.tar.gz
,可以先下載好安裝文件再通過ftp上傳的CentOS上,也可以在CentOS上直接通過wget命令下載,這里我將文件下載到了/home/software文件夾下,如下:

[root@localhost software]# pwd
/home/software
[root@localhost software]# wget ***/download/nginx-1.10.1.tar.gz
二、解壓安裝文件
[root@songguoliang software]# tar -xzvf nginx-1.10.1.tar.gz
三、執行configure命令
通過cd命令進入Nginx解壓文件目錄,執行該目錄下的configure命令,--prefix是打算將Nginx安裝在哪個目錄 。在執行configure命令之前,確保安裝了gcc、openssl-devel、pcre-devel和zlib-devel軟件庫(gzip模塊需要 zlib 庫,rewrite模塊需要 pcre 庫,ssl 功能需要openssl庫),也可以直接執行configure命令,根據提示缺少的軟件庫安裝,下面有缺少相應庫報的錯誤信息和安裝依賴庫的方法 。
為了方便,我們可以先安裝一下必須的軟件庫 。
[root@localhost software]# yum -y install gcc pcre-devel zlib-devel openssl-devel
出現類似下圖信息或提示之前已經安裝過等信息,說明已經安裝好依賴庫 。如下:
如何快速安裝方向盤套,mac安裝nginx


這樣事先安裝好依賴庫后,就不必看下面幾個處理錯誤的步驟了,直接進行configure,如下:
[root@localhost software]# cd nginx-1.10.1
[root@localhost nginx-1.10.1]# pwd
/home/software/nginx-1.10.1
[root@localhost nginx-1.10.1]# ./configure --prefix=/usr/local/nginx
1、如果報下面錯誤,說明還沒有安裝gcc編譯環境,可以通過yum在線安裝功能安裝gcc,重新執行configure命令 。
[root@localhost nginx-1.10.1]# ./configure --prefix=/usr/local/nginx
checking for OS
+ Linux 2.6.32-431.el6.x86_64 x86_64
checking for C compiler ... not found

./configure: error: C compiler cc is not found
在線安裝gcc:
[root@localhost nginx-1.10.1]# yum install gcc
2、如果報下面的錯誤,說明沒有安裝pcre-devel庫,通過yum在線安裝pcre后,重新執行configure命令 。
./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-devel庫:
[root@localhost nginx-1.10.1]# yum -y install pcre-devel
-y參數表示使用yum在線安裝時,如果需要用戶輸入Y/N時自動輸入Y 。
3、如果報下面的錯誤,說明沒有安裝zlib庫,安裝zlib庫后重新執行configure命令 。
./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.
在線安裝zlib庫:
[root@localhost nginx-1.10.1]# yum -y install zlib-devel
4、如果報以下錯誤,說明沒有安裝OpenSSL庫,安裝OpenSSL庫后重新執行configure命令 。
./configure: error: SSL modules require the OpenSSL library.
You can either do not enable the modules, or install the OpenSSL library
into the system, or build the OpenSSL library statically from the source
with nginx by using --with-openssl=<path> option.
在線安裝openssl庫:
[root@localhost nginx-1.10.1]# yum install openssl-devel
執行configure命令成功后,顯示如下信息:
checking for zlib library ... found
creating objs/Makefile

Configuration summary
+ using system PCRE library
+ OpenSSL library is not used
+ using builtin md5 code
+ sha1 library is not found
+ using system zlib library

nginx path prefix: "/usr/local/nginx"
nginx binary file: "/usr/local/nginx/sbin/nginx"
nginx modules path: "/usr/local/nginx/modules"
nginx configuration prefix: "/usr/local/nginx/conf"
nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
nginx pid file: "/usr/local/nginx/logs/nginx.pid"
nginx error log file: "/usr/local/nginx/logs/error.log"
nginx http access log file: "/usr/local/nginx/logs/access.log"
nginx http client request body temporary files: "client_body_temp"
nginx http proxy temporary files: "proxy_temp"
nginx http fastcgi temporary files: "fastcgi_temp"
nginx http uwsgi temporary files: "uwsgi_temp"
nginx http scgi temporary files: "scgi_temp"
四、執行make命令
[root@localhost nginx-1.10.1]# make
【如何快速安裝方向盤套,mac安裝nginx】五、執行make install命令
[root@localhost nginx-1.10.1]# make install
步驟四和步驟五可以合并執行如下命令,連接符 && 代表前面一個命令如果執行成功則繼續執行后面的命令,如果前面命令執行失敗則不再執行后面的命令 。而 || 表示如果前面的命令執行成功則不執行后面的命令,如果前面的命令執行失敗則繼續執行后面的命令
[root@localhost nginx-1.10.1]# make && make install
六、啟動Nginx服務
[root@localhost nginx-1.10.1]# cd /usr/local/nginx/
[root@localhost nginx]# ll
總用量 16
drwxr-xr-x. 2 root root 4096 10月 1 23:35 conf
drwxr-xr-x. 2 root root 4096 10月 1 23:35 html
drwxr-xr-x. 2 root root 4096 10月 1 23:35 logs
drwxr-xr-x. 2 root root 4096 10月 1 23:35 sbin
[root@songguoliang nginx]# ./sbin/nginx
通過瀏覽器訪問Nginx,顯示如下welcome to nginx!頁面便表示安裝成功:
如何快速安裝方向盤套,mac安裝nginx


nginx啟動、重啟、重新加載配置文件和平滑升級
nginx啟動、重啟、重新加載配置文件和平滑升級可以參考我博客 ***/gnail_oug/article/details/52754491

    推薦閱讀