centos7.6 安装nginx-1.14.2

一、安装所需依赖环境

yum -y install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel

二、下载nginx官方源码包

wget -c https://nginx.org/download/nginx-1.14.2.tar.gz

三、解压

tar -xzvf nginx-1.14.2.tar.gz

四、配置编译安装

1,手动创建nginx属主和nginx属组
groupadd nginx
useradd nginx -g nginx -s /sbin/nologin -M
2,配置编译安装
./configure
make && make install

五、启动nginx

/usr/local/nginx/sbin/nginx

六、nginx开机自启

加入systemctl
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
启动nginx
systemctl enable nginx && systemctl start nginx

posted @ 2019-04-10 19:21  飞到问情  阅读(853)  评论(0编辑  收藏  举报