# 1. 安装PCRE
sudo apt install libpcre3-dev
# 2. 安装OpenSSL:
sudo apt install openssl
sudo apt-get install libssl-dev
# 3. 安装zlib:
sudo apt-get install ruby
sudo apt-get install zlib1g
sudo apt-get install zlib1g.devcd tools
wget https://openresty.org/download/openresty-1.25.3.2.tar.gz
tar -zxvf openresty-1.25.3.2.tar.gzcd openresty-1.25.3.2
./configure --user=nginx --group=nginx --prefix=/apps/openresty
make
make installcat >> /etc/profile <<EOF
export openresty_HOME=/apps/openresty
export PATH=\$PATH:\$openresty_HOME/binEOF
source /etc/profileopenresty -v# 设置开机自启
cat >> /usr/lib/systemd/system/nginx.service <<EOF
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
# 指定PID文件的路径,确保与Nginx配置中的路径一致
PIDFile=/apps/openresty/nginx/logs/nginx.pid
# 指定Nginx可执行文件的路径
ExecStartPre=/apps/openresty/nginx/sbin/nginx -t
ExecStart=/apps/openresty/nginx/sbin/nginx
# 重新加载Nginx配置时使用的命令
ExecReload=/bin/kill -s HUP $MAINPID
# 停止Nginx服务时使用的命令
ExecStop=/bin/kill -s QUIT $MAINPID
# 设置PrivateTmp为true,以确保每个服务有自己的临时空间
PrivateTmp=true
[Install]
WantedBy=multi-user.targetEOF
systemctl daemon-reload
systemctl enable nginx
systemctl start nginx