测试环境=硬件+软件+网络+数据准备+测试工具
 省略在VMware虚拟机安装CentOS7系统过程。
安装Apache
1.安装Apache
 yum -y install httpd![[外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传(img-ZxU6LPv2-1651645450669)(https://img-blog.csdnimg.cn4887c574f27e462ebbb6148244fabd03.png)]](https://file.cfanz.cn/uploads/png/2022/05/04/11/48DO7b7306.png)
 2.设置防火墙
 添加防火墙:firewall-cmd --zone=public --add-port=80/tcp --permanent
 查看防火墙:firewall-cmd --zone=public --query-port=80/tcp
 防火墙重载:firewall-cmd --reload
 
 3.查看虚拟机ip
 查看ip地址:ip addr
 4.验证Apache服务
 浏览器访问ip地址
 
安装PHP
1.配置yum源
 添加源:
 yum install epel-release
 rpm -ivh http://rpms.famillecollet.com/enterprise/remi-release-7.rpm
 
 2.安装
 yum --enablerepo=remi install php74-php
 
3.安装所需组件
 安装组件:yum --enablerepo=remi install php74-php php74-php-gd php74-php-xml php74-php-sockets php74-php-session php74-php-snmp php74-php-mysql
 
 4.创建phpinfo文件
 打开/var/www/html/文件:cd /var/www/html/
 
 编写文件:echo '<php pgpinfo();?> ’ > /var/www/html/index.php
 
 5.重启
 重启:systemctl restart httpd
 6.验证Apache解析PHP
 浏览器访问ip地址/index.php
 
 (在过程中可能会遇到页面显示空白问题:可能index.php没有编写成功,可以用vim命令手动编写)
安装Mariadb
1.yum安装Mariadb
 安装:yum -y install mariadb mariadb-server
 
 启动:systemctl start mariadb
 
 2.数据库安全设置
 mysql_secure_installation
 
 3.数据库设置
 登录数据库:mysql -u root -p
 
查看用户访问数据库:select User,host from mysql.user;
 
 创建远程访问:
 create user root@‘%’ identified by ‘123456’;
 grant all privileges on . to root@‘%’ with grant option;
 
 (在创建时出现:ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ‘%‘ identified by ‘123456‘ with grant option’ at line 1,原因是grant all privileges on . to ‘root‘@‘%‘ identified by ‘123456‘ with grant option只适用于mysql8.0之前的版本)
刷新:flush privileges;
 
 4.远程访问测试
 
 (连接过程中报错,查看虚拟机3306端口是否开启,过程如下:
 1.查看3306端口是否开启:firewall-cmd --zone=public --query-port=3306/tcp
 2.开启3306端口:firewall-cmd --zone=public --add-port=3306/tcp --permanent
 3.重启防火墙:firewall-cmd --reload
 
)










