nginx安装

1.安装、

cd /usr/nginx
wget http://nginx.org/download/nginx-1.9.2.tar.gz
tar -xzvf nginx-1.9.2.tar.gz
cd /usr/nginx/nginx-1.9.2
./configure --prefix=/usr/local/nginx-1.9.2 --with-http_ssl_module --with-http_stub_status_module
make && make install

2.启动

#进入到安装后的目录下
cd /usr/local/nginx-1.9.2
ll
cd sbin/
./nginx

 3、开机自启动

3.1、建立服务文件

vim /usr/lib/systemd/system/nginx.service

填写内容

Description=nginx - high performance web server
After=network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
ExecStart=/usr/local/nginx-1.9.2/sbin/nginx -c /usr/local/nginx-1.9.2/conf/nginx.conf
ExecReload=/usr/local/nginx-1.9.2/sbin/nginx -s reload
ExecStop=/usr/local/nginx-1.9.2/sbin/nginx -s stop
[Install]
WantedBy=multi-user.target

3.2、命令

systemctl disable nginx.service 关闭开机自启
systemctl enable nginx.service 开启开机自启
systemctl status nginx.service 查看状态
systemctl restart nginx.service 重启服务
systemctl list-units --type=service 查看所有服务

4、nginx常用命令

# 启动
/usr/local/nginx-1.9.2/sbin/nginx -c /usr/local/nginx-1.9.2/conf/nginx.conf
# 停止
/usr/local/nginx-1.9.2/sbin/nginx -s stop
# 重载配置或重启
/usr/local/nginx-1.9.2/sbin/nginx -s reload

  

posted @ 2023-11-21 15:20  浅笑19  阅读(6)  评论(0编辑  收藏  举报