1.安装epel
rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY*
yum -y install epel-release
2.安装MySQL/MariaDB
yum -y install mariadb-server mariadb //yum 安装MariaDB
systemctl start mariadb.service //启动
systemctl enable mariadb.service //设置为开机启动模式
mysql_secure_installation //MySQL账号设置
[root@server1 ~]# mysql_secure_installation
.......
Enter current password for root (enter for none): <--ENTER
OK, successfully used password, moving on...
Set root password? [Y/n] <--ENTER
New password: 输入你的密码
Re-enter new password: 再次输入你的密码
Password updated successfully!
Reloading privilege tables..
... Success!
Remove anonymous users? [Y/n] <--ENTER //删除匿名用户
... Success!
Disallow root login remotely? [Y/n] <--ENTER //禁止远程登陆
... Success!
Remove test database and access to it? [Y/n] <--ENTER //删除测试数据库并访问它
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!
Reload privilege tables now? [Y/n] <--ENTER //是否现在加载权限表
... Success!
Thanks for using MariaDB!
3.安装 Apache并打开防火墙端口
yum -y install httpd
systemctl start httpd.service
systemctl enable httpd.service
firewall-cmd --permanent --zone=public --add-service=http
firewall-cmd --permanent --zone=public --add-service=https
firewall-cmd --reload
4.安装PHP
yum -y install php
systemctl restart httpd.service
vi /var/www/html/info.php //在次目录下新建一个info.php文件
<?php phpinfo(); ?> //info.php文件里要写的内容 可通过访问 127.0.0.1/info.php 查看php的配置信息
5.安装PHP对MySQL的支持包
yum search php
yum -y install php-mysql
yum -y install php-gd php-ldap php-odbc php-pear php-xml php-xmlrpc php-mbstring php-snmp php-soap curl curl-devel
systemctl restart httpd.service
6.安装phpMyAdmin
yum install phpMyAdmin
vi /etc/httpd/conf.d/phpMyAdmin.conf //打开phpMyAdmin.conf文件并作如下修改
----------------------------------------------------------------------------
//在phpMyAdmin.conf文件中将下列代码注释掉,结果如下
#<Directory /usr/share/phpMyAdmin/>
# <IfModule mod_authz_core.c>
# # Apache 2.4
# <RequireAny>
# Require ip 127.0.0.1
# Require ip ::1
# </RequireAny>
# </IfModule>
# <IfModule !mod_authz_core.c>
# # Apache 2.2
# Order Deny,Allow
# Deny from All
# Allow from 127.0.0.1
# Allow from ::1
# </IfModule>
#</Directory>
//在上述注释掉内容下面添加以下内容:
<Directory /usr/share/phpMyAdmin/>
Options none
AllowOverride Limit
Require all granted
</Directory>
---------------------------------------------------------------------
vi /etc/phpMyAdmin/config.inc.php //打开config.inc.php文件,并作如下修改
----------------------------------------------------------------------------------
//一般默认为cookie 将其改为 http
$cfg['Servers'][$i]['auth_type'] = 'http'; // Authentication method (config, http
--------------------------------------------------------------------------------------
systemctl restart httpd.service //最后重启服务
7.最后登录http://127.0.0.1/phpmyadmin/可通过网页查看数据库