wget
wget
wget
wget
wget
#tar xzvf nginx-0.6.34.tar.gz
#cd nginx-0.6.34
#./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_gzip_static_module --with-http_stub_status_module --with-http_sub_module
#make -j 4
#make install
#tar xzvf php-5.2.8.tar.gz
#gzip -cd php-5.2.8-fpm-0.5.10.diff.gz |patch -d php-5.2.8 -p1
#tar jxvf xcache-1.2.2.tar.bz2
#tar xzvf memcache-2.2.4.tgz
#mv xcache-1.2.2 php-5.2.8/ext/xcache
#mv memcache-2.2.4 php-5.2.8/ext/memcache
#cd php-5.2.8
#rm -f configure
#./buildconf --force
#./configure '--prefix=/usr/local/php' '--enable-fastcgi' '--enable-force-cgi-redirect' '--with-mysql' '--enable-xcache' '--enable-xcache-constant' '--enable-xcache-optimizer' '--enable-memcache' '--enable-fpm' '--with-mcrypt'
#make -j 4
#make install
#cd /usr/local/php/etc/
#mv php.ini.default php.ini
#vi php-fpm.conf
去掉注释 nobody 改为与nginx.conf中user相同
Unix user of processes
nobody
Unix group of processes
nobody
启动
#/usr/local/php/sbin/php-fpm start
#/usr/local/nginx/sbin/nginx
#附nginx.conf配置
user web;
worker_processes 2;
error_log /www/error_logs/error.log;
events {
use epoll;
worker_connections 2048;
}
http {
include mime.types;
default_type application/octet-stream;
server_names_hash_bucket_size 64;
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 /www/access_logs/access.log;
charset utf-8;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
fastcgi_connect_timeout 60;
fastcgi_send_timeout 180;
fastcgi_read_timeout 180;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 128k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
fastcgi_temp_path /dev/shm;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 8k;
output_buffers 1 32k;
postpone_output 1460;
gzip_types text/plain application/x-javascript text/css text/html application/xml;
server {
listen 80;
server_name 123.123.123.123;
access_log /www/access_logs/ main;
location / {
root /www/
index index.php index.html index.htm;
}
#error_page 404 /usr/local/nginx/html/404.html;
#error_page 500 502 503 504 /usr/local/nginx/html/50x.html;
location ~ \.php$ {
root /www/
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
location /status {
stub_status on;
access_log off;
allow 123.123.123.123;
deny all;
}
}
}
用来做反向代理的一个配置
user nobody nobody;
worker_processes 2;
error_log logs/error.log notice;
pid logs/nginx.pid;
events {
use epoll;
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"';
client_header_buffer_size 1k;
large_client_header_buffers 4 4k;
gzip on;
gzip_min_length 1100;
gzip_buffers 4 8k;
gzip_types text/plain;
output_buffers 1 32k;
postpone_output 1460;
access_log logs/access.log main;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 60;
upstream mysvr1 {
server 192.168.1.225:81;
}
upstream mysvr2 {
server 192.168.1.224;
}
server {
listen 80;
server_name 192.168.1.225 ;
charset utf-8;
access_log logs/access.log main;
location / {
if ($http_host ~ "^www\.123\.com$") {
proxy_pass ;
}
if ($http_host ~ "^www\.456\.com\.cn$") {
proxy_pass ;
}
proxy_pass ;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
proxy_buffer_size 4k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
location /status {
stub_status on;
}
}
}
附:部分内容解释:
#运行用户
user www www;
#工作线程
worker_processes 5;
#错误日志 debug模式
error_log logs/error.log debug;
# 记录Nginx主进程的ID
pid logs/nginx.pid;
events {
#最大连接数
worker_connections 8192;
#运行模式 use [ kqueue | rtsig | epoll | /dev/poll | select | poll ];
# epoll linux only
# 推荐使用epoll
use epoll;
}
http{
#导入配置文件
include conf/mime.types;
#默认类型
default_type application/octet-stream;
#主访问日志
log_format main ‘$remote_addr - $remote_user [$time_local] ‘
‘”$request” $status $bytes_sent ‘
‘”$http_referer” “$http_user_agent” ‘
‘”$gzip_ratio”‘;
#下载日志
log_format download ‘$remote_addr - $remote_user [$time_local] ‘
‘”$request” $status $bytes_sent ‘
‘”$http_referer” “$http_user_agent” ‘
‘”$http_range” “$sent_http_content_range”‘;
#客户端 header 请求超时时间
client_header_timeout 3m;
#客户端 内容 请求超时时间
client_body_timeout 3m;
#客户端发送请求超时时间 established 状态还没有发送回应
send_timeout 3m;
#打开gzip模式
gzip on;
#压缩级别 1-9 1最快 9最慢
gzip_comp_level 5;
#回送给客户端最小的gzip压缩大小
gzip_min_length 1100;
#设置gzip缓存的大小 默认是 4-8k之间
gzip_buffers 4 8k;
#需要使用Gzip压缩的内容Mime集合 每种类型中间用” “空格分割
gzip_types text/plain;
#Linux 2.4+ 可设置 可通过调用内核级 sendfile() 来提高性能
sendfile on;
#freebsd 或 基于TCP_CORK的linux系统可使用
tcp_nopush on;
#只在keep-alive的链接状态中使用
tcp_nodelay on;
#设置保留链接超时时间为75秒 设置header超时时间为20秒
keepalive_timeout 75 20;
#默认虚机配置
server {
#默认虚机端口
listen 80 default;
server_name _ *;
#设置主访问日志,没有独立设置的虚机都将记录与此
access_log logs/default.access.log main;
#设置错误页面路径
error_page 404
location / {
index index.html;
root /var/www/default/htdocs;
}
location /i/ {
#设置别名 /i 的访问实际路径是 /spool/w3/images/
alias /spool/w3/images/;
}
}
#设置一个虚拟机
server {
#监听端口
listen 80;
#虚拟机域名
server_name big.server.com;
#访问日志 使用main日志记录格式
access_log logs/big.server.access.log main;
#location 根据不同的URI 提供不同的设置 通过正则匹配
location / {
#设置默认首页
index index.html;
#设置内容根路径
root /var/www/domain1.com/htdocs;
}
#后缀为jpg|jpeg|gif|css|png|js|ico|html的文件作为静态文件,缓存30天,并且不记录访问日志
location ~* ^.+.(jpg|jpeg|gif|css|png|js|ico|html)$ {
access_log off;
expires 30d;
}
#设置.ht权限文件禁止访问
location ~ /\.ht {
deny all;
}
}
#设置一组名称为big_server_com的服务群
upstream big_server_com {
#可以通过weight来设置权重,如果没有设置,系统将自动为你分配
server 127.0.0.3:8000 weight=5;
#设置该组服务离线
server 127.0.0.3:8001 down;
server 192.168.0.1:8000;
server 192.168.0.1:8001;
}
}
阅读(1646) | 评论(0) | 转发(0) |