Bytes
Http://nginx.org/en/download.html
Http://php-fpm.org/
Compile and install Linux Nginx
Tar zxvf nginx-0.6.35.tar.gz cd nginx-0.6.35/
Default installation:./configure make & make install
By default, Nginx is installed in/usr/local/nginx. You can change this setting by setting the compilation option.
Specify compilation options for installation, such:
./Configure -- user = www -- group = www -- prefix =/usr/local/webserver/nginx -- with-http_stub_status_module -- with-http_ssl_module
Make & make install
Cd ../
VII. create the fcgi. conf file in Linux Nginx
1. rm-f/usr/local/webserver/nginx/conf/fcgi. conf
2. vi/usr/local/webserver/nginx/conf/fcgi. conf
Enter the following content:
1. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
2. fastcgi_param SERVER_SOFTWARE nginx;
3. 4. fastcgi_param QUERY_STRING $ query_string;
5. fastcgi_param REQUEST_METHOD $ request_method;
6. fastcgi_param CONTENT_TYPE $ content_type;
7. fastcgi_param CONTENT_LENGTH $ content_length;
8.
9. fastcgi_param SCRIPT_FILENAME $ document_root $ fastcgi_script_name;
10. fastcgi_param SCRIPT_NAME $ fastcgi_script_name;
11. fastcgi_param REQUEST_URI $ request_uri;
12. fastcgi_param DOCUMENT_URI $ document_uri;
13. fastcgi_param DOCUMENT_ROOT $ document_root;
14. fastcgi_param SERVER_PROTOCOL $ server_protocol;
15.
16. fastcgi_param REMOTE_ADDR $ remote_addr;
17. fastcgi_param REMOTE_PORT $ remote_port;
18. fastcgi_param SERVER_ADDR $ server_addr;
19. fastcgi_param SERVER_PORT $ server_port;
20. fastcgi_param SERVER_NAME $ server_name;
21.
22. # PHP only, required if PHP was built with -- enable-force-cgi-redirect
23. fastcgi_param REDIRECT_STATUS 200;
8. edit the Linux Nginx configuration file
1. rm-f/usr/local/webserver/nginx/conf/nginx. conf
2. vi/usr/local/webserver/nginx/conf/nginx. conf
Enter the following content:
1. user www;
2. worker_processes 8;
3. error_log/usr/local/webserver/nginx/logs/nginx_error.log crit;
4. pid/usr/local/webserver/nginx/logs/nginx. pid;
5. worker_rlimit_nofile 51200;
6. events {
7. use epoll;
8. worker_connections 51200;
9 .}
10.
11. http {
12. include mime. types;
13. default_type application/octet-stream;
14. charset UTF-8;
15.
16. server_names_hash_bucket_size 128;
17. client_header_buffer_size 32 k;
18. large_client_header_buffers 4 32 k;
19. client_max_body_size 8 m;
20.
21. sendfile on;
22. tcp_nopush on;
23. keepalive_timeout 60;
24. tcp_nodelay on;
25.
26. fastcgi_connect_timeout 300;
27. fastcgi_send_timeout 300;
28. fastcgi_read_timeout 300;
29. fastcgi_buffer_size 64 k;
30. fastcgi_buffers 8 64 k;
31. fastcgi_busy_buffers_size 128 kb;
32. fastcgi_temp_file_write_size 128 kb;
33.
34. gzip on;
35.gzip _ min_length 1 k;
36.gzip _ buffers 4 16 k;
37.gzip _ http_version 1.0;
38.gzip _ comp_level 2;
39.gzip _ types text/plain application/x-javascript text/css application/xml;
40.gzip _ vary on;
41.
42. # limit_zone crawler $ binary_remote_addr 10 m;
43. # for multiple site settings, the site folder must be placed in the Nginx html directory; otherwise, multiple sites are not supported.
44. server {
45. listen 80;
46. server_name www.v-ec.com;
47. root/usr/local/webserver/nginx/html/www.v-ec.com;
48. index. php index.html;
49.
50. location ~ . * \. (Php | php5 )? $ {
51. # fastcgi_pass unix:/tmp/php-cgi.sock;
52. fastcgi_pass 127.0.0.1: 9000;
53. fastcgi_index. php;
54. include fcgi. conf;
55 .}
56.
57. location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $ {
58. expires 30d; 59 .}
60.
61. location ~ . * \. (Js | css )? $ {
62. expires 6 h;
63 .}
64.
65. log_format veclog '$ remote_addr-$ remote_user [$ time_local] "$ request "'
66. '$ status $ body_bytes_sent "$ http_referer "'
67. '"$ http_user_agent" $ http_x_forwarded_for ';
68. access_log logs/vec. log veclog;
69 .}
70. # for multiple site settings, the site folder must be placed in the Nginx html directory; otherwise, multiple sites are not supported.
71. server {
72. listen 80;
73. server_name www.w3cgroup.com;
74. root/usr/local/webserver/nginx/html/www.w3cgroup.com;
75. index. php index.html;
76.
77. location ~ . * \. (Php | php5 )? $ {
78. # fastcgi_pass unix:/tmp/php-cgi.sock;
79. fastcgi_pass 127.0.0.1: 9000;
80. fastcgi_index. php;
81. include fcgi. conf;
82 .}
83.
84. location ~ . * \. (Gif | jpg | jpeg | png | bmp | swf) $ {
85. expires 30d;
86 .}
87. 88. location ~ . * \. (Js | css )? $ {
89. expires 6 h;
90 .}
91.
92. log_format w3cclog '$ remote_addr-$ remote_user [$ time_local] "$ request "'
93. '$ status $ body_bytes_sent "$ http_referer "'
94. '"$ http_user_agent" $ http_x_forwarded_for ';
95. access_log logs/w3c. log w3clog;
96 .}
97 .}
9. configure boot to automatically start Linux Nginx + PHP
1. add the following content at the end of vi/etc/rc. local:
1. ulimit-SHn 51200
2./usr/local/webserver/php/sbin/php-fpm start
3./usr/local/webserver/nginx/sbin/nginx
10. Linux Nginx optimizes Linux kernel parameters
1. add the following content to the end of vi/etc/sysctl. conf:
1.net. ipv4.tcp _ fin_timeout = 30
2.net. ipv4.tcp _ keepalive_time = 300
3.net. ipv4.tcp _ syncookies = 1
4.net. ipv4.tcp _ tw_reuse = 1
5.net. ipv4.tcp _ tw_recycle = 1
Make the configuration take effect immediately:/sbin/sysctl-p. here, you can restart Linux with reboot. Nginx should be enabled smoothly without any exceptions.