Chinaunix首页 | 论坛 | 博客
  • 博客访问: 788072
  • 博文数量: 434
  • 博客积分: 11187
  • 博客等级: 上将
  • 技术积分: 5221
  • 用 户 组: 普通用户
  • 注册时间: 2009-02-19 01:00
文章分类

全部博文(434)

文章存档

2016年(2)

2013年(1)

2012年(115)

2011年(195)

2010年(32)

2009年(89)

分类: LINUX

2011-06-21 11:17:44

前面搭建好了postfix整套系统,现在就将它的web端从apache移置到nginx后台.
extmail extman放在/var/www/extsuite目录下。
extmail extman的FCGI脚本是要启动/var/www/extsuite/extmail/dispatch-init,并且配置端口为8888。

需要先安装:# echo "install FCGI" |perl -MCPAN -e shell
#/var/www/extsuite/extmail/dispatch-init start


#vi /usr/local/nginx/conf/nginx.conf
  1. worker_processes 1;
  2. worker_rlimit_nofile 51200;
  3. events {
  4.      use epoll;
  5.       worker_connections 51200;
  6. }
  7. http {
  8.     include mime.types;
  9.     default_type application/octet-stream;
  10.     log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  11.                       '$status $body_bytes_sent "$http_referer" '
  12.                       '"$http_user_agent" "$http_x_forwarded_for"';
  13.     access_log logs/access.log main;
  14.     sendfile on;
  15.     #tcp_nopush on;
  16.     send_timeout 3m;
  17.     keepalive_timeout 65;
  18.     #gzip on;
  19. server {
  20.         listen 80;
  21.         server_name mail.test.com;
  22.         root /var/www/extsuite/extmail/html;
  23.         index index.html index.htm index.php;
  24.         access_log logs/mail.harrytest.log main;
  25.         keepalive_timeout 60;
  26.         fastcgi_connect_timeout 300;
  27.         fastcgi_buffer_size 128k;
  28.         fastcgi_buffers 16 128k ;
  29.         fastcgi_send_timeout 300;
  30.         fastcgi_read_timeout 300;
  31.         fastcgi_busy_buffers_size 128k;
  32.         fastcgi_temp_file_write_size 128k;
  33.         # charset gb2312;
  34.         if (-d $request_filename){
  35.                  rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
  36.                 }

  37.         location /extmail/cgi {
  38.               #fastcgi_pass unix:/tmp/php-cgi.sock;
  39.                 fastcgi_pass 127.0.0.1:8888;
  40.                 fastcgi_index index.cgi;
  41.                 fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
  42.                 include fastcgi.conf;
  43.           }
  44.     location ^~ /extmail {
  45.                 alias /var/www/extsuite/extmail/html/;
  46.          }
  47.     location /extman/cgi {
  48.                 fastcgi_pass 127.0.0.1:8888;
  49.                 fastcgi_index index.cgi;
  50.                 fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extman/cgi/$fastcgi_script_name;
  51.                 include fastcgi.conf;
  52.         }
  53.        location ^~ /extman {
  54.                 alias /var/www/extsuite/extman/html/;
  55.          }
  56. #------ nginx.conf  phpadmin --------#
  57.         location  /phpadmin{
                     root  /var/www/;
                     index index.php ;
             }


            location ~ ^/phpadmin/.*\.(php|php5)?$
            {
                    root /var/www/;
                    fastcgi_pass  127.0.0.1:9000;
                    fastcgi_index index.php;
                    include fastcgi.conf;
            }

    #------ nginx.conf  phpadmin end --------#
          
    location ~ .*\.(php|php5)?$
  1.      {
  2.       fastcgi_pass 127.0.0.1:9000;
  3.       fastcgi_index index.php;
  4.        include fastcgi.conf;
  5.      }
  6.     
  7.     #location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  8.     #  {
  9.     #            expires 30d;
  10.     #  }
  11.     
  12.    #location ~ .*\.(js|css)?$
  13.     #   {
  14.     #   expires 1h;
  15.     #   }
  16.   }
  17. }
