首先展示一下路径
/project
/project/wwwroot
获取 laradock
cd /project
git clone https://github.com/Laradock/laradock.git
laradock配置
cp env-example .env
修改laradock的.env,建立laradock与wwwroot的链接
APP_CODE_PATH_HOST=../wwwroot/
.env中其他修改
PHP_VERSION=7.2 //php版本
MYSQL_VERSION=latest //mysql版本
下载镜像和容器,时间超长
docker-compose up -d nginx mysql phpmyadmin redis workspace
如果没有自动启动的话可手动启动
docker-compose up -d nginx
docker-compose up -d php-fpm
docker-compose up -d mysql
进入laradock的工作区域,上面配置的相对路径“../wwwroot/”,进入后可执行composer,artisan,mysql等命令
docker-compose exec workspace bash
将自己的项目(blog)放在在wwwroot中,在laradock/nginx/sites中添加nginx的conf文件
cp default.conf blog.conf
项目路径:root /var/www/blog/public;
运行地址:server_name localhost;如果改成域名' server_name XXX.com '需要在'/etc/hosts'添加‘ 127.0.0.1 XXX.com ’
server {
listen 80 default_server;
listen [::]:80 default_server ipv6only=on;
# For https
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server ipv6only=on;
# ssl_certificate /etc/nginx/ssl/default.crt;
# ssl_certificate_key /etc/nginx/ssl/default.key;
server_name localhost;
root /var/www/blog/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;
}
}
重启nginx
docker-compose restart nginx
浏览器打开 http://IP 或者 http://XXX.com即可看到效果
网友评论