服务器之家:专注于服务器技术及软件下载分享
分类导航

Linux|Centos|Ubuntu|系统进程|Fedora|注册表|Bios|Solaris|Windows7|Windows10|Windows11|windows server|

服务器之家 - 服务器系统 - Centos - CentOS7服务器中apache、php7以及mysql5.7的安装配置代码

CentOS7服务器中apache、php7以及mysql5.7的安装配置代码

2022-02-19 19:262cto Centos

这篇文章主要介绍了CentOS7服务器中apache、php7以及mysql5.7的安装配置代码,需要的朋友可以参考下

CentOS7服务器中apache、php7以及mysql5.7的配置代码如下所示:

?
1
2
yum upgrade
yum install net-tools

安装apache

?
1
2
3
4
5
6
7
8
9
10
11
12
关闭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

?
1
2
3
4
5
添加源
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
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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

延伸 · 阅读

精彩推荐
  • CentosCentos 7开启网卡自动获取IP的详细方法

    Centos 7开启网卡自动获取IP的详细方法

    本篇文章主要介绍了Centos 7开启网卡自动获取IP的详细方法,小编觉得挺不错的,现在分享给大家,也给大家做个参考。一起跟随小编过来看看吧...

    凌锋8972021-12-29
  • CentosCentOS 6.6实现永久修改DNS地址的方法

    CentOS 6.6实现永久修改DNS地址的方法

    这篇文章主要介绍了CentOS 6.6实现永久修改DNS地址的方法,涉及针对CentOS配置文件的相关设置技巧,具有一定参考借鉴价值,需要的朋友可以参考下 ...

    Linux社区4472020-08-21
  • CentosCentOS下Uptime命令详解

    CentOS下Uptime命令详解

    在Linux下,我们可以使用uptime命令,而且此命令不必使用root权限。uptime命令在系统中已经默认安装了。今天小编为大家带来的是CentOS下Uptime命令详解;希望...

    CentOS之家11482019-06-19
  • Centoscentos 安装与操作方法

    centos 安装与操作方法

    这篇文章主要介绍了centos 安装与操作方法,需要的朋友可以参考下...

    centos之家5272019-07-11
  • CentosCentos7运用/dev/shm进行网站优化

    Centos7运用/dev/shm进行网站优化

    这篇文章主要介绍了LINUX中Centos7运用/dev/shm进行网站优化相关知识点,对此有兴趣的朋友参考学习下。...

    彬菌9912022-03-02
  • CentosCentOS7设置日期和时间方法以及基本概念介绍

    CentOS7设置日期和时间方法以及基本概念介绍

    这篇文章主要介绍了CentOS7设置日期和时间方法以及基本概念介绍,本文讲解使用CentOS7中的新命令timedatectl设置日期时间方法,需要的朋友可以参考下 ...

    CentOS之家6522019-09-19
  • CentosCentOS6.5下Redis安装与配置详细步骤

    CentOS6.5下Redis安装与配置详细步骤

    本篇文章主要介绍了CentOS6.5下Redis安装与配置详细步骤,详细介绍redis单机单实例安装与配置,服务及开机自启动。有兴趣的可以了解一下。...

    飞流11452021-12-24
  • Centoscentos不小心删除/root目录该如何解决?

    centos不小心删除/root目录该如何解决?

    一些朋友最近在问小编centos不小心删除/root目录该如何解决?今天小编就为大家分享centos不小心删除/root目录解决办法;希望对大家会有帮助,有需要的朋友...

    脚本之家8022019-05-29