Docker built using the PHP + Nginx + Laravel development environment

Mirrored

Since the official php: 7.2.2-fpm-alpine3.7 image composer free, and will be dependent on a single composer php mirror image, so it should be added in php mirror composer.Dockerfile follows:

FROM php:7.2.2-fpm-alpine3.7
LABEL maintainer="php-composer Docker Maintainers <[email protected]>"

RUN php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');" && \
php composer-setup.php && \
php -r "unlink('composer-setup.php');" && \
mv composer.phar /usr/local/bin/composer && \
composer self-update

Generate Mirror

docker build -t bx-php:7.2.2-fpm-alpine3.7

Preparation configuration file:

My local profile for /data/server/conf/nginx/conf.d/member.conf

server {
    listen       80;
    server_name  localhost;

    location / {
        root   /app/public;
        index  index.php index.html index.htm;
        try_files $uri $uri/ /index.php?$query_string;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    location ~ \.php$ {
        fastcgi_pass   phpfpm:9000;
        fastcgi_index  index.php;
        fastcgi_param  SCRIPT_FILENAME  /app/public/$fastcgi_script_name;
        include        fastcgi_params;
    }
}

Run docker

Running a local data volume

docker run --name vc_member \
    -v /data/wwwroot/retail/member/src:/app \
    -v /data/server/conf/nginx/conf.d:/etc/nginx/conf.d \
    alpine:latest 

Execute php-fpm

docker run --name phpfpm -d \
--volumes-from vc_member \
bx-php:7.2.2-fpm-alpine3.7 

Phpfpm need to enter the container, modify some configuration and file permissions, and perform composer install / composer update and so on.
Note:
1. execution composer install, may be a "case of the root user can not use," you need to perform: Composer install --no-plugins --no-scripts
2. [very important] to enter phpfpm container: docker exec -it phpfpm sh then modify "listen = 127.0.0.1:9000" to "listen = 9000" or Rom PHP
3. nginx allow users to access: chown -R & lt WWW-Data: WWW-Data / App
4. impart storage write permission : chmod -R 755 / app / storage

Running nginx

docker run --name nginx -p 8080:80 -d \
--volumes-from vc_member \
--link phpfpm:php \
nginx:1.13.8-alpine

Such directly enter the URL can be opened.

Guess you like

Origin www.linuxidc.com/Linux/2019-08/160150.htm