更改为:
  1. worker_processes 2;
  2. worker_rlimit_nofile 51200;
  3. events {
  4.      use epoll;
  5.       worker_connections 51200;
  6. }
  7. http {
  8.     include mime.types;
  9.     default_type application/octet-stream;
  10.     log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  11.                       '$status $body_bytes_sent "$http_referer" '
  12.                       '"$http_user_agent" "$http_x_forwarded_for"';
  13.     access_log logs/access.log main;
  14.     sendfile on;
  15.     #tcp_nopush on;
  16.     send_timeout 3m;
  17.     keepalive_timeout 65;
  18.     #gzip on;
  19. server {
  20.         listen 80;
  21.         server_name mail.madeforchina.com;
  22.         root /var/www/extsuite/extmail/html/;
  23.         index index.html index.htm index.php index.cgi;

  24.         access_log logs/mail.madeforchina.log main;
  25.         keepalive_timeout 60;

  26.         fastcgi_connect_timeout 300;
  27.         fastcgi_buffer_size 128k;
  28.         fastcgi_buffers 16 128k ;
  29.         fastcgi_send_timeout 300;
  30.         fastcgi_read_timeout 300;
  31.         fastcgi_busy_buffers_size 128k;
  32.         fastcgi_temp_file_write_size 128k;
  33.         # charset gb2312;

  34.         if (-d $request_filename){
  35.                  rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
  36.                }
  37.          location /extmail {
  38.                 alias /var/www/extsuite/extmail/html/;
  39.          }

  40.         location /extmail/cgi {
  41.                 alias /var/www/extsuite/extmail/cgi/;
  42.                 #fastcgi_pass 127.0.0.1:8888;
  43.                 #fastcgi_index index.cgi;
  44.                 #fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extmail/cgi/$fastcgi_script_name;
  45.                 #include fastcgi.conf;
  46.           }
  47.         location ~.*\.cgi$ {
  48.  
  49.              fastcgi_pass 127.0.0.1:8888;
  50.              fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  51.              include fastcgi.conf;
  52.         }
  53.          
  54.          location /extman {
  55.                 alias /var/www/extsuite/extman/html/;
  56.          }
  57.         location /extman/cgi {
  58.                 alias /var/www/extsuite/extman/cgi/;
  59.                 #fastcgi_pass 127.0.0.1:8888;
  60.                 #fastcgi_index index.cgi;
  61.                 #fastcgi_param SCRIPT_FILENAME /var/www/extsuite/extman/cgi/$fastcgi_script_name;
  62.                 #include fastcgi.conf;
  63.         }

  64.         location ~ .*\.(php|php5)?$ {
  65.                 fastcgi_pass 127.0.0.1:9000;
  66.                 fastcgi_index index.php;
  67.                 include fastcgi.conf;
  68.         }

  69.         location /NginxStatus {
  70.                         stub_status on;
  71.                         access_log off;
  72.                         allow 1.2.3.4;
  73.                         deny all;
  74.                 }

  75.  }

  76. }


#vi /usr/local/nginx/conf/fastcgi.conf
  1. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  2. fastcgi_param QUERY_STRING $query_string;
  3. fastcgi_param REQUEST_METHOD $request_method;
  4. fastcgi_param CONTENT_TYPE $content_type;
  5. fastcgi_param CONTENT_LENGTH $content_length;

  6. fastcgi_param SCRIPT_NAME $fastcgi_script_name;
  7. fastcgi_param REQUEST_URI $request_uri;
  8. fastcgi_param DOCUMENT_URI $document_uri;
  9. fastcgi_param DOCUMENT_ROOT $document_root;
  10. fastcgi_param SERVER_PROTOCOL $server_protocol;

  11. fastcgi_param GATEWAY_INTERFACE CGI/1.1;
  12. fastcgi_param SERVER_SOFTWARE nginx/$nginx_version;

  13. fastcgi_param REMOTE_ADDR $remote_addr;
  14. fastcgi_param REMOTE_PORT $remote_port;
  15. fastcgi_param SERVER_ADDR $server_addr;
  16. fastcgi_param SERVER_PORT $server_port;
  17. fastcgi_param SERVER_NAME $server_name;

  18. # PHP only, required if PHP was built with --enable-force-cgi-redirect
  19. fastcgi_param REDIRECT_STATUS 200;
修改dispatch-init,这里需要注意postfix的用户和组:
#vi /var/www/extsuite/extmail/dispatch-init
  1. MAXFORK=10
  2. MINFORK=2
  3. MAXREQS=25
  4. TIMEOUT=360
  5. PORT=8888
  6. SU_UID=vmail
  7. SU_GID=vmail

  8. PATH=/bin:/usr/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/local/sbin
  9. BASE=/var/www/extsuite/extmail
  10. BIN=dispatch.fcgi
  11. PID_FILE=/$BASE/$BIN.pid

  12. export PATH=$PATH

  13. ........
ExtMail中sort2name问题:  
参考:
问题:Undefined subroutine &Ext::Utils::sort2name called at /var/www/extsuite/extmail/libs/Ext/App/Folders.pm line 387
这个问题一般出现在webmail和后台都同时配置了FCGI或cgi server,然后在某个时刻先访问了后台再访问webmail,造成@INC问题后就容易再次出现了!

最后查出来最可能的原因是持续环境下,Webmail和后台的同名perl模块Utils.pm内容不一致导致的。后台的Utils.pm里没有 sort2name和name2sort函数的定义,在Perl持续环境下,@INC中第一个能找到Ext::Utils的路径如果不是 extmail/libs而是extman/libs,那么对sort2name的调用就因为找不到对应的定义而报上面的错。

如何解决?
问题一旦确定是搜索路径下Utils.pm缺少sort2name的定义,那么解决就很容易了,无非有几个:
1)将extmail的Utils拷贝到extman目录下,保持两边同步
2)将Webmail和后台公共用到的模块抽出来放到一个公共目录,避免名字空间重叠的现象
3)模块改名,例如extman/libs/Ext/Utils.pm可以改为extman/libs/Ext/ManUtils.pm,避免名字空间重叠

阅读(2796) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~