CentOS7服务器中apache、php7以及mysql5.7的安装配置代码
作者:mrr 时间:2023-11-19 02:14:52
CentOS7服务器中apache、php7以及mysql5.7的配置代码如下所示:
yum upgrade
yum install net-tools
安装apache
关闭SELinux
编辑器打开 etc/selinux/config 文件,找到 SELINUX=enforcing 字段,将其改成 SELINUX=disabled ,并重启设备。
yum -y install httpd mod_ssl
配置防火墙
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --reload
开机启动
systemctl start httpd
systemctl enable httpd
终端输入如下指令检查httpd的运行状态
sudo systemctl status httpd
安装PHP7
添加源
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
安装
yum install php70w
安装mysql5.7
1.安装wget
yum -y install wget
2.安装源
wget https://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
rpm -ivh mysql57-community-release-el7-8.noarch.rpm
3.安装mysql
yum install mysql-server
4.启动mysql服务
systemctl start mysqld
5.查看MySQL的启动状态
systemctl status mysqld
6.开机启动
systemctl enable mysqld
systemctl daemon-reload
7.修改root本地登录密码
查找mysql生成的随机密码
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错误
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4!';
8.配置默认编码为utf8
修改/etc/my.cnf配置文件,在[mysqld]下添加编码配置
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
9.配置mysql远程连接
mysql -uroot -p
use mysql;
Grant all on *.* to 'root'@'%' identified by 'root用户的密码' with grant option;
flush privileges;
然后用以下命令查看哪些用户和host可以访问,%代表任意ip地址
select user,host from user;
防火墙添加3306端口
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.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的安装配置代码,希望对大家有所帮助,如果大家有任何疑问请给我留言,小编会及时回复大家的。在此也非常感谢大家对脚本之家网站的支持!
来源:https://www.2cto.com/database/201710/688449.html
标签:centos7,apache,php7,mysql5.7
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
学习ASP.NET八天入门:第一天
2007-08-07 13:08:00
![](https://img.aspxhome.com/file/UploadPic/up/2007080714434946.jpg)
关于useSSL=false和true的区别及说明
2024-01-25 03:27:40
Python GUI自动化实现绕过验证码登录
2023-06-25 05:18:25
taro小程序添加骨架屏的实现代码
2024-04-19 11:04:04
Go json反序列化“null“的问题解决
2024-02-18 22:54:19
![](https://img.aspxhome.com/file/2023/5/110515_0s.jpg)
Python谱减法语音降噪实例
2023-07-26 05:19:55
Python定时爬取微博热搜示例介绍
2022-09-18 21:59:18
![](https://img.aspxhome.com/file/2023/0/118620_0s.png)
MySQL5.7.14下载安装图文教程及MySQL数据库语句入门大全
2024-01-25 08:56:18
![](https://img.aspxhome.com/file/2023/9/129909_0s.png)
Python 实现购物商城,含有用户入口和商家入口的示例
2023-09-26 11:39:46
我所理解的网页推广设计的几个要点
2011-01-25 12:37:00
![](https://img.aspxhome.com/file/UploadPic/20111/25/javascript-selectors3-23s.jpg)
使用Django框架中ORM系统实现对数据库数据增删改查
2024-01-28 03:25:50
![](https://img.aspxhome.com/file/2023/0/115180_0s.png)
PyQT5 QTableView显示绑定数据的实例详解
2023-09-09 19:40:40
![](https://img.aspxhome.com/file/2023/1/101121_0s.jpg)
mysql游标的原理与用法实例分析
2024-01-15 16:33:36
![](https://img.aspxhome.com/file/2023/1/129881_0s.png)
Python数据分析之绘制ppi-cpi剪刀差图形
2023-01-10 09:57:03
![](https://img.aspxhome.com/file/2023/5/120445_0s.webp)
获得当前数据库对象依赖关系的实用算法
2009-01-08 13:28:00
JS中数组重排序方法
2024-04-22 22:34:27
python使用正则表达式的search()函数实现指定位置搜索功能
2023-08-08 09:26:01
Python2.7编程中SQLite3基本操作方法示例
2023-11-14 04:13:32
人工智能自动sql优化工具--SQLTuning for SQL Server
2024-01-25 00:54:15
![](https://img.aspxhome.com/file/2023/2/86882_0s.jpg)
Python random模块的使用示例
2023-08-01 16:33:48