自行安装docker和git
安装laradock
git clone https://github.com/laradock/laradock.git
cp .env.example .env
重点修改.env,因为不可抗力,如果能解封可以不修改
CHANGE_SOURCE=true #这里
WORKSPACE_TIMEZONE=PRC
WORKSPACE_NVM_NODEJS_ORG_MIRROR=https://npm.taobao.org/mirrors/node
注:APP_CODE_PATH_HOST是你应用程序的目录,APP_CODE_PATH_CONTAINER是你容器映射的目录
以下如果能安装成功可以不修改,有时会安装不了需要修改。
WORKSPACE_BASE_IMAGE_TAG_PREFIX=latest
WORKSPACE_COMPOSER_GLOBAL_INSTALL=true
WORKSPACE_COMPOSER_AUTH=false
WORKSPACE_COMPOSER_REPO_PACKAGIST=
WORKSPACE_NVM_NODEJS_ORG_MIRROR=
WORKSPACE_INSTALL_NODE=false #这里
WORKSPACE_NODE_VERSION=node #这里
WORKSPACE_NPM_REGISTRY=
WORKSPACE_INSTALL_YARN=false #这里
WORKSPACE_YARN_VERSION=latest
WORKSPACE_INSTALL_NPM_GULP=false #这里
WORKSPACE_INSTALL_NPM_BOWER=false #这里
WORKSPACE_INSTALL_NPM_VUE_CLI=false #这里
WORKSPACE_INSTALL_NPM_ANGULAR_CLI=false #这里
启动
docker-compose up -d redis mysql nginx
我这里返回报错信息,没有报错的可以不看这里:
=> ERROR [internal] load metadata for docker.io/library/mysql:latest
因为我的是Mac M1,所以在 docker-compose.yml 添加参数
vim docker-compose.yml
搜索MySQL位置,/MySQL,MySQL尾部加上:platform: linux/x86_64
Failed to connect to raw.githubusercontent.com port 443: Connection refused
ERROR: Service 'workspace' failed to build : Build failed,
通过https://ipaddress.com/website/raw.githubusercontent.com,
查询 raw.githubusercontent.com 的真实 IP, 然后手工添加到 /etc/hosts, 比如 185.199.108.133 raw.githubusercontent.com
sudo vim /etc/hosts
加上:185.199.108.133 raw.githubusercontent.com
Service 'php-fpm' failed to build : Build failed
跟workspace报错一样,已经配置过了,需要多试几次,网络可能有问题
你的项目和laradock位于同级目录
laradock
project-1
project-2
配置nginx即可开始访问
docker-compose exec workspace bash
配置composer
# 查看composer配置的镜像
composer config -g repositories.packagist.org
# 修改composer镜像(全局配置(推荐))
composer config -g repo.packagist composer https://mirrors.aliyun.com/composer/
创建laravel应用
composer create-project --prefer-dist laravel/laravel blog "6.*"
官方文档:https://laradock.io/
一篇不错的文档://www.greatytc.com/p/6d79370d8b6e
kafka
Install RDKAFKA extension in php-fpm
1 - Open the .env
file
2 - Search for the PHP_FPM_INSTALL_RDKAFKA
argument under the PHP-FPM container
3 - Set it to true
4 - Re-build the container docker-compose build php-fpm
Install RDKAFKA extension in workspace
This is needed for ‘composer install’ if your dependencies require Kafka.
1 - Open the .env
file
2 - Search for the WORKSPACE_INSTALL_RDKAFKA
argument under the WORKSPACE container
3 - Set it to true
4 - Re-build the container docker-compose build workspace
修改docker-compose.yml中kafka部分
### kafka ####################################################
kafka:
image: wurstmeister/kafka
ports:
- "9092:9092"
environment:
KAFKA_BROKER_ID: 1
KAFKA_ADVERTISED_HOST_NAME: kafka #修改
KAFKA_ADVERTISED_LISTENERS: PLAINTEXT://kafka:9092 #修改
KAFKA_MESSAGE_MAX_BYTES: 2000000
KAFKA_ZOOKEEPER_CONNECT: zookeeper:2181
volumes:
- ${DATA_PATH_HOST}/kafka:/kafka
- /var/run/docker.sock:/var/run/docker.sock
depends_on: #添加
- zookeeper #添加
networks:
- backend
### kafka-manager ###########################################
kafka-manager:
image: sheepkiller/kafka-manager
ports:
- 9020:9000
environment:
ZK_HOSTS: zookeeper:2181
depends_on:
- kafka
networks:
- backend
配合phpstorm适应xdebug调试
https://learnku.com/articles/36800
注意这一步validate前要在laradock/php-fpm下对应的php.ini添加xdebug.mode=debug