1.先确定系统版本:控制面板-系统和安全-系统
建议使用windows专业版
2. 直接安装wsl2,https://docs.microsoft.com/zh-cn/windows/wsl/install-manual#step-4---download-the-linux-kernel-update-package,下载安装
3.控制面板-程序-程序和功能-启用或关闭windows服务找到hyper-v,勾选上
4. 安装docker,下载软件https://www.docker.com/products/docker-desktop
查看docker版本 docker --version
查看docker-compose的版本 docker-compose --version
5. 安装laradock
新建文件夹laradocker
https://hub.fastgit.org/Laradock/laradock.git
修改.env,
build
docker-compose build nginx workspace redis php-worker
启动服务
docker-compose up -d nginx mysql redis
进入容器
docker-compose exec workspace bash
拉代码
配置nginx
/laradock/nginx/sites 生成一个配置文件
server {
listen 80;
listen [::]:80;
# For https
# listen 443 ssl;
# listen [::]:443 ssl ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name vote.localhost; //自己的域名
root /var/www/activity-api/public; //指向自己的项目的public
index index.php index.html index.htm;
location / { //伪静态配置
try_files $uri $uri/ /index.php$is_args$args;
}
location ~ \.php$ {
try_files $uri /index.php =404;
fastcgi_pass php-upstream;
fastcgi_index index.php;
fastcgi_buffers 16 16k;
fastcgi_buffer_size 32k;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
#fixes timeouts
fastcgi_read_timeout 600;
include fastcgi_params;
}
location ~ /\.ht {
deny all;
}
location /.well-known/acme-challenge/ {
root /var/www/letsencrypt/;
log_not_found off;
}
error_log /var/log/nginx/app_error.log;
access_log /var/log/nginx/app_access.log;
}
thinkphp 伪静态配置
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
重启nginx
docker-compose restart nginx