yum安装
- 添加yum源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 安装nginx
yum install -y nginx
- 启动nginx
systemctl start nginx.service systemctl enable nginx.service
- 打开浏览器访问
源码安装
-
官网下载
wget http://nginx.org/download/nginx-1.18.0.tar.gz
-
安装
tar xvf nginx-1.18.0.tar.gz useradd -s /sbin/nologin -M nginx cd nginx-1.18.0 ./configure --prefix=/usr/local/nginx-1.18.0 --user=nginx --group=nginx --with-http_stub_status_module --with-http_ssl_module make && make install ln -s /usr/local/nginx-1.18.0 /usr/local/nginx
-
启动
/usr/local/nginx/sbin/nginx
-
添加到环境变量
vim /etc/bashrc export NGINX_HOME=/usr/local/nginx export PATH=$PATH:$NGINX_HOME/sbin