windows10 专业版使用laradock
2020-03-23 本文已影响0人
charmingcheng
安装Docker for windows
下载Docker for windows,地址:https://hub.docker.com/editions/community/docker-ce-desktop-windows/
安装完成后,测试是否安装成功,运行cmd,执行命令:
docker -v
docker-compose -v
克隆laradock
- 在本地克隆laradock仓库代码
git clone https://github.com/Laradock/laradock.git
修改laradock配置
- 复制env-example为.env文件
cp env-example .env
- 修改.env
APP_CODE_PATH_HOST=../wwwroot/ /*网站根目录*/
- 添加host
DB_HOST=mysql
REDIS_HOST=redis
QUEUE_HOST=beanstalkd
- 修改为国内源
# If you need to change the sources (i.e. to China), set CHANGE_SOURCE to true
CHANGE_SOURCE=true
网站根目录
在laradock同级目录下新建一个名为:wwwroot(与.env中APP_CODE_PATH_HOST对应)的文件夹,作为网站根目录
laravel搭建项目
- 进入wwwroot目录, 使用composer创建laravel项目
cd wwwroot
composer create-project laravel/laravel --prefer-dist
配置nginx站点
在laradock/nginx/sites目录下复制laravel.conf.example为laravel.conf,修改nginx配置
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 laravel.test;
root /var/www/laravel/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/laravel_error.log;
access_log /var/log/nginx/laravel_access.log;
}
docker-compose 重启nginx
docker-compose restart nginx
配置本地hosts
127.0.0.1 laravel.test