Docker 安装 Nginx(https://www.runoob.com/docker/docker-install-nginx.html)
Docker 安装 PHP(https://www.runoob.com/docker/docker-install-php.html)
注意:配置nginx.conf文件时
location ~ .php$ {
fastcgi_pass php:9000; //指的是容器名
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /www/$fastcgi_script_name;
include fastcgi_params;
}
docker 中安装PHP扩展(https://blog.csdn.net/bbwangj/article/details/81474915)
可以通过两种方式实现
1.pecl pdo_msql
方式二:
docker-php-ext-install pdo pdo_mysql
如果报 /usr/local/bin/docker-php-ext-enable: cannot create /usr/local/etc/php/conf.d/docker-php-ext-pdo_mysql.ini: Directory nonexistent
解决方案:
直接在/usr/local/etc/php目录下面新建 conf.d目录和对应的docker-php-ext-pdo_msql.ini文件
其中docker-php-ext-pdo_msql.ini的内容为:
extension=pdo_mysql.so