安装版本:mysql8.0.16-php7.2.16 -nginx1.16
nginx安装
- 安装Nginx源
rpm -Uvh http://nginx.org/packages/centos/7/noarch/RPMS/nginx-release-centos-7-0.el7.ngx.noarch.rpm
- 安装nginx
yum install -y nginx
- 启动nginx并设置开机自动运行
systemctl start nginx #启动,restart-重启,stop-停止
systemctl enable nginx #开机启动
安装PHP
- 安装源
rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
- 搜索是否存在PHP72w
yum search php72w
3.安装所需扩展
yum install php72w.x86_64 php72w-fpm.x86_64 php72w-cli.x86_64 php72w-common.x86_64 php72w-gd.x86_64 php72w-ldap.x86_64 php72w-mbstring.x86_64 php72w-mcrypt.x86_64 php72w-mysql.x86_64 php72w-pdo.x86_64 php72w-pecl-redis.x86_64 php72w-devel php72w-pear
- 启动php并设为开机启动
systemctl start php-fpm #启动,restart-重启,stop-停止
systemctl enable php-fpm #开机启动
配置nginx监听php-fpm
- copy 一份/etc/nginx/conf.d/default.conf 文件
cp default.conf my.conf
- 修改my.conf配置如下
location / {
root /data;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /data;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
配置过程中遇到的报错
2019/05/03 12:20:12 [error] 2600#2600: *5 "/data/index.php" is forbidden (13: Permission denied), client: 10.0.2.2, server: my.nginx.cn, request: "GET / HTTP/1.1", host: "my.nginx.cn"
Connection closing...Socket close.
百度得到解决方案:具体原因就是服务器的SELinux设置为了开启(enabled)状态。
#直接行下面的命令:
setenforce 0
#这种方法我没有尝试,不知道有效性。
vim /etc/selinux/config
#将配置文件中的SELINUX=enforcing修改为SELINUX=disabled即可,修改完成后需要重启下机器。
#这种方法应该是有效的,至少在我的机器中是通过该方式解决了问题。
#借鉴网站:https://blog.csdn.net/hbysj/article/details/80615330
安装mysql
- 官方安装文档
http://dev.mysql.com/doc/mysql-yum-repo-quick-guide/en/
- 下载rpm包
wget https://dev.mysql.com/get/mysql80-community-release-el7-1.noarch.rpm
- 安装源
rpm -Uvh mysql80-community-release-el7-1.noarch.rpm
- 安装mysql服务端
yum install mysql-community-server
- 启动mysql
systemctl start mysqld.service
systemctl enable mysqld
- 获取临时密码
[root@localhost ~]# grep 'temporary password' /var/log/mysqld.log
2019-05-03T12:58:47.220498Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: jI!:dTges0?#
- 修改密码
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'root';
ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
#解决方法
#修改两个全局变量的参数
set global validate_password.policy=0;
set global validate_password.length=1;
#修改密码
ALTER USER 'root'@'localhost' IDENTIFIED BY '123456789';
- 授权其他客户机登录
use mysql;
select host,user,authentication_string,plugin from user;
update user set host = "%" where user = "root";
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456789';