1、版权声明:

  • 本文版权归作者所有,如其他个人、第三方网站或媒体报刊等需转载全文或节选,为支持我们的工作,请务必注明如下信息:

2、关于此文

  • 本文档在2010年底就已经成型,由于工作的原因一直没有去整理,本文以EMOS1.5为基础,采用RPM安装方式,所涉及软件全部是OpenSource软件,版权以GPL为主,作为企业应用没有任何版权/法律问题。
  • 编写本文的初衷,因为使用Nginx的人越来越多,Extmail的虚拟主机部分在Nginx上面已经正常运行,因为之前Extmail团队对Nginx不熟悉,所有Dspam结合Nginx一直没有去配置。

安装Nginx

  • nginx源码安装和RPM的安装网上太多了,这里就不在介绍。

3、配置extmail虚拟主机

shell

# vi /etc/nginx/conf.d/extmail.conf

内容如下:

server {
    listen 80;
    server_name  mail.extmail.org;
    index index.html index.htm index.php index.cgi;
    root  /var/www/extsuite/extmail/html;
    access_log  /var/log/extmaillog.log;

    location /extmail/cgi {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             include               /etc/nginx/fcgi.conf;
         }
     location  /extmail {
             alias  /var/www/extsuite/extmail/html/;
         }
     location /extman/cgi {
             fastcgi_pass          127.0.0.1:8888;
             fastcgi_index         index.cgi;
             include               /etc/nginx/fcgi.conf;
         }
     location /extman {
             alias  /var/www/extsuite/extman/html/;
         }
}

编辑fcgi.conf文件

shell

# vi /etc/nginx/fcgi.conf

内容如下:

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx;

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

4、配置dspam_webui虚拟主机

shell

# vi /etc/nginx/conf.d/dspam.conf

内容如下:

server {
        listen 80;
        server_name dspam.extmail.org;
        access_log /var/log/dspam/access.log;
        error_log /var/log/dspam/error.log;

        root  /usr/share/dspam/webui/cgi-bin;
        index dspam.cgi;

    location ~ \.cgi$ {
        gzip off;
        fastcgi_pass 127.0.0.1:8899;
        fastcgi_index dspam.cgi;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        fastcgi_param REMOTE_USER       $remote_user;
        auth_basic "DSPAM Restricted Site";
        auth_basic_user_file /usr/share/dspam/webui/cgi-bin/.htpasswd;
        include /etc/nginx/fcgi.conf;
    }
}

修改dspam_webui的配置文件

shell

# cp /usr/share/dspam/webui/htdocs/* /usr/share/dspam/webui/cgi-bin/
# vi /usr/share/dspam/webui/cgi-bin/configure.pl

修改内容如下

$CONFIG{'WEB_ROOT'}     = "./";

5、配置Nginx支持perl FCGI

安装perl FCGI

shell

# perl -MCPAN -e 'install FCGI::ProcManager'
# wget http://www3.extmail.org/cgiwrap-fcgi.pl.tgz -P /usr/local/bin/
# cd /usr/local/bin/
# tar zxvf cgiwrap-fcgi.pl.tgz
# chmod +x cgiwrap-fcgi.pl
# ./cgiwrap-fcgi.pl > /dev/null 2>&1 &

备注:
如果非EMOS环境或没有安装perl-FCGI的,请用下面办法自行安装

shell

# perl -MCPAN -e 'install FCGI'

启动dispatch-init

shell

# /var/www/extsuite/extmail/dispatch-init start
# vi /etc/rc.local

添加以下内容:

/usr/local/bin/cgiwrap-fcgi.pl > /dev/null 2>&1 &
/var/www/extsuite/extmail/dispatch-init start

6、启动Nginx

检查配置文件是否有误

shell

# /usr/sbin/nginx -t /etc/nginx/nginx.conf

停止Apache和mini_http服务

shell

# service httpd stop
# service dspam-webd stop
# chkconfig httpd off
# chkconfig dspam-webd off

启动nginx

shell

# service nginx start
# chkconfig nginx on

现在在浏览器登录 http://dspam.extmail.org,就可以看到dspam的web界面了。

 
emos_migration_from_apache_to_nginx.txt · 最后更改: 2013/03/01 07:07 由 shaobo
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki