nginx的简单安装

初始Nginx

nginx的安装

环境准备

yum -y install wget gcc-c++ ncurses ncurses-devel cmake make perl bison openssl openssl-devel gcc* libxml2 libxml2-devel curl-devel libjpeg* libpng* freetype*

安装编译

wget http://nginx.org/download/nginx-1.16.1.tar.gz
tar -xzf nginx-1.16.1.tar.gz
./configure --prefix=/usr/local/nginx 
make
make install

配置为systemd服务

绝对路径方式管理服务
/usr/local/nginx/sbin/nginx   启动服务
/usr/local/nginx/sbin/nginx -s reload  重新加载服务
/usr/local/nginx/sbin/nginx -s stop    停止服务

vim /usr/lib/systemd/system/nginx.service 
插入如下内容
[Unit]
Description=Nginx
After=network.target remote-fs.target nss-lookup.target
 
[Service]
Type=forking
WorkingDirectory=/usr/local/nginx
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
 
[Install]
WantedBy=multi-user.target

systemctl daemon-reload   重新加载
systemctl enable nginx      开机启动
systemctl start nginx      启动服务
systemctl stop nginx      停止服务
systemctl status nginx.service 查看状态
posted @ 2020-03-31 08:51  IT终结者  阅读(117)  评论(0编辑  收藏  举报