Docker environment to build php development environment

docker environment installation

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

Pull the latest version of nginx mirror

docker pull nginx:latest

Instantiate image

docker run --name nginx -p 80:80 -v /web/nginx/html:/usr/share/nginx/html -v /web/nginx/conf/nginx.conf:/etc/nginx/nginx.conf -v /web/nginx/log:/var/log/nginx -d nginx

Browser access

http://192.168.112.136:8080/

Download php mirror

docker pull php:7.2

Generate instance

docker run --name php-test -v /usr/local/www:/www -d php:7.2

nginx.conf configuration

server {
    
    
    listen       80;
    server_name  localhost;

    location / {
    
    
        root   /usr/share/nginx/html;
        index  index.html index.htm index.php;
    }

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

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

Download the mysql mirror

docker pull mysql:5.7

Instantiate image

docker run -itd --name mysql-test -p 3309:3306 -e MYSQL_ROOT_PASSWORD=123456 mysql:5.7

Download redis mirror

docker run -itd --name redis-test -p 6379:6379 redis

Instantiate redis image

docker run -itd --name redis-test -p 6390:6379 redis

Enter docker

docker exec -it redis-test /bin/bash

Link redis client

redis-cli

Guess you like

Origin blog.csdn.net/qq_41526316/article/details/109960333