准备
部署项目的细节可以看这个,传送门Centos 7部署Laravel项目
主机IP:192.168.10.17
【高可用架构】系列链接:待部署的架构介绍
演示
部署Deploy
composer create-project --prefer-dist laravel/laravel Deploy
# cd Deploy
composer install
额,刚发现Laravel版本竟然是6.6了,迭代很快呀。
修改配置
# cd Deploy
# vi .env
APP_NAME=Deploy
APP_URL=http://dev.deploy.goods
php artisan key:generate # 生成Key
chmod -R 0777 storage # 日志
设置Nginx config配置
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
192.168.10.17 dev.deploy.goods
打开http://dev.deploy.goods/ 部署成功。
显示服务器IP
我们可以将虚拟机的工作区挂载到win下,传送门Centos7安装Samba并将工作区挂载到win,当然也可以直接用vi
打开Deploy/routes/web.php
Route::get('/', function () {
$data = ['server_ip' => $_SERVER['SERVER_ADDR']];
return view('welcome', $data);
});
打开Deploy/resources/views/welcome.blade.php,修改84行
IP:{{ $server_ip }}
刷新http://dev.deploy.goods/
上传Github
这步看概述里面的传送门,这里就不写了,仓库名为Deploy
下一章我们开始用官网的Envoy工具,将Deploy项目统一部署到两台APP Server上