CentOS Linux 零碎应用 yum
装置的 Nginx 短少一些须要的模块,只能用编译的形式来解决,记录一下装置过程。
首先须要用 yum 装置零碎依赖:
sudo yum install -y gcc make \ pcre-devel perl-ExtUtils-Embed openssl-devel
而后下载 nginx 源码:
wget -c http://nginx.org/download/nginx-1.18.0.tar.gz
解压并进入源码目录并按本人的需要执行编译操作:
tar zxvf nginx-1.18.0.tar.gzcd nginx-1.18.0./configure --prefix=/usr/local/nginx \ --user=zzxworld \ --group=zzxworld \ --with-http_perl_module \ --with-http_ssl_module \ --with-http_v2_modulemakesudo make install
编译实现后,就能够应用 /usr/local/bin/bin/nginx
来治理 Nginx 了。不过更好的形式是应用 Systemd 服务。将 Nginx 接入 Systemd 也很简略,在 /usr/lib/systemd/system/ 目录创立一个 nginx.service 文件,内容如下:
[Unit]Description=The NGINX HTTP and reverse proxy serverAfter=syslog.target network-online.target remote-fs.target nss-lookup.targetWants=network-online.target [Service]Type=forkingExecStartPre=/usr/local/nginx/sbin/nginx -tExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx -s reloadExecStop=/usr/local/nginx/sbin/nginx -s quitPrivateTmp=true [Install]WantedBy=multi-user.target
而后就能够应用 systemctl
命令来治理 Nginx 了。