CentOSLinux系统使用yum安装的Nginx缺少一些必需的模块,只能通过编译解决。记录安装过程。首先需要使用yum安装系统依赖:sudoyuminstall-ygccmake\pcre-develperl-ExtUtils-Embedopenssl-devel然后下载nginx源码:wget-chttp://nginx.org/download/nginx-1.18.0解压.tar.gz进入源码目录,根据需要编译:tarzxvfnginx-1.18.0.tar.gzcdnginx-1.18.0./configure--prefix=/usr/local/nginx\--user=zzxworld\--group=zzxworld\--with-http_perl_module\--with-http_ssl_module\--with-http_v2_modulemakesudomakeinstall编译后可以使用/usr/local/bin/bin/nginx来管理Nginx。但更好的方法是使用Systemd服务。将Nginx连接到Systemd也非常简单。在/usr/lib/systemd/system/目录下创建nginx.service文件,内容如下:[Unit]Description=TheNGINXHTTPandreverseproxyserverAfter=syslog.targetnetwork-online。目标remote-fs.targetnss-lookup.targetWants=network-online.target[Service]Type=forkingExecStartPre=/usr/local/nginx/sbin/nginx-tExecStart=/usr/local/nginx/sbin/nginxExecReload=/usr/local/nginx/sbin/nginx-sreloadExecStop=/usr/local/nginx/sbin/nginx-squitPrivateTmp=true[Install]WantedBy=multi-user.target然后就可以使用systemctl命令来管理Nginx了。
