安装环境centos7.4 安装httpd2.4.6 php版本5.6.38 (有7.1 、7.2的版本这里安装5.6的) mysql版本5.7.22
1. #查看系统 uname -a
Linux localhost.localdomain 3.10.0-693.el7.x86_64 #1 SMP Tue Aug 22 21:09:27 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
2.检查当前安装的PHP包
yum list installed | grep php
把之前的删除 4个包都要删除
yum remove php php-cli php-common php-devel
同理 mysql 和apache一样有的话卸载
3.添加epel源
yum install epel-release rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
4、安装apache
yum install httpd
使用yum list命令查看可安装的包
5、安装php56
yum list php56* (你也可以安装php7)
yum install php56 (就可以自己安装了,自己解决依赖)
6、安装mysql
[root@localhost ~]# cd /usr/local/src/
[root@localhost src]# wget http://repo.mysql.com/mysql57-community-release-el7-8.noarch.rpm
[root@localhost src]# rpm -ivh mysql57-community-release-el7-8.noarch.rpm
[root@localhost src]# yum -y install mysql-server
配置 my.cnf vim /etc/my.cnf
datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock # Disabling symbolic-links is recommended to prevent assorted security risks symbolic-links=0 log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
启动mysql服务
service mysqld restart
查看密码 grep "password" /var/log/mysqld.log
用查看的密码登录数据库 修改root密码
alter user 'root'@'localhost' identified by 'Root!!2018';
flush privileges 刷新权限
也可以 直接再添加新用户
CREATE USER ‘root‘@‘%‘ IDENTIFIED BY ‘您的密码‘;
grant all on *.* to 'root001'@'%' identified by 'Root@@' with grant option;
增加root用户指定可以任意IP登录,如果想限制只能让指定IP登录请把%替换成IP地址