(7)配置nginx支持php 以虚拟主机为案例:
1
2 user nobody;
3 worker_processes 1;
4
5 #error_log logs/error.log;
6 #error_log logs/error.log notice;
7 error_log logs/error.log info;
8
9 #pid logs/nginx.pid;
10 google_perftools_profiles /tmp/tcmalloc;
11
12 events {
13 worker_connections 1024;
14 }
15
16
17 http {
18 include mime.types;
19 default_type application/octet-stream;
20
21 log_format main '$remote_addr - $remote_user [$time_local] "$request" '
22 '$status $body_bytes_sent "$http_referer" '
23 '"$http_user_agent" "$http_x_forwarded_for"';
24
25 #access_log logs/access.log main;
26
27 sendfile on;
28 #tcp_nopush on;
29
30 #keepalive_timeout 0;
31 keepalive_timeout 65;
32
33 gzip on;
34 gzip_min_length 1k;
35 gzip_buffers 6 16k;
36 gzip_http_version 1.1;
37 gzip_comp_level 2;
38 gzip_types text/plain application/x-javascript text/css application/xml;
39 gzip_vary on;
40
41 server {
42 listen 80;
43 server_name localhost;
44
45 #charset koi8-r;
46
47 access_log logs/host.access.log main;
48
49 location / {
50 root html;
51 index index.html index.htm;
52 }
58 error_page 500 502 503 504 /50x.html;
59 location = /50x.html {
60 root html;
61 }
127 server {
128 listen 80;
129 server_name mail.test.com 192.168.1.120;
130 access_log logs/test.access.log main;
131
132 location / {
133 root /web;
134 index index.php index.html index.htm;
135 }
136
137 location ~ \.php$ {
138 root /web;
139 fastcgi_pass 127.0.0.1:9000;
140 fastcgi_index index.php;
141 fastcgi_param SCRIPT_FILENAME /web/$fastcgi_script_name;
142 include fastcgi_params;
143 }
144 }
145 }
[root@localhost~]#mkdir /web
[root@localhost web]#vim index.php
<?php
phpinfo();
?>
[root@localhost web]# ps -ef |grep nginx
[root@localhost web]# kill 9382
[root@localhost web]# /usr/local/nginx/sbin/nginx
(8)优化Nginx中FastCGI
[root@localhost web]# vim /usr/local/nginx/conf/nginx.conf
server {
listen 80;
server_name mail.test.com 192.168.1.120;
access_log logs/test.access.log main;
location / {
root /web;
index index.php index.html index.htm;
}
location ~ \.php$ {
root /web;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /web/$fastcgi_script_name;
include fastcgi_params;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
}
}
}
http://192.168.1.120
本文出自 “dsafsa_技术博客” 博客,转载请与作者联系!