CentOS7 安装Nginx
2019-01-07 本文已影响5人
王勇1024
1. 下载安装包
访问Nginx官网下载页面:http://nginx.org/en/download.html
wget http://nginx.org/download/nginx-1.12.2.tar.gz
2. 解压安装包
tar zxvf nginx-1.12.2.tar.gz
cd nginx-1.12.2/
3. 编译
./configure
4. 安装
make
sudo make install
5. 配置开机自启动
在目录/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
启动Nginx
sudo systemctl start nginx
查看Nginx状态
sudo systemctl status nginx
停止Nginx
sudo systemctl stop nginx
重新加载配置
sudo systemctl reload nginx