我不鼓励您尝试将 phpMyAdmin 与 CodeIgniter 集成,而是建议您使用 Web 服务器指令来完成此操作。例如,我使用 Apache。当我在我的 Ubuntu 服务器上安装 PHPMyAdmin 时,我通常使用包管理器:
sudo apt-get install phpmyadmin
在 Ubuntu/Debian 上,此软件包安装通常会导致 phpmyadmin 源安装在 /usr/share/phpmyadmin 并在 /etc/apache2/conf 安装 apache conf 文件.d/phpmyadmin.conf。我只是删除了 conf 文件,然后将此指令添加到文件 /etc/apache2/sites-available/default-ssl.conf 这样 phpmyadmin 只能通过 HTTPS 访问。您可能需要在系统上编辑不同的 Web 配置文件。
# *adapted* from the phpmyadmin.conf installed
# by the debian package (/etc/apache2/conf.d/phpmyadmin.conf)
# NOTE this stuff represents a pretty significant juggling of the originally
# installed directives
# see http://www.linuxquestions.org/questions/showthread.php?p=4516840#post4516840
Alias /phpmyadmin /usr/share/phpmyadmin
<Directory /usr/share/phpmyadmin>
Options FollowSymLinks
Order allow,deny
allow from all
DirectoryIndex index.php
<IfModule mod_php5.c>
AddType application/x-httpd-php .php
php_flag magic_quotes_gpc Off
php_flag track_vars On
php_flag register_globals Off
php_value include_path .
</IfModule>
<IfModule mod_authn_file.c>
AuthType Basic
AuthName "phpMyAdmin"
AuthUserFile /var/www/.htpasswd
</IfModule>
Require valid-user
</Directory>
该指令指定一个别名,以便 https://example.com/phpmyadmin 的请求将从 /usr/share/phpmyadmin 中的文件得到处理。
它还指定必须进行身份验证才能访问这些文件,因此您必须从命令行使用 htpasswd 文件在文件 /var/www/.htpasswd 中创建用户/密码条目:
sudo htpasswd -c /var/www/.htpasswd some_user_name
该命令将提示您输入密码,它会截断并覆盖 /var/www/.htpassd 的内容。
差点忘记了! 更改 conf 文件时必须重新启动或重新加载 apache。
sudo service apache2 restart