1、配置epel源
[root@localhost ~]# cd /etc/yum.repos.d/
[root@localhost yum.repos.d]# wget -O /etc/yum.repos.d/epel-7.repo http://mirrors.aliyun.com/repo/epel-7.repo
--2017-12-01 17:08:56-- http://mirrors.aliyun.com/repo/epel-7.repo
Resolving mirrors.aliyun.com (mirrors.aliyun.com)... 180.163.159.88, 180.163.159.87, 180.163.159.84, ...
Connecting to mirrors.aliyun.com (mirrors.aliyun.com)|180.163.159.88|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1084 (1.1K) [application/octet-stream]
Saving to: ‘/etc/yum.repos.d/epel-7.repo’
100%[=====================================================================================================================>] 1,084 --.-K/s in 0s
2017-12-01 17:09:07 (111 MB/s) - ‘/etc/yum.repos.d/epel-7.repo’ saved [1084/1084]
[root@localhost yum.repos.d]# ll epel-7.repo
-rw-r--r--. 1 root root 1084 Nov 21 2014 epel-7.repo
2、查看nginx版本
[root@localhost ~]# yum info nginx

3、安裝nginx
[root@localhost ~]# yum -y install nginx
4、nginx目錄結構
配置文件: /etc/nginx
啟動腳本:/usr/lib/systemd/system/nginx.service
腳本配置文件:/etc/sysconfig/nginx
nginx命令:/usr/sbin/nginx
模塊文件:/usr/lib64/nginx/modules
說明文檔目錄:/usr/share/doc/
日志切割:etc/logrotate.d/nginx
日志文件:/var/log/nginx
默認主目錄:/usr/share/nginx/html/
5、啟動nginx服務
[root@localhost ~]# systemctl start nginx
[root@localhost ~]# systemctl status nginx
● nginx.service - The nginx HTTP and reverse proxy server
Loaded: loaded (/usr/lib/systemd/system/nginx.service; disabled; vendor preset: disabled)
Active: active (running) since Fri 2017-12-01 17:22:30 CST; 4s ago
Process: 2425 ExecStart=/usr/sbin/nginx (code=exited, status=0/SUCCESS)
Process: 2423 ExecStartPre=/usr/sbin/nginx -t (code=exited, status=0/SUCCESS)
Process: 2421 ExecStartPre=/usr/bin/rm -f /run/nginx.pid (code=exited, status=0/SUCCESS)
Main PID: 2428 (nginx)
CGroup: /system.slice/nginx.service
├─2428 nginx: master process /usr/sbin/nginx
└─2429 nginx: worker process
通過配置nginx repo倉庫也可以
1、配置nginx repo倉庫
[root@static ~]# vim /etc/yum.repos.d/nginx.repo
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
注意:
baseurl=http://nginx.org/packages/OS/OSRELEASE/$basearch/
Replace “OS” with “rhel” or “centos”, depending on the distribution used, and “OSRELEASE” with “6” or “7”, for 6.x or 7.x versions, respectively.
2、然后安裝nginx
[root@localhost ~]# yum -y install nginx
- 第一部分:Nginx Web服務
- 第一章: Nginx的初探
- 第二章:Nginx的安裝部署
- 第一節:在centos6上通過Yum安裝Nginx
- 第二節:在Centos7上通過Yum安裝nginx
- 第三節:編譯安裝Nginx服務
- 第四節: Nginx編譯參數詳解
- 第五節: Nginx的啟動腳本
- 第六節:Nginx的shell腳本安裝
- 第七節:nginx服務的平滑升級
- 第三章:Nginx服務基礎配置
- 第一節: 配置運行nginx服務器用戶
- 第二節:配置運行生成的worker processes進程數
- 第三節:配置Nginx進程PID存放路徑
- 第四節:定義MIME類型
- 第五節:自定義nginx的訪問日志
- 第六節:主配置段(main)常用的配置
- 第七節:http段(核心)常用的配置命令
- 第八節:配置nginx中的location段
- 第九節: 基于IP的訪問控制
- 第十節:基于用戶的訪問控制
- 第十一節:Nginx定義status狀態頁
- 第十二節:Nginx服務器Rewrite重寫
- 第十三節:Nginx服務配置防盜鏈
- 第十四節:nginx軟件的優點
- 第四章:Nginx服務器的優化配置
- 第一節:nginx.conf配置文件基本參數優化
- 第二節:fastcgi調優
- 第三節:Gzip調優
- 第四節:expires緩存調優
- 第五節:內核參數優化
- 第六節: Nginx之——413 修改上傳文件大小限制
- 第五章:Nginx虛擬主機的配置
- 第一節:基于名稱的虛擬主機
- 第二節:通過shell腳本添加虛擬主機
- 第六章:Nginx常用模塊指令詳解
- 第一節:ngx_http_realip_module
- 第二節:http_image_filter_module
- 第三節:tengine中配置consistent hash module
- 第四節:ngx_http_userid_module
- 第七章:Nginx服務器配置HTTPS訪問
- 第八章: Nginx服務器日志切割
- 第二部分:Nginx負載均衡反向代理服務
- 第一章:Nginx進階參數詳解
- 第一節:proxy_module參數詳解
- 第二節:upstream_module參數詳解
- 第四章:Nginx反向代理服務
- 第一節:Nginx反向代理配置參數詳解
- 第二節:Nginx反向代理服務配置案例
- 第三節:Nginx緩存
- 第四節: Nginx中fastcgi模塊
- 第五節:nginx+fastcgi實現動靜分離架構
- 第五章:Nginx負載均衡
- 第一節:ngx_http_upstream_module常見指令
- 第二節:調度方法
- 第三節:健康狀態檢查