Centos7 yum安装php5.6 apache2.4.7 mysql5.6

时间:2022-01-30 02:36:32

简言:

使用yum搭建php、apache、mysql

环境:Centos7

 

一、安装Apache

yum install -y httpd
httpd -v  //查看版本信息

 

二、安装PHP5.6

yum -y install epel-release    //安装epel-release
rpm -Uvh https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
yum -y install php56w php56w-mysql php56w-gd libjpeg* php56w-ldap php56w-odbc php56w-pear php56w-xml php56w-xmlrpc php56w-mbstring php56w-bcmath 
yum -y install httpd php-gd56w php-intl56w php-mysql56w mod_ssl openssl mcrypt php5-mcrypt56w
yum -y install php56w-mcrypt php56w-soap php56w-intl  php56w-pdo
systemctl restart httpd.service
php -v  //查看版本信息

 

 

三、安装Mysql5.6

卸载mariadb,否则安装mysql会出现冲突
rpm -qa | grep mariadb
(rpm -e --nodeps 包名称(比如:rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64))
 
创建并编辑mysql-community.repo文件
执行命令:vi /etc/yum.repos.d/mysql-community.repo
[mysql56-community] name=MySQL 5.6 Community Server baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/7/$basearch/ enabled=1 gpgcheck=0    //gpgcheck是GPG加密校验,官方文档中,值为1,但check会报错误,所以这里改为0跳过检查,对安装无影响
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
sudo yum install mysql-community-server
sudo service mysqld start
mysqladmin -u root -p password 你的新密码

 

 

测试

 

cd /var/www/html/

vi index.php

<?php
    echo phpinfo();
?>

浏览器打开本机IP地址

Centos7 yum安装php5.6 apache2.4.7 mysql5.6

 

 访问成功!!!