下载:
Nginx开源版
http://nginx.org/
Nginx plus 商业版
https://www.nginx.com
openresty
http://openresty.org/cn/
Tengine
http://tengine.taobao.org/
我用的是openresty
下载完后传到linux系统root用户家目录下
安装Nginx所需要的依赖:
1.安装gcc
yum install -y gcc
2.安装perl库
yum install -y pcre pcre-devel
3.安装zlib库
yum install -y zlib zlib-devel
安装Nginx
1.解压nginx-1.21.6.tar.gz
tar zxvf nginx-1.21.6.tar.gz
2.进入 nginx-1.21.6目录
cd ./nginx-1.21.6
3.编译安装
./configure --prefix=/usr/local/software/nginx
make
make install
安装成系统服务
创建服务脚本
vi /usr/lib/systemd/system/nginx.service
服务脚本内容
[Unit]
Description=nginx - web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/usr/local/software/nginx/logs/nginx.pid
ExecStartPre=/usr/local/software/nginx/sbin/nginx -t -c /usr/local/software/nginx/conf/nginx.conf
ExecStart=/usr/local/software/nginx/sbin/nginx -c /usr/local/software/nginx/conf/nginx.conf
ExecReload=/usr/local/software/nginx/sbin/nginx -s reload
ExecStop=/usr/local/software/nginx/sbin/nginx -s stop
ExecQuit=/usr/local/software/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
重新加载系统服务
systemctl daemon-reload
启动服务
systemctl start nginx.service
设置为开机启动
systemctl enable nginx.service