lizongbo at 618119.com 工作,生活,Android,前端,Linode,Ubuntu,nginx,java,apache,tomcat,Resin,mina,Hessian,XMPP,RPC

2014年09月15日

在Linode VPS上安装配置Apache James 3.0

Filed under: Java,Linux — 标签:, , — admin @ 14:50

在Linode VPS上安装配置Apache James 3.0,服务器是Linode的VPS,操作系统是Ubuntu 14.04 64位
1.先下载

http://mirrors.ibiblio.org/apache//james/apache-james/3.0beta4/apache-james-3.0-beta4-app.tar.gz

来自:http://james.apache.org/download.cgi#Apache_James_Server

root@618119.com:/usr/local/app# wget http://mirrors.ibiblio.org/apache//james/apache-james/3.0beta4/apache-james-3.0-beta4-app.tar.gz

2.解压:

root@618119.com:/usr/local/app# tar -zxvf ./apache-james-3.0-beta4-app.tar.gz

3.修改配置文件:
进入/usr/local/app/apache-james-3.0-beta4/conf 目录。
先把配置文件模板复制一份成配置文件

root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./dnsservice-template.conf ./dnsservice.conf
root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./domainlist-template.conf ./domainlist.conf
root@618119.com:/usr/local/app/apache-james-3.0-beta4/conf# cp ./smtpserver-template.conf ./smtpserver.conf

然后分别编辑这三个文件。
dns server 增加
<server>8.8.8.8</server>
<server>114.114.114.114</server>

domainlist.conf修改为:
<!– XML based implementation for DomainList –>
<domainlist class=”org.apache.james.domainlist.xml.XMLDomainList”]] >
<domainnames>
<domainname>mail.lizongbo.com</domainname>
<domainname>lizongbo.com</domainname>
</domainnames>
<autodetect>true</autodetect>
<autodetectIP>true</autodetectIP>
<defaultDomain>mail.lizongbo.com</defaultDomain>
</domainlist>

(实际发现这个没效果,还是通过命令加域名比较靠谱)
smtpserver.conf
增加如下配置:
<authRequired>announce</authRequired>
<verifyIdentity>true</verifyIdentity>

4.由于服务器用的jdk版本较高,会触发一个bug。

因此需要下载 http://jaxb.java.net/2.1.13/JAXB2_20100510.jar 提取jaxb-impl.jar 放到 james 的lib目录下面:
quickli-nb:lib lizongbo$ scp ./jaxb-impl.jar root@lizongbo.com:/usr/local/app/apache-james-3.0-beta4/lib

参考:
http://james.apache.org/server/3/install.html

5.运行测试

启动还是出错
于是下载最新的SNAPSHOT版本:

http://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

参考:http://stackoverflow.com/questions/16154201/start-apache-james-with-jdk-1-7

root@618119.com:/usr/local/app# wget http://repository.apache.org/content/repositories/snapshots/org/apache/james/james-server-app/3.0.0-beta5-SNAPSHOT/james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

root@618119.com:/usr/local/app# tar -zxvf ./james-server-app-3.0.0-beta5-20140913.003752-643-app.tar.gz

把改好的配置同步过去

root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/dnsservice.conf  /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf
root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/domainlist.conf /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf
root@618119.com:/usr/local/app# cp /usr/local/app/apache-james-3.0-beta4/conf/smtpserver.conf /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/conf

此时不需要更新jaxb也能正常启动了。

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james start
Starting Apache James :: Server :: App…
./james: 1: eval: /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/./wrapper-linux-x86-32: not found
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# sudo apt-get install libc6 libc6-dev

6.通过命令来加东西

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adddomain email.lizongbo.com
adddomain command executed sucessfully in 262 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listdomains
email.lizongbo.com
localhost.
96.126.96.170
127.0.0.1

listdomains command executed sucessfully in 3571 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adddomain mail.lizongbo.com
adddomain command executed sucessfully in 253 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listdomains
email.lizongbo.com
mail.lizongbo.com
localhost.
96.126.96.170
127.0.0.1

listdomains command executed sucessfully in 165 ms.

7.先添加域名,再添加测试账号

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser postmaster 618119
Error while execute command:
Given Username needs to contain a @domainpart
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser postmaster@mail.lizongbo.com 618119
adduser command executed sucessfully in 171 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 adduser admin@mail.lizongbo.com lizongbo
adduser command executed sucessfully in 164 ms.

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james-cli.sh  -h 127.0.0.1 -p 9999 listusers
admin@mail.lizongbo.com
postmaster@mail.lizongbo.com

8.配置wrapper.conf,替换 wrapper-linux-x86-32。

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# vi ../conf/wrapper.conf
(指定了java 启动命令来源:)
wrapper.java.command=/usr/local/app/jdk/bin/java

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# cp ./wrapper-linux-x86-64  ./wrapper-linux-x86-32
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./wrapper-linux-x86-32

不替换的话,启动会报错,因为服务器是64位的:

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin# ./james start
Starting Apache James :: Server :: App…
./james: 1: eval: /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/./wrapper-linux-x86-32: not found

9.然后再安装成系统服务:

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# ln -s /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/james /etc/init.d/james
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# ls /etc/init.d/james  -alh
lrwxrwxrwx 1 root root 62 Sep 14 04:38 /etc/init.d/james -> /usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT/bin/james
root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# service james start

root@618119.com:/usr/local/app/james-server-app-3.0.0-beta5-SNAPSHOT# service james restart
Stopping Apache James :: Server :: App…
Stopped Apache James :: Server :: App.
Starting Apache James :: Server :: App…

这样就成了系统服务了。

10.再在name.com  添加mx记录,将mail.lizongbo.com 的域名指向运行Apache James的服务器,就可以了。

Powered by WordPress