PHP 配置文件


原文链接: PHP 配置文件

Php 设置时区

  1. 使用date_default_timezone_set()设置 date_default_timezone_set('PRC'); date_default_timezone_set('Asia/shanghai');
  2. ini_set('date.timezone','Asia/Shanghai');
  3. 修改错误级别配置(不推荐)
  4. 修改php.ini,显式设置date.timezone=PRC

Configure locale

RUN echo "LC_ALL=en_US.UTF-8" >> /etc/default/locale

Set my timezone

RUN ln -sf /usr/share/zoneinfo/UTC /etc/localtime

User password

RUN adduser homestead;
usermod -p $(echo secret | openssl passwd -1 -stdin) homestead

解决curl访问https的证书问题

RUN printf "[openssl]\n" | tee -a /etc/php/7.2/fpm/php.ini;
printf "openssl.cainfo = /etc/ssl/certs/ca-certificates.crt\n" | tee -a /etc/php/7.2/fpm/php.ini

RUN printf "[curl]\n" | tee -a /etc/php/7.2/fpm/php.ini;
printf "curl.cainfo = /etc/ssl/certs/ca-certificates.crt\n" | tee -a /etc/php/7.2/fpm/php.ini

log_errors = Off

RUN wget http://curl.haxx.se/ca/cacert.pem --directory-prefix=/etc/php/7.2/extras/ssl
RUN echo 'curl.cainfo = "ssl/cacert.pem"' >> /etc/php/7.2/apache2/php.ini
RUN echo 'curl.cainfo = "ssl/cacert.pem"' >> /etc/php/7.2/cli/php.ini
echo 'openssl.cafile = "/etc/ssl/certs/cacert.pem"' >> /etc/php5/cli/php.ini &&
echo 'openssl.cafile = "/etc/ssl/certs/cacert.pem"' >> /etc/php5/apache2/php.ini &&
echo 'curl.cainfo = "/etc/ssl/certs/cacert.pem"' >> /etc/php5/cli/php.ini &&
echo 'curl.cainfo = "/etc/ssl/certs/cacert.pem"' >> /etc/php5/apache2/php.ini &&

RUN sed -i 's/;date.timezone =/date.timezone = PRC/' /etc/php.ini
RUN sed -i 's/display_errors = Off/display_errors = On/' /etc/php.ini
RUN sed -i 's/error_reporting = E_ALL & ~E_DEPRECATED & ~E_STRICT/error_reporting = E_ALL/' /etc/php.ini
RUN mkdir -p /opt/cacert
COPY files/cacert.pem /opt/cacert
RUN sed -i 's|;curl.cainfo =|curl.cainfo = /opt/cacert/cacert.pem|' /etc/php.ini
```

`