centos7 安装php环境

From:https://blog.csdn.net/qq_59536202/article/details/125053130

安装apache服务

yum install httpd

开启apache服务

systemctl start httpd

设为开机自启动

systemctl enable httpd

接下来安装php

yum install -y epel-release

rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm

yum –enablerepo=remi install -y php74-php

yum –enablerepo=remi install -y php74-php php74-php-gd php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql

yum install -y php74-php-fpm

运行并查看版本

php74 -v

添加开机自启动

systemctl enable php74-php-fpm

链接php文件

ln -s /opt/remi/php74/root/usr/bin/php /usr/bin/php

配置文件路径

vi /etc/opt/remi/php74/php.ini

memory_limit = 512M

安装wget

yum install wget

wget http://dev.mysql.com/get/mysql57-community-release-el7-9.noarch.rpm

rpm -ivh mysql57-community-release-el7-9.noarch.rpm

安装MySQL

yum install -y –nogpgcheck mysql-community-server

启动MySQL

systemctl start mysqld

查找默认密码

grep ‘temporary password’ /var/log/mysqld.log

冒号后面的就是密码

拿到登录密码登录mysql

修改密码 刷新权限

开启mysql远程访问并允许连接

use mysql;

更改host并刷新权限

在关闭防火墙的状态下,现在使用navicat工具就可以连接上centos的mysql了

如果有防火墙,开放3306端口

firewall-cmd –zone=public –add-port=3306/tcp –permanent

更新防火墙规则

firewall-cmd –reload

安装完毕