我使用Hyper-V,4核和8GB RAM运行Docker for Windows,但我的PHP项目的页面加载大约为每页40秒。
我的设置使用自签名证书,但我认为问题与其他问题有关。
在我的docker构建期间,我收到以下警告:
--->在46329f96a79f中运行 重新启动Apache httpd Web服务器:apache2 [Mon Jun 11 09:17:26.151516 2018] [ssl:warn] [pid 23] AH01906:localhost:443:0服务器证书是CA证书(BasicConstraints:CA == TRUE!?) [Mon Jun 11 09:17:26.151605 2018] [ssl:warn] [pid 23] AH01909:localhost:443:0服务器证书不包含与服务器名称匹配的ID
由于非https页面的加载速度也很慢,我认为这是另一回事。
我的Docker文件如下
FROM php:5.6-apache
COPY server.crt /etc/apache2/ssl/server.crt
COPY server.key /etc/apache2/ssl/server.key
RUN docker-php-ext-install pdo pdo_mysql mysqli
RUN apt-get update &&\
apt-get install --no-install-recommends --assume-yes --quiet ca-certificates
curl git &&\
rm -rf /var/lib/apt/lists/*
RUN curl -Lsf 'https://storage.googleapis.com/golang/go1.8.3.linux-
amd64.tar.gz' | tar -C '/usr/local' -xvzf -
ENV PATH /usr/local/go/bin:$PATH
RUN go get github.com/mailhog/mhsendmail
RUN cp /root/go/bin/mhsendmail /usr/bin/mhsendmail
RUN echo 'sendmail_path = /usr/bin/mhsendmail --smtp-addr mailhog:1025' >
/usr/local/etc/php/php.ini
COPY ./ /var/www/html/
RUN echo "ServerName localhost" >> /etc/apache2/apache2.conf
RUN a2enmod rewrite
RUN a2enmod ssl
COPY dev.conf /etc/apache2/sites-enabled/dev.conf
RUN service apache2 restart
EXPOSE 80
EXPOSE 443
当我点击链接时,它会在浏览器栏中显示等待...大约40秒,但显示页面内容本身非常快
可能是DNS问题吗?
答案 0 :(得分:2)
我将使用PHP + Redis + MySQL + Nginx与您分享我的docker设置,看看它是否对您有用!
我的Dockerfile
FROM php:7.1-fpm
RUN apt-get update
RUN apt-get install -y zlib1g-dev \
libjpeg-dev \
libpng-dev \
libfreetype6-dev
# Add Microsoft repo for Microsoft ODBC Driver 13 for Linux
RUN apt-get update && apt-get install -y \
apt-transport-https \
&& curl https://packages.microsoft.com/keys/microsoft.asc | apt-key add - \
&& curl https://packages.microsoft.com/config/debian/8/prod.list > /etc/apt/sources.list.d/mssql-release.list \
&& apt-get update
# Install Dependencies
RUN ACCEPT_EULA=Y apt-get install -y \
unixodbc \
unixodbc-dev \
libgss3 \
odbcinst \
msodbcsql \
locales \
&& echo "en_US.UTF-8 UTF-8" > /etc/locale.gen && locale-gen
RUN pecl install pdo_sqlsrv-4.1.8preview sqlsrv-4.1.8preview \
&& docker-php-ext-enable pdo_sqlsrv sqlsrv
RUN ln -s /usr/lib/x86_64-linux-gnu/libsybdb.a /usr/lib/
RUN docker-php-ext-install pdo_mysql
RUN docker-php-ext-install zip
RUN mkdir -p /code
ENV HOME=/code
WORKDIR $HOME
USER root
COPY ./ $HOME
在这个docker文件中也有一个SQLServer连接插件(我已经集成了许多项目)。
现在我的docker-compose.yml
web:
container_name: your_web_container_name
image: nginx
ports:
- "80:80"
volumes:
- ./:/code
- ./host.conf:/etc/nginx/conf.d/default.conf
links:
- php:php
redis:
container_name: your_redis_container_name
image: redis
php:
container_name: your_php_container_name
build: ./
dockerfile: ./Dockerfile
volumes:
- ./:/code
links:
- db
- redis
db:
container_name: your_database_container_name
image: mysql:5.6
volumes:
- /var/lib/mysql
ports:
- "3306:3306"
environment:
- MYSQL_USER=docker
- MYSQL_DATABASE=docker
- MYSQL_ROOT_PASSWORD=docker
- MYSQL_PASSWORD=docker
希望对您有帮助。