This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revision | |||
| en:常见问题及解答:如何为astercc系统配置多台php服务器 [2016/11/14 02:07] – liuxl | en:常见问题及解答:如何为astercc系统配置多台php服务器 [2016/11/18 03:11] (current) – removed solo | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| - | ====== How to configure multiple PHP servers for the asterCC system ====== | ||
| - | |||
| - | ===== System Details ===== | ||
| - | |||
| - | * CTI(Asterisk)、Nginx:192.168.1.62 | ||
| - | * MySQL:192.168.1.60 | ||
| - | * PHP1:192.168.1.61 | ||
| - | * PHP2:192.168.1.70 | ||
| - | |||
| - | < | ||
| - | |||
| - | 1.Before distributing the system, you need to back up the database on the CTI machine. | ||
| - | < | ||
| - | |||
| - | And then in the new mysql database server (192.168.1.60) on the backup data import. | ||
| - | < | ||
| - | |||
| - | |||
| - | 2.On the MySQL machine, the CTI, PHP1, PHP2 machine database authorization. | ||
| - | In the mysql> under the implementation of the following order: | ||
| - | < | ||
| - | |||
| - | |||
| - | 3.In the CTI, PHP1, PHP2 three machines / | ||
| - | < | ||
| - | [database] | ||
| - | dbtype = mysql | ||
| - | dbhost = 192.168.1.60 | ||
| - | dbname = astercc10 | ||
| - | dbport = 3306 | ||
| - | username = astercc | ||
| - | password = asterccpw | ||
| - | prefix= cc10_ | ||
| - | |||
| - | [statistics] | ||
| - | ; | ||
| - | status = on | ||
| - | dbtype = mysql | ||
| - | dbhost = 192.168.1.60 | ||
| - | dbname = astercc10 | ||
| - | dbport = 3306 | ||
| - | dbuser = astercc | ||
| - | dbpassword = asterccpw | ||
| - | prefix= cc10_ | ||
| - | |||
| - | |||
| - | [system] | ||
| - | ;if Cluster no, | ||
| - | cluster = php | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | |||
| - | |||
| - | 4.In / | ||
| - | |||
| - | class DATABASE_CONFIG { | ||
| - | var $default = array( | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ' | ||
| - | ); | ||
| - | |||
| - | < | ||
| - | |||
| - | |||
| - | 5.Configure the iptables service, the implementation of the machine configuration is complete:service iptables restart | ||
| - | |||
| - | CTI (and Nginx) machines: | ||
| - | < | ||
| - | *filter | ||
| - | :INPUT DROP [32888: | ||
| - | :FORWARD DROP [0:0] | ||
| - | :OUTPUT ACCEPT [38964: | ||
| - | -A INPUT -p udp -m udp --dport 5060 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 4569 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 5036 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 2727 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 137:138 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 123 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 8081 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 139 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 389 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 445 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 5038 -j ACCEPT | ||
| - | -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT | ||
| - | -A INPUT -s 127.0.0.1/ | ||
| - | -A INPUT -m state --state ESTABLISHED -j ACCEPT | ||
| - | COMMIT | ||
| - | </ | ||
| - | |||
| - | |||
| - | On a MySQL machine: | ||
| - | < | ||
| - | *filter | ||
| - | :INPUT DROP [32888: | ||
| - | :FORWARD DROP [0:0] | ||
| - | :OUTPUT ACCEPT [38964: | ||
| - | -A INPUT -p udp -m udp --dport 5060 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 4569 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 5036 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 2727 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 3306 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 161 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 161 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 162 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 162 -j ACCEPT | ||
| - | -A INPUT -p icmp -m icmp --icmp-type 8 -j ACCEPT | ||
| - | -A INPUT -s 127.0.0.1/ | ||
| - | -A INPUT -m state --state ESTABLISHED -j ACCEPT | ||
| - | COMMIT | ||
| - | </ | ||
| - | |||
| - | |||
| - | On PHP1 machines: | ||
| - | < | ||
| - | *filter | ||
| - | :INPUT ACCEPT [32888: | ||
| - | :FORWARD ACCEPT [0:0] | ||
| - | :OUTPUT ACCEPT [38964: | ||
| - | -A INPUT -p udp -m udp --dport 5060 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 4569 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 5036 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 10000:20000 -j ACCEPT | ||
| - | -A INPUT -p udp -m udp --dport 2727 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 9000 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 80 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 443 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 21 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 22 -j ACCEPT | ||
| - | -A INPUT -p tcp -m tcp --dport 5038 -j ACCEPT | ||
| - | COMMIT | ||
| - | </ | ||
| - | |||
| - | |||
| - | On PHP2 machines: | ||
| - | like PHP1 | ||
| - | |||
| - | < | ||
| - | Port: According to the actual situation, the / | ||
| - | 21: FTP default port | ||
| - | 22: SSH default port | ||
| - | 80: http acquiescence port, because I changed the machine 8081, the CTI iptables added 8081 | ||
| - | 123: NTP default port | ||
| - | 137: udp samba port | ||
| - | 138: udp samba port | ||
| - | 139: tcp samba port | ||
| - | 389: tcp samba port | ||
| - | 445: tcp samba port | ||
| - | 901: tcp samba port | ||
| - | 161: Port of SNMP | ||
| - | 162: Port of the SNMP trap | ||
| - | 443: https default port | ||
| - | 2727: MGCP default port | ||
| - | 3306: mysql default port | ||
| - | 4569: IAX2 default port | ||
| - | 5036: IAX1 default port | ||
| - | 5038: Asterisk default port | ||
| - | 5060: sip The default port | ||
| - | 9000: php default port | ||
| - | 10000: 20000: Asterisk RTP to use the port | ||
| - | </ | ||
| - | |||
| - | |||
| - | 6.In CTI, PHP1 installed samba services, the Executive Order: | ||
| - | < | ||
| - | |||
| - | |||
| - | 7.After installation is complete, create samba user and password, such as: sbu/123456, | ||
| - | run: | ||
| - | < | ||
| - | And then, when prompted, enter 123456: | ||
| - | < | ||
| - | |||
| - | 8.Modify the samba configuration file / | ||
| - | |||
| - | On a CTI machine: | ||
| - | < | ||
| - | [ccastspool] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | |||
| - | [ccastetc] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | |||
| - | [ccastlib] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | |||
| - | [ccscripts] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | </ | ||
| - | |||
| - | On PHP1 machines: | ||
| - | < | ||
| - | [ccdata] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | |||
| - | [ccstatistics] | ||
| - | path = / | ||
| - | comment = Home Directories | ||
| - | browseable = no | ||
| - | writable = yes | ||
| - | ; valid users = %S | ||
| - | ; valid users = MYDOMAIN\%S | ||
| - | create mask=777 | ||
| - | directory mask = 777 | ||
| - | force user = asterisk | ||
| - | </ | ||
| - | |||
| - | |||
| - | 9.After the configuration is complete, restart the Samba service configuration to take effect, execute the command: | ||
| - | < | ||
| - | |||
| - | 10.The samba file, mounted on each other. (For example, on a CTI machine, mount the ccdata from the PHP1 machine to the / | ||
| - | |||
| - | |||
| - | On the CTI machine, execute the following commands to mount: | ||
| - | < | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | </ | ||
| - | |||
| - | PHP1 machines, followed by the implementation of orders, carrying: | ||
| - | < | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | </ | ||
| - | |||
| - | PHP2 machines, followed by orders for carrying: | ||
| - | < | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | mount -t cifs -o username=sbu, | ||
| - | </ | ||
| - | |||
| - | Set the boot automatically mount, master and slave can be mounted on all the settings are similar to the following: | ||
| - | < | ||
| - | < | ||
| - | |||
| - | {{: | ||
| - | |||
| - | 11.Modify the contents of the / | ||
| - | On a CTI machine: | ||
| - | < | ||
| - | [www] | ||
| - | listen=127.0.0.1 | ||
| - | listen.allowed_clients=127.0.0.1 | ||
| - | </ | ||
| - | |||
| - | On PHP1 machines: | ||
| - | < | ||
| - | [www] | ||
| - | listen=192.168.1.61: | ||
| - | listen.allowed_clients=127.0.0.1, | ||
| - | </ | ||
| - | |||
| - | On PHP2 machines: | ||
| - | < | ||
| - | [www] | ||
| - | listen=192.168.1.70: | ||
| - | listen.allowed_clients=127.0.0.1, | ||
| - | </ | ||
| - | |||
| - | |||
| - | 12.Modify the / | ||
| - | On a CTI machine: | ||
| - | |||
| - | 12-1:In http add the following: | ||
| - | < | ||
| - | http{ | ||
| - | |||
| - | upstream myphp { | ||
| - | #ip_hash; PHP load balancing | ||
| - | server 192.168.1.61: | ||
| - | server 192.168.1.70: | ||
| - | } | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | |||
| - | 12-2:In the location in front of the location to add the following, and the default configuration fastcgi_pass 127.0.0.1: | ||
| - | < | ||
| - | location ~ .*\.(php|php5)? | ||
| - | { | ||
| - | # This means that the login and reload, the use of the machine' | ||
| - | set $target myphp; | ||
| - | if ($request_uri ~* login) { | ||
| - | set $target 127.0.0.1: | ||
| - | } | ||
| - | if ($request_uri ~* reloadConf) { | ||
| - | set $target 127.0.0.1: | ||
| - | } | ||
| - | fastcgi_pass | ||
| - | # | ||
| - | } | ||
| - | </ | ||
| - | |||
| - | < | ||
| - | |||
| - | If you only use one server (such as: PHP1) to run PHP services, rather than using PHP load balancing, then, CTI does not need to add any content. And the location of the first sentence set $ target myphp; content also need to modify the address plus PHP1 port, namely: set $ target 192.168.1.61: | ||
| - | </ | ||
| - | |||
| - | |||
| - | 13.Authorize the sharing of related documents | ||
| - | |||
| - | On a CTI machine: | ||
| - | |||
| - | 13-1:First copy to the mount directory: | ||
| - | < | ||
| - | Then execute: | ||
| - | < | ||
| - | |||
| - | 13-2:copy: | ||
| - | < | ||
| - | Then execute: | ||
| - | < | ||
| - | |||
| - | 13-3:/ | ||
| - | 13-4:/ | ||
| - | |||
| - | 13-5:copy: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | |||
| - | 13-6:copy: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | |||
| - | PHP1 machine: | ||
| - | |||
| - | 13-7:Back up the agentsxindesk.ctp file of the machine into agentsxindesk.ctp.bak | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | 13-8:Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | |||
| - | 13-9:The machine' | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | 13-10:The local astercc.conf file backup astercc.conf.bak | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | On PHP2 machines: | ||
| - | |||
| - | 13-11:Back up the agentsxindesk.ctp file of the machine into agentsxindesk.ctp.bak | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | 13-12:Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | 13-13:The machine' | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | 13-14:The local astercc.conf file backup astercc.conf.bak | ||
| - | Backup: | ||
| - | < | ||
| - | run: | ||
| - | < | ||
| - | |||
| - | |||
| - | 14.Modify the contents of some files | ||
| - | |||
| - | On a CTI machine: | ||
| - | |||
| - | / | ||
| - | < | ||
| - | |||
| - | < | ||
| - | [astercc] | ||
| - | secret = asterccsecret | ||
| - | deny=0.0.0.0/ | ||
| - | permit=127.0.0.1/ | ||
| - | permit=192.168.1.0/ | ||
| - | read = system, | ||
| - | write = system, | ||
| - | </ | ||
| - | |||
| - | / | ||
| - | < | ||
| - | [asterisk] | ||
| - | server = 192.168.1.62 | ||
| - | port = 5038 | ||
| - | username = astercc | ||
| - | secret = asterccsecret | ||
| - | </ | ||
| - | |||
| - | |||
| - | 15.Note / etc / asterisk permissions, | ||
| - | |||
| - | 16.Crontab file content, the implementation of: crontab-e for its content editing. Crontab start monitoring procedures can be complementary, | ||
| - | |||
| - | CTI: | ||
| - | |||
| - | < | ||
| - | 30 12 * * * / | ||
| - | 30 20 * * * / | ||
| - | 30 23 * * * / | ||
| - | * * * * * / | ||
| - | 10 2 * * * / | ||
| - | 10 0 * * * / | ||
| - | 20 0 * * * / | ||
| - | </ | ||
| - | |||
| - | MySQL: | ||
| - | Delete all, do not need to carry out any procedure. | ||
| - | |||
| - | |||
| - | PHP1 and PHP2, the two machines need to be divided according to the configuration and load the implementation of the script, the two machines do not have to do, so complementary to the following script: | ||
| - | < | ||
| - | * * * * * / | ||
| - | * 2 * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | */5 * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | * * * * * / | ||
| - | </ | ||
| - | |||
| - | |||
| - | 17.Mount mount detection, need to be added to the crontab. | ||
| - | CTI: | ||
| - | < | ||
| - | */5 * * * * dfccdata=`df |grep ccdata`; [ " | ||
| - | */5 * * * * dfccstatistics=`df |grep ccstatistics`; | ||
| - | </ | ||
| - | |||
| - | |||
| - | PHP1: | ||
| - | < | ||
| - | */5 * * * * dfccastspool=`df |grep ccastspool`; | ||
| - | */5 * * * * dfastetc=`df |grep etc/ | ||
| - | */5 * * * * dfccastlib=`df |grep ccastlib`; [ " | ||
| - | */5 * * * * dfccscripts=`df |grep ccscripts`; [ " | ||
| - | </ | ||
| - | |||
| - | |||
| - | PHP2: | ||
| - | < | ||
| - | */5 * * * * dfccdata=`df |grep ccdata`; [ " | ||
| - | */5 * * * * dfccstatistics=`df |grep ccstatistics`; | ||
| - | |||
| - | */5 * * * * dfccastspool=`df |grep ccastspool`; | ||
| - | */5 * * * * dfastetc=`df |grep etc/ | ||
| - | */5 * * * * dfccastlib=`df |grep ccastlib`; [ " | ||
| - | */5 * * * * dfccscripts=`df |grep ccscripts`; [ " | ||
| - | </ | ||
| - | |||
| - | |||
| - | 18.At last, | ||
| - | |||
| - | On CTI machine, | ||
| - | < | ||
| - | On PHP1 machine, | ||
| - | < | ||
| - | On php2 machine,run | ||
| - | < | ||
| - | |||
| - | Normal CTI will be prompted: 001, in PHP1 will prompt 002, PHP2 will prompt 003, and then re-do authorization. In the CTI run: service asterccd restart, the process of see if there is an error. | ||