简体   繁体   中英

Laravel 5 on two vps server and one domain name

I have a laravel (with mysql) project that uses Jobs, cron tasks, etc. I want to configure it on two different vps servers(two mysql db How can they be synchronized?), but so that the load is distributed evenly. And he use one domain name.

example.com - domain

127.0.0.1 - 1 vps server with isp manager

127.0.0.2 - 2 vps server with isp manager

how to set up a domain to work with two servers? How can this be done?

upd

I use this if one of the servers stops working. I need to configure this at the domain level.

您可以将项目1指向其他项目数据库,只需将.env编辑为拥有数据库的项目的内部ip地址,但我建议您只为数据库使用第三个vps,然后将两个项目都指向该VPS ,那么您也可以添加负载均衡器VPS并处理项目vps实例的流量。

It's slb what you need, you can implement lsb functionality with nginx reverse proxy

http {
    upstream backend {
        server 127.0.0.1;
        server 127.0.0.2;
    }
    server {
        location / {
            proxy_pass http://backend;
        }
    }
}

refer https://docs.nginx.com/nginx/admin-guide/load-balancer/http-load-balancer/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM