Centos 7 安装
安装环境
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
下载安装包并解压安装
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2
#配置编译选项
./configure --prefix=/usr/local/nginx/
#编译安装
make && make install
启动
我们安装后会在nginx-1.12.2外层目录下看到一个nginx的目录,进去,脚本启动
cd /usr/local/nginx/
./sbin/nginx #启动
./sbin/nginx -s reload #重启
./sbin/nginx -s stop #关闭
./sbin/nginx -t #测试配置文件是否正确
我们也可以将Nginx配置成服务进行启动
vim /lib/systemd/system/nginx.service
把以下内容复制进去
[Unit]
Description=nginx
After=network.target
[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true
[Install]
WantedBy=multi-user.target
#执行(如有报错按人家提示来)
systemctl daemon-reload #如果是第一次运行,需要开启保护模式加载
systemctl start nginx
Centos 8 安装
dnf install nginx
nano /etc/nginx/conf.d/odoo13.conf
systemctl start nginx
systemctl enable nginx
systemctl status nginx