工具
VMware版本号 : 12.0.0
CentOS版本 : 7.0
一、修改 yum 源
[root@localhost ~]# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm [root@localhost ~]# rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm [root@localhost ~]# rpm -Uvh http://dev.MysqL.com/get/MysqL57-community-release-el7-9.noarch.rpm
Webtatic:https://webtatic.com
MysqL:https://dev.mysql.com/downloa...
二、安装 Nginx、MysqL、PHP
[root@localhost ~]# yum -y install Nginx [root@localhost ~]# yum -y install MysqL-community-server [root@localhost ~]# yum -y install PHP70w-devel PHP70w.x86_64 PHP70w-cli.x86_64 PHP70w-common.x86_64 PHP70w-gd.x86_64 PHP70w-ldap.x86_64 PHP70w-mbstring.x86_64 PHP70w-mcrypt.x86_64 PHP70w-pdo.x86_64 PHP70w-MysqLnd PHP70w-fpm PHP70w-opcache PHP70w-pecl-redis PHP70w-pecl-mongo
三、配置
1、配置 MysqLMysqL
安装完成之后,在 /var/log/MysqLd.log
文件中给 root
生成了一个默认密码
通过下面的方式找到root 默认密码
,然后登录 MysqL
进行修改:
[root@localhost ~]# systemctl start MysqLd # 启动 MysqL [root@localhost ~]# grep 'temporary password' /var/log/MysqLd.log # 查找默认密码 2017-04-10T02:58:16.806931Z 1 [Note] A temporary password is generated for root@localhost: iacFXpWt-6gJ
[root@localhost ~]# MysqL -uroot -p'iacFXpWt-6gJ'
修改root 默认密码
:
MysqL> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyPass1!';
或者:
MysqL> set password for 'root'@'localhost'=password('123abc');
注
:MysqL5.7
默认安装了密码安全检查插件(validate_password)
,默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示 ERROR 1819 (HY000): Your password does not satisfy the current policy requirements
错误
详见 MysqL 官网密码策略详细说明:https://dev.mysql.com/doc/ref...
配置默认编码为 utf8
:
修改 /etc/my.cnf
配置文件,在 [MysqLd]
下添加编码配置,配置完成后重启:
[root@localhost ~]# vim /etc/my.cnf [MysqLd] character_set_server=utf8 init_connect='SET NAMES utf8' [root@localhost ~]# systemctl restart MysqLd # 重启 MysqL
设置开机启动:
[root@localhost ~]# systemctl enable MysqLd
默认配置文件路径:
配置文件:/etc/my.cnf
日志文件:/var/log/MysqLd.log
服务启动脚本:/usr/lib/systemd/system/MysqLd.service
socket 文件:/var/run/MysqLd/MysqLd.pid
2、配置 Nginx
安装完成以后查看自己防火墙
是否开启,如果已开启,我们需要修改
防火墙配置
,开启 Nginx
外网端口访问。
[root@localhost ~]# systemctl status firewalld
如果显示 active (running)
,则需要调整防火墙规则的配置。
修改 /etc/firewalld/zones/public.xml
文件,在zone一节中增加
保存后重新加载 firewalld
服务:
[root@localhost ~]# vim /etc/firewalld/zones/public.xml <zone> ... <service name="Nginx"/> <zone> [root@localhost ~]# systemctl reload firewalld
[root@localhost ~]# vim /etc/Nginx/Nginx.conf
在 server {}
里添加:
location / { #定义首页索引文件的名称 index index.PHP index.html index.htm; } # PHP 脚本请求全部转发到 FastCGI处理. 使用FastCGI默认配置. location ~ .PHP$ { fastcgi_pass 127.0.0.1:9000; fastcgi_index index.PHP; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; include fastcgi_params; }
配置完成重启 Nginx
:
[root@localhost ~]# systemctl start Nginx # 启动 Nginx
设置开机启动:
[root@localhost ~]# systemctl enable Nginx
3、设置开机启动 PHP-fpm
:
[root@localhost ~]# systemctl enable PHP-fpm [root@localhost ~]# systemctl start PHP-fpm # 启动 PHP-fpm