下载对应当前系统版本的nginx包(package)
# wget http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
建立nginx的yum仓库
rpm -ivh nginx-release-centos-7-0.el7.ngx.noarch.rpm
下载并安装nginx
# yum install nginx
启动nginx服务
systemctl start nginx
curl localhost //或者打开浏览器访问http://localhost/
nginx -h 查看安装版本
二、配置文件
1.由上面的步骤,我们看到配置文件放置在/etc/nginx/目录下:
主要配置文件:/etc/nginx/nginx.conf 内容如下图
扩展配置文件:/etc/nginx/conf.d/*.conf
配置nginx
打开/etc/nginx/conf.d/default.conf,如果不存在则创建
粘贴
server {
listen 80;
server_name server_domain_name_or_IP;
sudo nginx
sudo nginx -s reload