1.先確定系統(tǒng)版本:控制面板-系統(tǒng)和安全-系統(tǒng)
建議使用windows專業(yè)版
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 / {? //偽靜態(tài)配置
? ? ? ? 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 偽靜態(tài)配置
location / {
? ? ? ? ? if (!-e $request_filename) {
? ? ? ? ? rewrite? ^(.*)$? /index.php?s=/$1? last;
? ? ? ? ? break;
? ? ? }
}
重啟nginx
docker-compose restart nginx