centos配置mysql以及安装phpmyadmin

2018-01-21  本文已影响0人  单曲_循环

环境:centos6.9 mysql5.7(community) httpd phpmyadmin(4.7.7)

检查mysql,httpd和phpmyadmin是否安装

[root@local ~]# rpm -qa | grep mysql
mysql-community-common-5.7.21-1.el6.i686
mysql-community-libs-5.7.21-1.el6.i686
mysql-community-client-5.7.21-1.el6.i686
mysql-community-server-5.7.21-1.el6.i686
[root@local ~]# rpm -qa | grep httpd
httpd-tools-2.2.15-60.el6.centos.6.x86_64
httpd-2.2.15-60.el6.centos.6.x86_64
[root@local ~l]# rpm -qa | grep phpmyadmin
[root@local ~]#

安装httpd
安装mysql(参考这篇文章https://www.jianshu.com/p/5cf4970c56b7)
安装phpmyadmin
这里只详细写下安装phpmyadmin的过程

[root@local ~]# wget https://files.phpmyadmin.net/phpMyAdmin/4.7.7/phpMyAdmin-4.7.7-all-languages.zip

解压

[root@local ~]# unzip phpMyAdmin-4.7.7-all-languages.zip

复制文件到http的目录下

[root@local ~]# mkdir /var/www/html/phpmyadmin
[root@local ~]# cp -rf * /var/www/html/phpmyadmin/

先测试httpd服务是否能够访问
在/va r/www/html 下面新建index.html 内容为test 然后重启httpd

[root@local html]# touch index.html
[root@local html]# 
[root@local html]# vim index.html 
[root@local html]# service httpd restart
停止 httpd:                                               [确定]
正在启动 httpd:httpd: apr_sockaddr_info_get() failed for local
httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName  [确定]
[root@local html]# 

在虚拟机外部访问虚拟机centos的ip地址
1,确保80端口对外开放
2,确保防火墙规则允许目的端口为80的入站

[root@local html]# 
[root@local html]# cd /etc/sysconfig/
[root@local sysconfig]# vim iptables
[root@local sysconfig]# 
[root@local sysconfig]# 
[root@local sysconfig]# 
[root@local sysconfig]# iptables -I INPUT -p tcp --dport 80 -j ACCEPT
[root@local sysconfig]# service iptables save
iptables:将防火墙规则保存到 /etc/sysconfig/iptables:     [确定]
[root@local sysconfig]# service iptables restart
iptables:将链设置为政策 ACCEPT:filter                    [确定]
iptables:清除防火墙规则:                                 [确定]
iptables:正在卸载模块:                                   [确定]
iptables:应用防火墙规则:                                 [确定]
[root@local sysconfig]# 
[root@local sysconfig]# 
[root@local sysconfig]# 
[root@local sysconfig]# 
[root@local sysconfig]# netstat -tunlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   
tcp        0      0 0.0.0.0:22                  0.0.0.0:*                   LISTEN      1276/sshd           
tcp        0      0 :::3306                     :::*                        LISTEN      2382/mysqld         
tcp        0      0 :::80                       :::*                        LISTEN      2729/httpd          
tcp        0      0 :::22                       :::*                        LISTEN      1276/sshd           
udp        0      0 0.0.0.0:68                  0.0.0.0:*                               1119/dhclient       
udp        0      0 0.0.0.0:847                 0.0.0.0:*                               1200/portreserve    
udp        0      0 0.0.0.0:647                 0.0.0.0:*                               1200/portreserve    
[root@local sysconfig]# 

配置并备份config.sample.inc.php文件

[root@local phpmyadmin]# cp config.sample.inc.php config.inc.php

注意config.sample.inc.php文件是配置备份文件起作用的是config.inc.php
配置如下(40行)

/* User used to manipulate with storage */
 $cfg['Servers'][$i]['controlhost'] = 'localhost';
 $cfg['Servers'][$i]['controlport'] = '3306';
 $cfg['Servers'][$i]['controluser'] = 'root';
 $cfg['Servers'][$i]['controlpass'] = '此处填写mysql密码';

然后访问ip/phpmyadmin/index.php
输入mysql的用户名和密码登录

可能出现的问题:
1,确保web环境完整(mysql+httpd+php)
2,确保php有mysql扩展
如何查看php信息:
/var/www/html下
touch index.php
内容如下:

<?php
echo phpinfo();

然后外部访问ip/index.php来查看php的信息

上一篇下一篇

猜你喜欢

热点阅读