Document directory
- 3.1php installation and configuration
Only simple configuration examples are provided here. For more detailed information about the configuration file, we will discuss it later.
Lab environment:
System: centos6.2 Linux 2.6 kernel
PHP version: 5.4.14 (latest)
Nginx version: 1.3.16 (latest)
1. Configuration Diagram
The configuration framework is as follows:
We can see that there are three machines.
Connection Proxy: 192.168.66.20 the other two are backend servers, and the IP address and listening port are marked above
2. Agent installation and configuration
Nginx installation is relatively simple, For details, please refer to: http://blog.csdn.net/rao_warrior/article/details/8948063
The nginx configuration is as follows:
In the following configuration file, for ease of understanding, I deleted some unnecessary items for the moment.
# User nobody;
Worker_processes 1;
# Error_log logs/error. log;
# Error_log logs/error. Log notice;
# Error_log logs/error. Log Info;
# PID logs/nginx. PID;
Events {
Worker_connections 1024;
}
HTTP {
Include mime. types;
Default_type application/octet-stream;
# Log_format main '$ remote_addr-$ remote_user [$ time_local] "$ request "'
# '$ Status $ body_bytes_sent "$ http_referer "'
# '"$ Http_user_agent" "$ http_x_forwarded_for "';
# Access_log logs/access. Log main;
Sendfile on;
# Tcp_nopush on;
# Keepalive_timeout 0;
Keepalive_timeout 65;
# Gzip on;
Upstream myproject {
Server 192.168.66.11: 9000;
Server 192.168.66.10: 9000;
}
Server {
Listen 80;
SERVER_NAME 192.168.66.20;
# Charset koi8-r;
# Access_log logs/host. Access. Log main;
Location /{
Root HTML;
Index index.html index.htm;
}
# Error_page 404/404 .html;
# Redirect server error pages to the static page/50x.html
#
Error_page 500 502 503 x.html;
Location =/50x.html {
Root HTML;
}
# Proxy the PHP scripts to Apache listening on 127.0.0.1: 80
#
# Location ~ \. Php $ {
# Proxy_pass http: // 192.168.66.20;
#
#}
# Pass the PHP scripts to FastCGI server listening on Fig: 9000
#
Location ~ \. Php $ {
Root HTML;
Fastcgi_pass myproject;
Fastcgi_index index. php;
Fastcgi_param script_filename/home/PHP/$ fastcgi_script_name; # specify the directory where the PHP website of the backend server is stored
Include fastcgi_params;
}
}
}
3. install and configure the backend server 3.1php
For installation details, see: http://blog.csdn.net/rao_warrior/article/details/8948063
Configure the/usr/local/etc/php-fpm.conf file as follows:
Find the line Listen = 127.0.0.1: 9000 and change it:
Listen = 192.168.66.10: 9000 # Take server 192.168.66.10 as an Example
Start PHP-FPM.