[记录]docker下的问题处理 | 祭夜博客
  • 欢迎光临,这个博客颜色有点多

[记录]docker下的问题处理

记录 msojocs 4年前 (2020-11-04) 1652次浏览 已收录 0个评论 扫描二维码
文章目录[隐藏]

php-apache 开启部分功能支持

ln -s /etc/apache2/mods-available/rewrite.load /etc/apache2/mods-enabled/rewrite.load
开启SSL支持,还需运行时映射443端口
ln -s /etc/apache2/mods-available/ssl.load /etc/apache2/mods-enabled/ssl.load
ln -s /etc/apache2/sites-available/default-ssl.conf /etc/apache2/sites-enabled/default-ssl.conf

GD库支持

# 如果之前启用了gd,需要先在php.ini文件中注释掉extension=gd.so并重启容器
# 进入php容器
docker exec -it <容器ID或容器名称> /bin/bash
# 容器中
# 可把软件源修改为国内某镜像站源,例如容器软件源/etc/apt/sources.list修改为中科大镜像站源,以stretch为例:
echo "deb http://mirrors.ustc.edu.cn/debian stable main contrib non-free" > /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian stable main contrib non-free" >> /etc/apt/sources.list \
    && echo "deb http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free" >> /etc/apt/sources.list \
    && echo "deb-src http://mirrors.ustc.edu.cn/debian stable-proposed-updates main contrib non-free" >> /etc/apt/sources.list \
    && rm -f /etc/apt/sources.list.d/* \
# 更新软件源
apt update
# 安装各种库
apt install -y libwebp-dev libjpeg-dev libpng-dev libfreetype6-dev
# 解压源码
docker-php-source extract
# 进入gd源码文件夹
cd /usr/src/php/ext/gd
# 准备编译
docker-php-ext-configure gd --with-webp-dir=/usr/include/webp --with-jpeg-dir=/usr/include --with-png-dir=/usr/include --with-freetype-dir=/usr/include/freetype2
# 编译安装
docker-php-ext-install gd
docker-php-ext-enable gd
# 检查扩展是否安装成功
php -m | grep gd
# 退出php容器终端
exit
# 重启php容器
……
# from https://www.colabug.com/2020/0110/6827989/

Permission denied错误

php遇到file_put_contents(***): failed to open stream: Permission denied
1:进入php目录下面

docker exec -ti php56 /bin/bash #进入php容器
chown -R www-data:www-data /var/www/html #给定权限
/var/www/html/ #是你代码存放的目录

2:在运行容器的时候,给容器加特权,及加上 –privileged=true 参数:
docker run -i -t -v /soft:/soft --privileged=true 686672a1d0cc /bin/bash

无法验证SSL请求

关于“SSL证书问题:无法获取本地颁发者证书”错误。显然,这适用于发送CURL请求的系统(并且没有接收请求的服务器)
1)从 https://curl.haxx.se/ca/cacert.pem 下载最新的cacert.pem
2)将以下行添加到php.ini(如果这是共享托管和您没有访问php.ini然后你可以添加到.user.ini在public_html)
curl.cainfo=/path/to/downloaded/cacert.pem
3)默认情况下,FastCGI进程将每隔300秒解析新文件(如果需要,您可以通过添加几个文件来更改频率,如这里建议的https://ss88.uk/blog/fast-cgi-and-user-ini -files-the-new-htaccess /)

计划任务

宿主:
crontab -e
* * * * * docker exec name php /path/to/html/?.php


祭夜の咖啡馆 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:[记录]docker下的问题处理
喜欢 (1)
[1690127128@qq.com]
分享 (0)
发表我的评论
取消评论
OwO表情
贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址