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的服务器,就可以了。

2014年08月18日

Linode VPS从 Ubuntu 12.04 升级到 Ubuntu 14.04

Filed under: Linux — 标签:, , — admin @ 10:40

Linode VPS从 Ubuntu 12.04 升级到 Ubuntu 14.04

linode官网现在还是只有升级到Ubuntu 12.04的步骤
参考:
https://www.linode.com/docs/security/upgrading/how-to-upgrade-to-ubuntu-12-04-precise
升级到Ubuntu 14.04的步骤是一样的,但是升级过程中出现个错误信息,出错信息如下:

Error in sys.excepthook:
Traceback (most recent call last):
File “/tmp/update-manager-Ik4Dhk/DistUpgrade/DistUpgradeViewText.py”, line 108, in _handleException
“\n”.join(lines))
File “/tmp/update-manager-Ik4Dhk/DistUpgrade/DistUpgradeViewText.py”, line 142, in error
print(twrap(summary))
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-5: ordinal not in range(128)

Original exception was:
Traceback (most recent call last):
File “/tmp/update-manager-Ik4Dhk/trusty”, line 10, in <module>
sys.exit(main())
File “/tmp/update-manager-Ik4Dhk/DistUpgrade/DistUpgradeMain.py”, line 230, in main
app = DistUpgradeController(view, options, datadir=options.datadir)
File “/tmp/update-manager-Ik4Dhk/DistUpgrade/DistUpgradeController.py”, line 126, in __init__
self._view.updateStatus(_(“Reading cache”))
File “/tmp/update-manager-Ik4Dhk/DistUpgrade/DistUpgradeViewText.py”, line 122, in updateStatus
print(msg)
UnicodeEncodeError: ‘ascii’ codec can’t encode characters in position 0-5: ordinal not in range(128)
=== Command detached from window (Fri Aug 15 11:42:55 2014) ===
=== Command terminated with exit status 1 (Fri Aug 15 11:42:55 2014) ===

在网上找资料看了说是没设置LC_ALL导致的。
参考:
http://blueecho.info/wp/?p=78

修改/root/.bashrc文件

命令 vi /root/.bashrc

按A,然后在文件末尾添加

export LC_ALL=C

按Esc,再按冒号和W和Q,

再运行  source /root/.bashrc 使修改后的文件生效。

然后再运行screen命令,再运行 sudo do-release-upgrade。

 

 

2010年11月17日

在Ubuntu10.04上通过mysql源代码进行编译安装

Filed under: Linux,mysql — 标签:, , , , — lizongbo @ 00:10

在Ubuntu10.04上通过mysql源代码进行编译安装MySQL Community Server

操作系统是linode上的Ubuntu 10.04,
MySQL Community Server目前最新正式版为:mysql 5.1.51 GA.
源代码下载地址为:
http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz

来源:http://www.mysql.com/downloads/mirror.php?id=394595#mirrors
http://www.mysql.com/downloads/

1.先下载源代码到本地:
root@618119.com:/usr/local/app# wget http://dev.mysql.com/get/Downloads/MySQL-5.1/mysql-5.1.51.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
2.解压mysql-5.1.51.tar.gz到/usr/local/app/mysql-5.1.51:
root@618119.com:/usr/local/app# tar -zxvf mysql*
3.进入解压得到的源码目录中:
root@618119.com:/usr/local/app# cd mysql*
4.运行configure进行检查:
root@618119.com:/usr/local/app/mysql-5.1.51# ./configure -prefix=/usr/local/app/mysql -with-charset=utf8 -with-collation=utf8_general_ci -with-extra-charsets=latin1
提示信息:checking for termcap functions library… configure: error: No curses/termcap library found
5.安装libncurses5-dev进行解决:
root@618119.com:/usr/local/app/mysql-5.1.51# sudo apt-get install libncurses5-dev
6.在编译安装nginx时候已经安装了 gcc libc6-dev build-essential 组件
直接开始运行make编译源代码:
root@618119.com:/usr/local/app/mysql-5.1.51# make
7.等待一段时间后,源码编译完成,运行make install进行安装:
root@618119.com:/usr/local/app/mysql-5.1.51# make install
8.复制系统服务脚本:
root@618119.com:/usr/local/app/mysql# cp /usr/local/app/mysql/share/mysql/mysql.server  /etc/init.d/mysql
9.再运行命令: sudo /usr/sbin/update-rc.d -f mysql defaults,将mysql安装为默认服务。
root@618119.com:/usr/local/app/mysql# sudo /usr/sbin/update-rc.d -f mysql defaults
perl: warning: Setting locale failed.
perl: warning: Please check that your locale settings:
LANGUAGE = (unset),
LC_ALL = (unset),
LANG = “zh_CN.UTF-8”
are supported and installed on your system.
perl: warning: Falling back to the standard locale (“C”).
Adding system startup for /etc/init.d/mysql …
/etc/rc0.d/K20mysql -> ../init.d/mysql
/etc/rc1.d/K20mysql -> ../init.d/mysql
/etc/rc6.d/K20mysql -> ../init.d/mysql
/etc/rc2.d/S20mysql -> ../init.d/mysql
/etc/rc3.d/S20mysql -> ../init.d/mysql
/etc/rc4.d/S20mysql -> ../init.d/mysql
/etc/rc5.d/S20mysql -> ../init.d/mysql
10.复制默认配置到/etc目录:
root@618119.com:/usr/local/app/mysql# cp /usr/local/app/mysql/share/mysql/my-medium.cnf /etc/my.cnf
11:添加名字为mysql的用户:
root@618119.com:/usr/local/app/nginx# sudo adduser –system –no-create-home –disabled-login –disabled-password –group mysql
12.初始化数据库(如果没初始化,启动mysql会提示“Manager of pid-file quit without updating file”):
root@618119.com:/usr/local/app/mysql/bin# ./mysql_install_db –user=mysql
Installing MySQL system tables…
101022 15:24:16 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK
Filling help tables…
101022 15:24:16 [Warning] ‘–skip-locking’ is deprecated and will be removed in a future release. Please use ‘–skip-external-locking’ instead.
OK

