centos 6.8/7.3版本安装php5.6mysql5.7apache2.4(已亲测绝对能用教程)

时间:2022-04-29 17:29:15

一、安装apache

1.yum install httpd    提示:按Y即可   30秒钟后即可完成安装  

systemctl restart httpd.service  重启httpd apache服务

systemctl enable httpd.service  设置apache开启启动项


二、安装php5.6

1.检查当前安装的PHP包
yum list installed | grep php
如果有安装的PHP包,先删除他们
 yum remove php.x86_64 php-cli.x86_64 php-common.x86_64 php-gd.x86_64 php-ldap.x86_64 php-mbstring.x86_64 php-mcrypt.x86_64 php-mysql.x86_64 php-pdo.x86_64

2.Centos 下载php源

  rpm -Uvh http://mirror.webtatic.com/yum/el5/latest.rpm    ##CentOs 5.x
  rpm -Uvh http://mirror.webtatic.com/yum/el6/latest.rpm    ##CentOs 6.x
rpm -Uvh https://mirror.webtatic.com/yum/el7/epel-release.rpm   ##CentOs 7.X
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm

3.运行yum install(选择你想安装的php版本php5.5\php5.6\php7.0)
  yum install php55w.x86_64 php55w-cli.x86_64 php55w-common.x86_64 php55w-gd.x86_64 php55w-ldap.x86_64 php55w-mbstring.x86_64 php55w-mcrypt.x86_64 php55w-mysql.x86_64 php55w-pdo.x86_64
 
yum install php56w.x86_64 php56w-cli.x86_64 php56w-common.x86_64 php56w-gd.x86_64 php56w-ldap.x86_64 php56w-mbstring.x86_64 php56w-mcrypt.x86_64 php56w-mysql.x86_64 php56w-pdo.x86_64
注:如果想升级到5.6把上面的55w换成56w就可以了。


yum install 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-mysql.x86_64 php70w-pdo.x86_64

4.安装PHP FPM
yum install php55w-fpm 
yum install php56w-fpm 
yum install php70w-fpm


三、安装mysql

# 下载mysql源安装包
shell> wget http://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
# 安装mysql源
yum localinstall mysql57-community-release-el7-8.noarch.rpm
#检查mysql源是否安装成功
yum repolist enabled | grep "mysql.*-community.*"   
#安装mysql服务
yum install mysql-community-server
#查看mysql启动状态
systemctl status mysqld
#查看系统默认安装root密码
grep 'temporary password' /var/log/mysqld.log
#登录数据库权限
mysql -uroot -p
输入密码
#修改root默认自定义密码
ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPwd6!'; 
#启动mysql服务
systemctl restart mysqld
#开启远程登录数据库权限
GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'MyNewPwd6!' WITH GRANT OPTION;
#修改数据库字符集
vim /etc/my.cnf
[mysqld]
character_set_server=utf8
init_connect='SET NAMES utf8'
#重启数据库服务
systemctl status mysqld