#### **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;
}
}
```