To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system

PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:

/usr/local/app/mysql/bin/mysqladmin -u root password ‘new-password’
/usr/local/app/mysql/bin/mysqladmin -u root -h 618119.com password ‘new-password’

Alternatively you can run:
/usr/local/app/mysql/bin/mysql_secure_installation

which will also give you the option of removing the test
databases and anonymous user created by default.  This is
strongly recommended for production servers.

See the manual for more instructions.

You can start the MySQL daemon with:
cd /usr/local/app/mysql ; /usr/local/app/mysql/bin/mysqld_safe &

You can test the MySQL daemon with mysql-test-run.pl
cd /usr/local/app/mysql/mysql-test ; perl mysql-test-run.pl

Please report any problems with the /usr/local/app/mysql/bin/mysqlbug script!

13.启动mysql数据库.
root@618119.com:/usr/local/app/mysql/bin# sudo /etc/init.d/mysql start

14.命令行进入数据库进行测试:
root@618119.com:/usr/local/app/mysql/bin# ./mysql
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.51-log Source distribution

Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
This software comes with ABSOLUTELY NO WARRANTY. This is free software,
and you are welcome to modify and redistribute it under the GPL v2 license

Type ‘help;’ or ‘\h’ for help. Type ‘\c’ to clear the current input statement.

mysql> show databases;
+——————–+
| Database           |
+——————–+
| information_schema |
| mysql              |
| test               |
+——————–+
3 rows in set (0.00 sec)

mysql> quit
Bye

15.运行mysql自带的测试脚本需要等的时间比较久:
root@618119.com:/usr/local/app/mysql# cd /usr/local/app/mysql/mysql-test ; perl mysql-test-run.pl
测试结果是1000多项只有600项通过:
main.mysql_client_test                   [ fail ]
Test ended at 2010-10-22 15:35:39

CURRENT_TEST: main.mysql_client_test
mysqltest: At line 15: command “$MYSQL_CLIENT_TEST –getopt-ll-test=25600M >> $MYSQLTEST_VARDIR/log/mysql_client_test.out.log 2>&1” failed

Output from before failure:
exec of ‘/usr/local/app/mysql/bin/mysql_client_test –defaults-file=/usr/local/app/mysql/mysql-test/var/my.cnf –testcase –vardir=/usr/local/app/mysql/mysql-test/var –getopt-ll-test=25600M >> /usr/local/app/mysql/mysql-test/var/log/mysql_client_test.out.log 2>&1’ failed, error: 256, status: 1, errno: 0

The result from queries just before the failure was:
SET @old_general_log= @@global.general_log;
SET @old_slow_query_log= @@global.slow_query_log;

– saving ‘/usr/local/app/mysql/mysql-test/var/log/main.mysql_client_test/’ to ‘/usr/local/app/mysql/mysql-test/var/log/main.mysql_client_test/’

Only  653  of 1415 completed.
mysql-test-run: *** ERROR: Not all tests completed
166.使用符号链接方便直接运行 mysql命令:
root@618119.com:/usr/local/app/mysql# sudo ln -s /usr/local/app/mysql/bin/mysql /usr/bin/
root@618119.com:/usr/local/app/mysql# sudo ln -s /usr/local/app/mysql/bin/mysqladmin /usr/bin/

开始在resin上安装phpMyAdmin:
phpMyAdmin最新版本 3.3.7:
下载地址:http://nchc.dl.sourceforge.net/project/phpmyadmin/phpMyAdmin/3.3.7/phpMyAdmin-3.3.7-all-languages.tar.gz
来源:
http://www.phpmyadmin.net/home_page/index.php

下载后解压到:lizongbo@618119.com:/etc/init.d$ cd /usr/local/app/resin/webapps
然后改名:
lizongbo@618119.com:/usr/local/app/resin/webapps$ mv phpMyAdmin-3.3.7-all-languages/ phpMyAdmin

尝试resin最新版跑phpMyAdmin跑不了。
还是想办法配置nginx吧,可以参考:
http://www.linuxidc.com/Linux/2010-03/25161.htm
mysql JDBC驱动:
最新正式版为:Connector/J 5.1.13
下载地址:http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector- java-5.1.13.tar.gz/from/http://www.mirrorservice.org/sites/ftp.mysql.com/
来源:http://www.mysql.com/downloads/connector/j/

root@618119.com:/usr/local/app# wget http://www.mirrorservice.org/sites/ftp.mysql.com/Downloads/Connector-J/mysql-connector-java-5.1.13.tar.gz
root@618119.com:/usr/local/app# tar -zxvf mysql-c*
复制jdbc驱动到resin的lib目录:
root@618119.com:/usr/local/app/mysql-connector-java-5.1.13# cp /usr/local/app/mysql-connector-java-5.1.13/mysql-connector-java-5.1.13-bin.jar /usr/local/app/resin/lib

Older Posts »

Powered by WordPress