【高可用架構】開發機上部署Deploy項目(一)

準備

部署項目的細節能夠看這個,傳送門Centos 7部署Laravel項目php

主機IP:192.168.10.17html

【高可用架構】系列連接:待部署的架構介紹nginx

演示


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

額,剛發現Laravel版本居然是6.6了,迭代很快呀。laravel

修改配置git

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

設置Nginx config配置github

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;
   }
}

重啓下nginxweb

項目在虛擬機上,還要配置下win的hosts服務器

192.168.10.17 dev.deploy.goods

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

顯示服務器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/

1

上傳Github

這步看概述裏面的傳送門,這裏就不寫了,倉庫名爲Deploy

下一章咱們開始用官網的Envoy工具,將Deploy項目統一部署到兩臺APP Server上

相關文章
相關標籤/搜索