nginx安装
- nginx安装(centos)在线安装
- 下载nginx
- 下载地址:https://nginx.org/en/download.html
- 例如以1.22.1为例,下载地址:https://nginx.org/download/nginx-1.22.1.tar.gz
- 解压nginx压缩包
tar -zxvf nginx-1.22.0.tar.gz
- 批量执行安装命令
sudo yum install -y gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel sudo useradd -M -s /sbin/nologin nginx sudo ./configure --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --prefix=/usr/local/nginx --user=nginx sudo make && sudo make install
- 检查对应 nginx 默认安装文件夹是否安装成功
cd /usr/local/nginx/ ll
- 启动nginx
/usr/local/nginx/sbin/.nginx -c /usr/local/nginx/conf/nginx.conf
- 验证配置
cd /usr/local/nginx ./nginx -s reload
- 将nginx制作成服务
sudo vim /usr/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
- 给服务赋执行权限
chmod +x /lib/systemd/system/nginx.service
- 重新加载服务配置文件
sudo systemctl daemon-reload
- 手动启动nginx服务
sudo systemctl start nginx.service
- 设置开机启动(centos7)
sudo systemctl enable nginx.service
- 下载nginx