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

步骤一 安装Apahce2.4.7

yum install -y httpd
httpd -v

步骤二 安装php5.6.40

先安装epel-release

yum -y install 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

image

步骤三 安装MySQL 5.6.44

1、卸载mariadb,否则安装mysql会出现冲突

执行命令

rpm -qa | grep mariadb

列出所有被安装的mariadb rpm 包;

执行命令

rpm -e --nodeps 包名称(比如:rpm -e --nodeps mariadb-libs-5.5.44-2.el7.centos.x86_64)

逐个将所有列出的mariadb rpm 包给卸载掉

然后

创建并编辑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

gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

注意:gpgcheck是GPG加密校验,官方文档中,值为1,但check会报错误,所以这里改为0跳过检查,对安装无影响。

同理,其他centos版本安装其他版本的mysql只需要改为对应的baseurl即可:

centos7安装mysql5.7:baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/7/$basearch/

centos6安装mysql5.6:baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/

centos6安装mysql5.7:baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/

3、安装

执行命令

sudo yum install mysql-community-server

4、启动

执行命令

sudo service mysqld start

5、改mysql 的root密码

mysqladmin -u root -p password 你的新密码

初始密码为空,直接按回车即可

Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6_第1张图片
image

步骤四 修改apahce默认的目录

vim /etc/httpd/conf/httpd.conf

Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6_第2张图片
image
vim /etc/httpd/conf.d/welcome.conf

Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6_第3张图片
image

步骤五 测试

cd /var/www/html
vim index.php

Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6_第4张图片
image

浏览器打开本机IP地址

Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6_第5张图片
image

你可能感兴趣的:(Centos7.5 yum安装php5.6+apache2.4.7+mysql5.6)