nginx yum 安裝 for CentOS
編譯自:
http://nginx.org/en/linux_packages.html
為 RHEL/CentOS 設置 yum 倉庫,使 Linux 可自動升級 nginx。
預編譯的“stable”版程序包
創建 /etc/yum.repos.d/nginx.repo 文件,內容如下:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/gpgcheck=0
enabled=1
根據自己的Linux發行版,將 “OS” 替換為 “rhel” 或者 “centos”,
根據 5.x, 6.x, 7,x 版本,將 “OSRELEASE” 替換為 “5”, “6”, or “7”。
比如 CentOS:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
預編譯的“mainline”版程序包
創建 /etc/yum.repos.d/nginx.repo
文件,內容如下:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/OS/OSRELEASE/$basearch/
gpgcheck=0
enabled=1
根據自己的Linux發行版,將 “OS” 替換為 “rhel” 或者 “centos”,
根據 5.x, 6.x, 7,x 版本,將 “OSRELEASE” 替換為 “5”, “6”, or “7”。
比如 CentOS:
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/centos/$releasever/$basearch/
gpgcheck=0
enabled=1
編譯配置參數
預編譯程序包的 configure 參數:
--prefix=/etc/nginx
--sbin-path=/usr/sbin/nginx
--conf-path=/etc/nginx/nginx.conf
--error-log-path=/var/log/nginx/error.log
--http-log-path=/var/log/nginx/access.log
--pid-path=/var/run/nginx.pid
--lock-path=/var/run/nginx.lock
--http-client-body-temp-path=/var/cache/nginx/client_temp
--http-proxy-temp-path=/var/cache/nginx/proxy_temp
--http-fastcgi-temp-path=/var/cache/nginx/fastcgi_temp
--http-uwsgi-temp-path=/var/cache/nginx/uwsgi_temp
--http-scgi-temp-path=/var/cache/nginx/scgi_temp
--user=nginx
--group=nginx
--with-http_ssl_module
--with-http_realip_module
--with-http_addition_module
--with-http_sub_module
--with-http_dav_module
--with-http_flv_module
--with-http_mp4_module
--with-http_gunzip_module
--with-http_gzip_static_module
--with-http_random_index_module
--with-http_secure_link_module
--with-http_stub_status_module
--with-http_auth_request_module
--with-threads
--with-stream
--with-stream_ssl_module
--with-http_slice_module
--with-mail
--with-mail_ssl_module
--with-file-aio
--with-http_v2_module
--with-ipv6
main nginx 程序包編譯了不要求額外庫依賴的所有模塊。
動態模塊
從 nginx 1.9.11 版開始,nginx 開始支持動態模塊。目前編譯為獨立動態模塊的如下:
nginx-module-geoip
nginx-module-image-filter
nginx-module-njs
nginx-module-perl
nginx-module-xslt
如何加載動態模塊:
Syntax: load_module file;
Default: —
Context: main
This directive appeared in version 1.9.11.
Loads a dynamic module.
Example:
load_module modules/ngx_mail_module.so;
Signatures 簽名
RPM 程序包使用數字簽名來驗證下載的程序包的完整性及是否被改動。
下載 http://nginx.org/keys/nginx_signing.key ,然后:
sudo rpm --import nginx_signing.key
因為我們的 PGP key 和程序包位于同一個服務器,所以它們都可被信任。
我們強烈建議驗證 PGP key 的可靠性和真實性。
PGP 有一個 “Web of Trust” 概念,具體可參考:
我們的 keys 擁有足夠多的簽名,它們的可靠性相對來說容易驗證。
版權信息:
本文編譯自 nginx.org ,遵循其原來的 licence 聲明: 2-clause BSD-like license