1. install
install pcre
./configure
make && make install
install nginx
./configure –prefix=/usr/local/nginx –with-zlib=/zlib_soure_dir/
make && make install
2. Install FastCgi init
configure && make Lighttpd
cp /lighttpd_path/src/spawn-fcgi —-> /spawn_fcgi_target_path/
edit fastcgi shell
/spawn_fcgi_target_path/spawn-fcgi -a 127.0.0.1 -p 8002 -C 20 -u nobody -g nobody -f /php_fastcgi_mode_path/bin/php-cgi
3. Control Nginx
Reload new nginx.conf on the running
ps -aux | grep ‘(PID|nginx)’
kill -HUB PID
Upgrading new version server on the running
Kill -HUP old_master_process kill -QUIT new_master_process Kill -TERM new_master_process
4. nginx.conf 常用设置说明
#运行用户 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 http://domain/error_404.html 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; } } (编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|