注意:php
狀況1:mysql
當後端是獨立的php-fpm服務器模塊的話nginx
須要fastcgi協議sql
狀況2:後端
當後端是LAMP的話,使用的就是Apache協議服務器
不須要開啓fastcgi模塊併發
直接寫個location / {ide
proxy_pass http://backservers;php-fpm
}測試
便可
這次實驗安裝的Nginx中fastcgi_params不適用這次,因此須要更該:
fastcgi_params模塊內容:
fastcgi_param GATEWAY_INTERFACE CGI/1.1;
fastcgi_param SERVER_SOFTWARE nginx;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param SCRIPT_NAME $fastcgi_script_name;
fastcgi_param REQUEST_URI $request_uri;
fastcgi_param DOCUMENT_URI $document_uri;
fastcgi_param DOCUMENT_ROOT $document_root;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param REMOTE_ADDR $remote_addr;
fastcgi_param REMOTE_PORT $remote_port;
fastcgi_param SERVER_ADDR $server_addr;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_NAME $server_name;
ab -n 1000 -c 100 http://192.168.253.100/cwy/
測試併發量
測試MySQL連通性:
<?php
$conn = mysql_connect('127.0.0.1','root','');
if ($conn)
echo succ;
else
echo fail;
mysql_close();
?>
使用的是Apache協議:
location /up/ {
proxy_pass http://cwy/;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}