1.前期准备
1.1 配置docker镜像加速器
配置docker镜像加速器,修改docker配置文件.
1.2 新增registry-mirrors项
{ "experimental": false, "debug": true, "registry-mirrors": [ "https://xxx.mirror.aliyuncs.com" ] }
|
1.3 免费申请阿里云docker镜像加速
免费申请阿里云docker镜像加速 点击申请
2.开始安装
2.1 步骤一: 下载代码
$ git clone https://github.com/52lu/docker-compose-server.git
$ docker-compose-server git:(main) ls README.md docker-compose.yml env-example kibana logstash mongo nginx rabbitmq solr bin elasticsearch grafana logs memcached mysql php-fpm redis workspace
|
2.2 步骤二: 配置文件
执行 cp env-example .env
修改配置文件内容
APP_CODE_PATH_HOST---> 你PHP项目所在的上级目录文件 DATA_PATH_HOST ---> 数据持久化位置,比如Mysql/Redis/Mongo产生的物理文件 DOCKER_HOST_IP ---> 修改成本地的IP(不修改的话,会出现无法捕获到断点情况)
|
2.3 步骤三: 配置nginx
配置目录: docker_php_env/nginx/sites/example.conf
server { charset utf-8; listen 80; server_name saaspro.com; root /var/www/saaspro/web; error_page 404 /404.html ; index index.php index.html; location / { try_files $uri $uri/ /index.php$is_args$args; } location ~ \.(js|css|png|jpg|gif|swf|ico|pdf|mov|fla|zip|rar)$ { try_files $uri =404; } location ~ \.php$ { include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass php-upstream; try_files $uri =404; } location ~ /\.(ht|svn|git) { deny all; } }
|
2.4 步骤四: 启动脚本
1. 脚本说明
文件位置: docker_php_env/bin/restart-php.sh
docker-compose down docker-compose build nginx php-fpm workspace docker-compose up -d nginx docker-compose ps
|
2. 启动脚本
chmod 777 bin/*
./bin/restart-php.sh
|
3. 启动结果
$ docker-compose ps Name Command State Ports ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- env_docker-in-docker_1 dockerd-entrypoint.sh Up 2375/tcp, 2376/tcp env_nginx_1 /docker-entrypoint.sh /bin ... Up 0.0.0.0:443->443/tcp, 0.0.0.0:80->80/tcp env_php-fpm_1 docker-php-entrypoint php-fpm Up 9000/tcp env_workspace_1 /sbin/my_init Up 0.0.0.0:2223->22/tcp, 0.0.0.0:8080->8010/tcp, 0.0.0.0:8081->8011/tcp, 0.0.0.0:8082->8012/tcp, 0.0.0.0:8083->8013/tcp, 0.0.0.0:8084->8014/tcp, 0.0.0.0:8085->8015/tcp, 0.0.0.0:8086->8016/tcp, 0.0.0.0:8087->8017/tcp, 0.0.0.0:8088->8018/tcp, 0.0.0.0:8089->8019/tcp, 0.0.0.0:8090->8020/tcp
|
2.5 步骤五: 配置PHPStorm
2.6 步骤六: 修改本地hosts文件
sudo vim /etc/hosts
127.0.0.1 saaspro.com
|
3. debug效果
4. 其他文档
laradock开源github地址
中文文档