Experiment: Based on keepalived implementation, the Nginx and PHP-FPM services in two Realserver servers are mainly from

Source: Internet
Author: User
Tags configuration php

Based on keepalived implementation, the Nginx and PHP-FPM services in two Realserver servers are mainly from

Idea: Using two VIP, a positioning nginx, a positioning php-fpm

Steps:

1 , prepare two sets based on Lnmp architected servers (capable of providing normal Web services)

2, in Nginx main php-fpm for the preparation of the machine operation:

① Editing the keepalived configuration file (refer to the blog for specific meanings of the contents of the document:

http://13150617.blog.51cto.com/13140617/1979652)

Vim/etc/keepalived/keepalived.conf

! Configuration File for Keepalived

Global_defs {

Notification_email {

[Email protected]

}

Notification_email_from [email protected]

Smtp_server 127.0.0.1

Smtp_connect_timeout 2

router_id Lvs_develhaha

}

Vrrp_instance Vi_1 {

State MASTER

Interface eth0

virtual_router_id 11

Priority 100

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 111111

}

virtual_ipaddress {

172.17.0.22

}

}

Vrrp_instance Vi_2 {

State BACKUP

Interface eth1

virtual_router_id 12

Priority 90

Advert_int 1

Authentication {

Auth_type PASS

Auth_pass 111111

}

virtual_ipaddress {

192.168.199.33

}

}

② configures the PHP-FPM so that it listens on port 9000 and allows all hosts to access

Vim/etc/php-fpm.d/www.conf

Listen = 9000

Note Listen.allowed_clients = any

③ configure Nginx to point to the host on which PHP resides

Vim/etc/nginx/nginx.conf

Fastcgi_pass 192.168.199.33:9000; Virtual IP

④ Turn on forwarding function

Echo 1 >/proc/sys/net/ipv4/ip_forward

⑤ Start Service

Systemctl Start KeepAlive

3, PHP-FPM main nginx for the preparation of the machine operation:

① editing the keepalived configuration file

Vim/etc/keepalived/keepalived.conf

With the above configuration, only the state and priority priorities need to be swapped

② Configuration php-fpm

Vim/etc/php-fpm.d/www.conf

Configuration completely ibid.

③ configuration Nginx

Vim/etc/nginx/nginx.conf

Configuration completely ibid.

④ Turn on forwarding function

Echo 1 >/proc/sys/net/ipv4/ip_forward

⑤ Start Service:

Systemctl Start KeepAlive

4, testing: Two servers are normal service, Nginx-based machine and PHP-FPM-based machines have a VIP, the site can be visited normally

650) this.width=650; "src=" https://s4.51cto.com/oss/201711/09/ca42798be27ab1580ae4753a5f20c995.jpg "style=" float: none; "title=" image 1.jpg "alt=" Ca42798be27ab1580ae4753a5f20c995.jpg "/>

650) this.width=650; "src=" https://s4.51cto.com/oss/201711/09/ad763f22f4282f2dab89580701c97d85.jpg "style=" float: none; "title=" image 2.jpg "alt=" Ad763f22f4282f2dab89580701c97d85.jpg "/>

650) this.width=650; "src=" https://s4.51cto.com/oss/201711/09/84589961fcb591c5c1dd1d2ac42e1ef4.jpg "style=" float: none; "title=" Image 3.jpg "alt=" 84589961fcb591c5c1dd1d2ac42e1ef4.jpg "/>


When a server fails, the VIP will drift to the normal server, and the site will still be accessible


650) this.width=650; "src=" Https://s4.51cto.com/oss/201711/09/298b7c499a86712c1649562e07e6e85d.jpg "title=" Picture 4.jpg "style=" Float:none; "alt=" 298b7c499a86712c1649562e07e6e85d.jpg "/>


Thanks for browsing, if in doubt, please leave a message.

650) this.width=650; "src=" Http://img.baidu.com/hi/jx2/j_0080.gif "alt=" J_0080.gif "/>


Experiment: Based on keepalived implementation, the Nginx and PHP-FPM services in two Realserver servers are mainly from

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.