#### **1.安裝**
① 更新安裝源(repo)
路徑:/etc/yum.repos.d
編輯(新增)nginx.repo文件
內容:
```
[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/7/$basearch/
gpgcheck=0
enabled=1
```
② 查看安裝源
yum list |grep nginx
③ 安裝
yum -y install nginx
④ 查看nginx版本
nginx -v(小寫)
⑤ 查看編譯參數
nginx -V(大寫)
⑥ 常用命令
service nginx start 開啟
service nginx restart 重啟
service nginx reload 重新載入
systemctl enable nginx 開機自啟
nginx -t 檢測nginx配置是否有問題
<br/>
#### **2.基礎站點配置**
```
server {
listen 80;
server_name 域名;
access_log /data/www/域名/log/access.log main;
root /data/www/域名/;
index index.html index.htm index.php;
ssl on;
#阿里云ssl證書
ssl_certificate /etc/nginx/conf.d/ssl/域名/cert-1540810922785_域名.crt;
ssl_certificate_key /etc/nginx/conf.d/ssl/域名/cert-1540810922785_域名.key;
ssl_session_timeout 5m;
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_prefer_server_ciphers on;
charset utf-8;
location / {
if (!-e $request_filename){
rewrite ^/(.*)$ /index.php/$1 last;
}
}
location ~ \.php {
root /data/www/域名/;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(.*)$; #增加這一句
fastcgi_param PATH_INFO $fastcgi_path_info; #增加這一句
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
```