2
votes

start mysql container

$ docker run --name mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql

Connect to MySQL and manually create new database

$ docker run -it --link mysql:mysql --rm mysql sh -c 'exec mysql -h"$MYSQL_PORT_3306_TCP_ADDR" -P"$MYSQL_PORT_3306_TCP_PORT" -uroot -p"$MYSQL_ENV_MYSQL_ROOT_PASSWORD"'

link the database and start php container

$ docker run -d --link mysql:mysql --name myapp -v "$PWD":/var/www/html -p 80:80 php:5.6-apache

first question:

When access my php website: http://localhost/index.php, I got below error:

Fatal Error: Mysql is not supported in your PHP, recompile and try again.

Here is the configure command shows in phpinfo page, seems mysql module has been included in compile.

Configure Command './configure' '--with-config-file-path=/usr/local/etc/php' '--with-config-file-scan-dir=/usr/local/etc/php/conf.d' '--with-apxs2' '--disable-cgi' '--enable-mysqlnd' '--with-curl' '--with-openssl' '--with-readline' '--with-recode' '--with-zlib'

Are there anything missed in official php image?

second question:

When access http://localhost/info.php, I can see phpinfo page.

But it also shows database password in session "Environment":

MYSQL_ENV_MYSQL_ROOT_PASSWORD  my-secret-pw

and in session "PHP Variables"

_ENV["MYSQL_ENV_MYSQL_ROOT_PASSWORD"]     my-secret-pw

So how to hide the password in phpinfo()?

1
Thanks @MarkO'Connor, but this time, that's different. The password exposed to public via http phpinfo call.Bill
I had a good think about this one. The phpinfo page is useful for debugging but I can't think of a sensible reason to condone the exposure of a production system's internal state on a public URL. If you insist on going down this road there are other more complex alternatives, such as using a distributed configuration store like consul, etcd or zookeeper.Mark O'Connor

1 Answers

1
votes

I assume you're trying to run phplist in a docker environment.

The message you're seeing (Fatal Error: Mysql is not supported in your PHP, recompile and try again.) is a phplist error message hardcoded in both the ./admin/mysql.inc and ./admin/mysqli.inc files.

This message is displayed upon check for the mysql_connect and mysqli_connect functions being present. You are seeing this message because the functions are not present in your environment.

You have to find out what package offers this functionality and either install it on your docker image, or build a new docker image with this support present.

The official PHP docker image is based on Debian, which offers the php5-mysql package. This is not present in the docker image, so you install this package using apt-get, then use docker-php-ext-install, docker-php-ext-configure and docker-php-ext-enable to enable the mysql and mysqli extensions.