2.1 安装nginx
2.1.1
在这个时候我们需要安装依赖包
yum -y install pcre pcre-devel zlib zlib-devel openssl openssl-devel
2.1.2
下载并且解压到(/usr/local/src目录当中去)
cd /usr/local/src
wget http://nginx.org/download/nginx-1.12.2.tar.gz
tar -zxvf nginx-1.12.2.tar.gz
2.1.3 编译安装
cd nginx-1.12.2
./configure --prefix=/usr/local/nginx
make && make install
2.1.4添加账号
groupadd nginx
useradd -M -g nginx -s /sbin/nologin nginx
cd /usr/local/nginx/conf
编辑 vim nginx.conf
user nginx nginx;
2.1.5设置nginx为系统服务
vim /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 stop
PrivateTmp=true
[Install]
WantedBy=multi-user.target
2.1.6启动nginx
systemctl restart nginx
2.1.7在虚拟机中访问127.0.0.1
出现nginx的画面就是成功了
2.1.8如果需要在windos上看见
关闭防火墙
systemctl stop firewall.service
原文链接 : https://blog.csdn.net/qq_41183192/article/details/121988809
标签:sbin,编译,nginx,安装,NGINX,usr,1.12,2.1,local From: https://www.cnblogs.com/zjj1990/p/16836611.html