# 工作环境

- centos 7.6
- `yum update`

# Nginx

## 安装

`yum install nginx -y`

## 配置

修改 ` /etc/nginx/conf.d/default.conf`

```nginx
server {
    listen       80 default_server;
    # listen       [::]:80 default_server;
    server_name  _;
    root         /usr/share/nginx/html;

    # Load configuration files for the default server block.
    include /etc/nginx/default.d/*.conf;

    location / {
    }

    error_page 404 /404.html;
        location = /40x.html {
    }

    error_page 500 502 503 504 /50x.html;
        location = /50x.html {
    }

}
```

## 启动

```shell
#启动
nginx
#开机启动
chkconfig nginx on
#重新启动
service nginx restart
```

# Mysql

## 安装

```shell
#下载 mysql 5.7 的源：
curl -O https://repo.mysql.com//mysql57-community-release-el7-11.noarch.rpm
#安装mysql
yum localinstall mysql57-community-release-el7-11.noarch.rpm
#检查是否成功
yum repolist enabled | grep "mysql.*-community.*"
#更新GPG密钥
rpm --import https://repo.mysql.com/RPM-GPG-KEY-mysql-2022


#安装mysql
yum install mysql-community-server
#检查是否成功
yum list installed mysql-*
```

## 启动

```shell
#启动
systemctl start mysqld
#开机启动
systemctl enable mysqld
chkconfig mysqld on
```

## 登录

```shell
#查看初始密码
grep 'temporary password' /var/log/mysqld.log
#密码登录
mysql -uroot -p
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'ouczbs';
#ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
	set global validate_password_policy=0;
	set global validate_password_length=6;

```

## 错误

`ERROR 1819 (HY000): Your password does not satisfy the current policy requirements`
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
# PHP

## 安装

`yum install php php-fpm php-mysql -y`

## 启动

```shell
#启动
service php-fpm start
#查看端口
netstat -nlpt | grep php-fpm
#开机启动
chkconfig php-fpm on
```

# 配置

修改Nginx的配置，开启php-cgi，使之连接到php解析器

`/etc/nginx/conf.d/default.conf`

```nginx
server {
    listen 8000;
    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    location ~ \.php$ {
        root           /usr/share/php;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
        include        fastcgi_params;
    }
}
```

