I do and I understand

【高可用架构】开发机上部署Deploy项目(一)

准备

部署项目的细节可以看这个,传送门Centos 7部署Laravel项目

主机IP:192.168.10.17

【高可用架构】系列链接:待部署的架构介绍

演示


部署Deploy
1
composer create-project --prefer-dist laravel/laravel Deploy
1
2
# cd Deploy
composer install

额,刚发现Laravel版本竟然是6.6了,迭代很快呀。

修改配置

1
2
3
4
# cd Deploy
# vi .env
APP_NAME=Deploy
APP_URL=http://dev.deploy.goods
1
2
php artisan key:generate # 生成Key
chmod -R 0777 storage # 日志

设置Nginx config配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
server {
listen 80;
server_name dev.deploy.goods;

index index.html index.htm index.php;

location / {

rewrite ^/(.*)$ /index.php/$1 last;
try_files $uri $uri/ /index.php?$query_string;
}

location ~ (.+\.php)(.*)$ {
root "/var/www/Deploy/public";
fastcgi_split_path_info ^(.+\.php)(.+)$;
fastcgi_pass unix:/var/run/php-fpm/php7-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;

fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
}

重启下nginx

项目在虚拟机上,还要配置下win的hosts

1
192.168.10.17 dev.deploy.goods

打开http://dev.deploy.goods/ 部署成功。

显示服务器IP

我们可以将虚拟机的工作区挂载到win下,传送门Centos7安装Samba并将工作区挂载到win,当然也可以直接用vi

打开Deploy/routes/web.php

1
2
3
4
5
Route::get('/', function () {

$data = ['server_ip' => $_SERVER['SERVER_ADDR']];
return view('welcome', $data);
});

打开Deploy/resources/views/welcome.blade.php,修改84行

1
IP:{{ $server_ip }}

刷新http://dev.deploy.goods/

1

上传Github

这步看概述里面的传送门,这里就不写了,仓库名为Deploy

下一章我们开始用官网的Envoy工具,将Deploy项目统一部署到两台APP Server上