我是靠谱客的博主 孝顺星星,这篇文章主要介绍CentOS7+apache+php7+mysql5.7配置教程详解,现在分享给大家,希望可以做个参考。

复制代码
1
2
yum upgrade yum install net-tools

安装apache

关闭SELinux

编辑器打开 etc/selinux/config 文件,找到 SELINUX=enforcing 字段,将其改成 SELINUX=disabled ,并重启设备。

复制代码
1
yum -y install httpd mod_ssl

配置防火墙

复制代码
1
2
3
firewall-cmd --permanent --add-port=80/tcp firewall-cmd --permanent --add-port=443/tcp firewall-cmd --reload

开机启动

复制代码
1
2
systemctl start httpd systemctl enable httpd

终端输入如下指令检查httpd的运行状态

复制代码
1
sudo systemctl status httpd

安装PHP7

添加源

复制代码
1
2
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

安装

复制代码
1
yum install php70w

安装mysql5.7

1.安装wget

复制代码
1
yum -y install wget

2.安装源

复制代码
1
2
wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm rpm -ivh mysql57-community-release-el7-8.noarch.rpm

3.安装mysql

复制代码
1
yum install mysql-server

4.启动mysql服务  

复制代码
1
systemctl start mysqld

5.查看MySQL的启动状态   

复制代码
1
systemctl status mysqld

6.开机启动  

复制代码
1
2
systemctl enable mysqld systemctl daemon-reload

7.修改root本地登录密码

    查找mysql生成的随机密码  

复制代码
1
2
grep 'temporary password' /var/log/mysqld.log mysql -uroot -p

    修改密码,注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误

复制代码
1
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';

8.配置默认编码为utf8

    修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置   

复制代码
1
2
3
[mysqld] character_set_server=utf8 init_connect='SET NAMES utf8'

9.配置mysql远程连接

复制代码
1
2
3
4
mysql -uroot -p use mysql; Grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option; flush privileges;

然后用以下命令查看哪些用户和host可以访问,%代表任意ip地址

复制代码
1
select user,host from user;

防火墙添加3306端口

复制代码
1
2
firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload

10.mysql忘记密码

1.修改MySQL的配置文件(默认为/etc/my.cnf),在[mysqld]下添加一行skip-grant-tables

2.service mysqld restart后,即可直接用mysql进入

3.

复制代码
1
2
3
mysql> update mysql.user set authentication_string=password('123qwe') where user='root' and Host = 'localhost'; mysql> flush privileges; mysql> quit;

 将/etc/my.cnf文件还原,重新启动mysql:service mysql restart,这个时候可以使用mysql -u root -p'123qwe'进入了

 mysql>SET PASSWORD = PASSWORD('newpasswd'); 设置新密码

总结

以上所述是小编给大家介绍的CentOS7+apache+php7+mysql5.7配置教程详解,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!

最后

以上就是孝顺星星最近收集整理的关于CentOS7+apache+php7+mysql5.7配置教程详解的全部内容,更多相关CentOS7+apache+php7+mysql5内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(131)

评论列表共有 0 条评论

立即
投稿
返回
顶部