阿里雲 ECS CentOS7 編譯安裝nginx

1. 下載新版本nginx 

# curl -O http://nginx.org/download/nginx-1.16.1.tar.gz
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 1008k  100 1008k    0     0  11119      0  0:01:32  0:01:32 --:--:-- 12160

2. 解壓文件

# tar -xvf nginx-1.16.1.tar.gz

3. 安裝必須庫pcre-devel, zlib-devel,openssl-devel

# yum install pcre-devel zlib-devel openssl-devel -y

說明:

pcre-devel: 正則表達式庫

zlib-devel: gzip壓縮庫

openssl-devel: openssl開發庫,用於ssl證書支持

4. 進入源碼目錄,配置構建環境,開啓https支持

# cd nginx-1.16.1
# ./configure --with-http_ssl_module
...
creating objs/Makefile

Configuration summary
  + using system PCRE library
  + using system OpenSSL library
  + 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"

5. 編譯並安裝

# make && make install

6. 測試nginx配置文件

# vim /usr/local/nginx/conf/nginx.conf
(查看,修改配置)

# /usr/local/nginx/sbin/nginx -t

7. 啓動nginx

# /usr/local/nginx/sbin/nginx

8. 參看nginx 訪問日誌

# tail -f /usr/local/nginx/logs/access.log

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章