当前位置:   article > 正文

零PHP基础搭建phpMyAdmin连接远程数据库_phpmyadmin 连接其它数据库

phpmyadmin 连接其它数据库

一为什么写这篇博文?

由于项目特殊限制,不能从本机直接远程连接到DB ,只能通过一台中间server去访问DB,所以想要从本机直接访问DB需要在中间server上搭建一个phpMyAdmin,然后客户端通过访问phpMyAdmin来查询和修改DB。

二前提条件

具备一定的linux操作系统基础知识。

三 环境与软件版本

名称版本
OSRedHat x86_64
PHP5.5.6
httpd2.2.26
mysql5.1.73
phpMyAdmin4.0.9

下载地址:

PHP       http://us2.php.net/downloads.php

httpd      http://httpd.apache.org/download.cgi

mysql    http://dev.mysql.com/downloads/mysql/5.1.html#downloads

四环境搭建

1.httpd安装

要安装httpd首先需要安装好 apr,apr-util等依赖包,这里我就不详细介绍了,这里假设你已经准备好了httpd的依赖包。

我的依赖包安装路径为/usr/local

下载好httpd-2.2.26.tar.gz

执行

tar xf httpd-2.2.26.tar.gz

cd httpd-2.2.26

./configure --enable-so

make

make install

httpd将会安装到默认路径/usr/local/apache2

进入

cd /usr/local/apache2/bin

执行

apachectl start

apachectl stop

如果不报错表示安装成功

httpd的配置文件

2.Mysql安装

下载 MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar

解压出来有很多rpm包

MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-community-debuginfo-5.1.73-1.rhel5.x86_64.rpm
MySQL-devel-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-embedded-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-shared-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-shared-compat-5.1.73-1.rhel5.x86_64.rpm
MySQL-test-community-5.1.73-1.rhel5.x86_64.rpm

执行 tar xf MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar

rpm -ivh MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm

rpm -ivh MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm

rpm -ivh *.rpm

默认会安装到/usr/bin;/usr/lib64/mysql/下面我们不需要配置mysql,只要安装好了就行了。php安装的时候需要用到/usr/lib64/mysql/下面的libmysqlclient.

3.PHP安装

下载php-5.5.6.tar.gz

执行

tar xf php-5.5.6.tar.gz

cd php-5.5.6.tar

 ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql=/usr/ --with-mysqli=/usr/bin/mysql_config  --enable-mbstring --with-mysql-sock=/var/lib/mysql/mysql.sock --enable-embedded-mysqli --with-libdir=lib64

make

make install

cp php.ini-development /usr/local/lib/php.ini

PHP默认安装到/usr/local下面

查看版本信息

php -v

查看php配置信息

php-config

配置httpd

vim /usr/local/apache2/conf/httpd.conf

如果没有下面这一段就加上

LoadModule php5_module        modules/libphp5.so
修改DocumentRoot

  1. DocumentRoot "/var/www/html/"
  2. #
  3. # This should be changed to whatever you set DocumentRoot to.
  4. #
  5. <Directory "/var/www/html/">
  6. #
  7. # Possible values for the Options directive are "None", "All",
  8. # or any combination of:
  9. # Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
  10. #
  11. # Note that "MultiViews" must be named *explicitly* --- "Options All"
  12. # doesn't give it to you.
  13. #
  14. # The Options directive is both complicated and important. Please see
  15. # http://httpd.apache.org/docs/2.2/mod/core.html#options
  16. # for more information.
  17. #
  18. Options Indexes FollowSymLinks
  19. #
  20. # AllowOverride controls what directives may be placed in .htaccess files.
  21. # It can be "All", "None", or any combination of the keywords:
  22. # Options FileInfo AuthConfig Limit
  23. #
  24. AllowOverride None
  25. #
  26. # Controls who can get stuff from this server.
  27. #
  28. Order allow,deny
  29. Allow from all
  30. </Directory>

在配置文件末尾加上

  1. <IfModule ssl_module>
  2. SSLRandomSeed startup builtin
  3. SSLRandomSeed connect builtin
  4. </IfModule>
  5. <FilesMatch \.php$>
  6. SetHandler application/x-httpd-php
  7. </FilesMatch>
  8. <FilesMatch "\.phps$">
  9. SetHandler application/x-httpd-php-source
  10. </FilesMatch>
保存关闭

wq

4.安装phpMyAdmin

下载phpMyAdmin-4.0.9-all-languages.zip

执行

unzip phpMyAdmin-4.0.9-all-languages.zip

cp phpMyAdmin-4.0.9-all-languages  /var/www/html/phpMyAdmin

cd /var/www/html/phpMyAdmin

cp config.sample.inc.php config.inc.php

修改config.inc.php的内容如下

  1. $cfg['blowfish_secret'] = 'a8b7c6d';
  2. /*
  3. * Servers configuration
  4. */
  5. $i = 0;
  6. /*
  7. * First server
  8. */
  9. $i++;
  10. /* Authentication type */
  11. $cfg['Servers'][$i]['auth_type'] = 'cookie';
  12. /* Server parameters */
  13. $cfg['Servers'][$i]['host'] = '10.123.255.1'; //your host ip
  14. $cfg['Servers'][$i]['connect_type'] = 'tcp';
  15. $cfg['Servers'][$i]['compress'] = false;
  16. /* Select mysql if your server does not have mysqli */
  17. $cfg['Servers'][$i]['port'] = '3306'; // MySQL port
  18. $cfg['Servers'][$i]['extension'] = 'mysql';
  19. $cfg['Servers'][$i]['AllowNoPassword'] = false;
  20. $cfg['Servers'][$i]['user'] = 'test'; // your mysql user
  21. $cfg['Servers'][$i]['password'] = 'test'; // use here your password
  22. $cfg['UploadDir'] = '';
  23. $cfg['SaveDir'] = '';

5.程序启动

做完以上步骤之后所有的程序安装完毕启动你的httpd访问http://yourhost:yourport/phpMyAdmin/index.php就可以看到如下画面

输入mysql的用户名密码可以进入一下画面











声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/不正经/article/detail/645672
推荐阅读
相关标签
  

闽ICP备14008679号