Before installing, first check to see if you have installed some of the lib libraries that nginx modules rely on, such as g++, gcc, pcre-devel, openssl-devel, and zlib-devel. Therefore, it is best to run the following commands one by one, the installed ones will prompt not to install, and the ones that are not installed or need to be updated will install and update:
yum install gcc-c++
yum -y install pcre pcre-devel
yum -y install zlib zlib-devel
yum -y install openssl openssl-devel
Download tengine-2.3.3
and headers-more-nginx-module-0.33
to the directory /opt/softwares
and decompress the software in the current directory via (tar zvxf xxxx
)
cd /opt/softwares/tengine-2.3.3
./configure --prefix=/opt/tengine --add-module=/opt/softwares/headers-more-nginx-module-0.33
make && make install
# Boot directory
/usr/lib/systemd/system
Set the system to boot the directory, so I put the files in the system directory.
vim /lib/systemd/system/nginx.service
[Unit]
Description=The nginx HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/tengine/logs/nginx.pid
ExecStartPre=/opt/tengine/sbin/nginx -t
ExecStart=/opt/tengine/sbin/nginx -c /opt/tengine/conf/nginx.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target
Modifying file permissions
chmod 745 nginx.service
Enable service
systemctl enable nginx.service
Disable service
systemctl disable nginx.service
View the current status of the service
systemctl status nginx.service
Stop the nginx service
systemctl stop nginx.service
Start the nginx service
systemctl start nginx.service
Restart the service nginx service
systemctl restart nginx.service
View all started services
systemctl list-units --type=service