1.安装准备依赖lib库
yum install gcc-c++ pcre pcre-devel zlib zlib-devel openssl openssl-devel
安装Nginx
2.安装之前,检查一下是否已经安装有nginx
find -name nginx
如果系统已经安装了nginx,那么就先卸载
yum remove nginx
yum安装nginx
3.新建
/etc/yum.repos.d/nginx.repo
添加以下,以centos7为例
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/mainline/rhel/7/$basearch/
gpgcheck=0
enabled=1
rpm –import http://nginx.org/keys/nginx_signing.key
yum install nginx
/bin/systemctl status nginx.service
4.配置:
安装后,NGINX的网站目录位于:
/usr/share/nginx/html
NGINX的配置文件位于:
/etc/nginx/ nginx.conf
nginx -t 测试配置文件
nginx -v 查看相关版本