Nginx編譯安裝:
第三方模塊
在nginx.org -------- wiki 找
--add-module= 添加
Nginx編譯安裝:
安裝開發環境
]# yum groupinstall "Development Tools" "Server Platfrom Development"
安裝組件
# yum install pcre-devel openssl-devel -y
編譯安裝
Tar -zxvf nginx.tgz
報錯:/configure: error: C compiler cc is not found
Yum install gcc
./configure --prefix=/usr/local/nginx --sbin-path=/usr/local/nginx/sbin/nginx --conf-path=/usr/local/nginx/conf/nginx.conf --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --pid-path=/var/run/nginx/nginx.pid --lock-path=/var/lock/nginx.lock --user=nginx --group=nginx --with-http_ssl_module --with-http_stub_status_module --with-http_gzip_static_module --http-client-body-temp-path=/var/tmp/nginx/client/ --http-proxy-temp-path=/var/tmp/nginx/proxy/ --http-fastcgi-temp-path=/var/tmp/nginx/fcgi/ --http-uwsgi-temp-path=/var/tmp/nginx/uwsgi --http-scgi-temp-path=/var/tmp/nginx/scgi --with-pcre
Make && make install
看unit文件
[Unit]
Description=The nginx HTTP and reverse proxy server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx.pid
# Nginx will fail to start if /run/nginx.pid already exists but has the wrong
# SELinux context. This might happen when running `nginx -t` from the cmdline.
# https://bugzilla.redhat.com/show_bug.cgi?id=1268621
ExecStartPre=/usr/bin/rm -f /run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
KillSignal=SIGQUIT
TimeoutStopSec=5
KillMode=process
PrivateTmp=true
[Install]
WantedBy=multi-user.target
添加啟動:
systemctl daemon-reload
mkdir -p /var/cache/nginx/client_temp
chown nginx.nginx /var/cache/nginx
cp /usr/local/nginx/sbin/nginx /usr/sbin/
Systemctl start nginx.service
自己編譯nginx 根據需求創建自己需要的rpm包
rpm -ivh nginx-1.10.2-1.el7.ngx.src.rpm
在root目錄下生成rpmbutild目錄
# vim nginx.spec 根據自己需要編譯
# rpmbuild -bb nginx.spec
yum install rpmdevtools
會生成一個新的rpm包
http://nginx.org/packages/
源碼編譯安裝的rpm包
先安裝後根據自己的需求編譯,生成新的rpm包
Nginx編譯安裝: