Use docker to quickly build laravel environment

Use docker to quickly build laravel environment

The laravel environment used in this article can also be the same as a php environment.
The final build is an environment of: nginx 1.3 + php 7.1 + composer + php-cli (artisan)
Here is the source address of the Dokcerfile for this environment: github.com/rainbowMore The
image has been uploaded to the docker hub official website

Text:
1. Preparations
-docker [Go to the Alibaba community to have a tutorial] -Set
up the Chinese source blog.csdn.net/hyzhou33550...

PS: The system I usually use is ubuntu16.04 server, and the mirroring system is also ubuntu16.04. Because the domestic system is centos, this article also uses centos 7.3 as a tutorial

I am using


image.png

Community version of 17.06.2-ce

Work flow refer to this picture


image.png

We now create a file container [if a server is distributed] to map the local files to the/data file in the docker container

docker run --name myapp-data -v/root/data:/data:rw -d rainbowmorel/data
 

Run composer command line

Execute the composer command line with the following command:

docker run --privileged=true --volumes-from myapp-data --rm rainbowmorel/composer
 

PS: But before running, remember to add the www folder to the folder mapped on your local machine, it will not appear

image.png image.png

Run artisan command line

The artisan command line runs in a similar way to the composer command line:

docker run --privileged=true --volumes-from myapp-data --rm rainbowmorel/artisan
 

If you think this command is very long, you can compare ~/.bashrc file to add alias

image.png

Remember to save source .bashrcit

image.png

Now enter mycomposer


image.png

see

Let's start to run the PHP environment

docker run --name

docker run --name myapp-php --privileged=true --volumes-from myapp-data -d rainbowmorel/phpfpm7
 

Below is run Nginx

docker run --name myapp-web --privileged=true --volumes-from myapp-data --link myapp-php:fpm -d -p 80:80 rainbowmorel/nginx
 
image.png

Just seeing these two is your usual operation: note that the mycomposer running here is mapped to the/data/www file of the container

mycomposer create-project laravel/laravel/data/www --prefer-dist
 
image.png

The latter is to enter nginx to configure

image.png image.png

then


image.png

then

image.png

If you find 403 because we haven't given it yet, then give www a 777 permission.