Thursday, November 24, 2011

add swap on AWS EC2 for CentOS

To add 512MB swap for example:

$ sudo dd if=/dev/zero of=/usr/swap0 bs=1M count=512
$ mkswap /usr/swap0
$ sudo swapon /usr/swap0

To use "top" command, you can see the swap is on.

To make it available on restart. Add following line to the end of your /etc/fstab file

/usr/swap0    swap    swap   defaults 0 0

Monday, November 14, 2011

install ejabberd on CentOS for EC2 server

1. download and install ejabberd

$ git clone git://git.process-one.net/ejabberd/mainline.git ejabberd
$ cd ejabberd
$ git checkout -b 2.1.x origin/2.1.x
$ cd src
$ ./configure
$ make
$ sudo make install

if you miss expat package,

$ wget http://fossies.org/unix/www/expat-2.0.1.tar.gz
$ gzip -d expat-2.0.1.tar.gz
$ tar xvf expat-2.0.1.tar
$ ./configure
$ make
$ sudo make install

$ sudo ejabberdctl start
$ sudo ejabberdctl status

to make sure ejabberd is installed successfully.


1.1 make a script file in /etc/init.d

$ cd src
$ sudo cp ejabberd.init /etc/init.d/ejabberd
$ cd /etc/rc2.d (and rc3.d, rc4.d, rc5.d, rc6.d
$ ln -s ../init.d/ejabberd S97ejabberd

$ cd /etc/rc0.d (and rc1.d)
$ ln -s ../init.d/ejabberd K87ejabberd

2. configuration

$ cd /etc
$ sudo vi ejabberd/ejabberd.cfg

add your domain name in the configuration file, such as

{hosts, ["url0.info", "localhost"]}.

3. register an user account

$ ejabberdctl register USERNAME DOMAINNAME PASSWORD

for example:

$ ejabberdctl register admin url0.info passwd

4. start the server

$ cd /etc/init.d
$ sudo ./ejabberd start

make sure the server process is keep running.

$ ps -ef | grep ejabberd root 1341 1 4 08:45 ? 00:00:00 /usr/local/lib/erlang/erts-5.8.3/bin/beam -K true -P 250000 -- -root /usr/local/lib/erlang -progname erl -- -home //var/lib/ejabberd -- -sname ejabberd@localhost -noshell -noinput -noshell -noinput -pa //lib/ejabberd/ebin -mnesia dir "//var/lib/ejabberd" -kernel inet_dist_use_interface {127,0,0,1} -s ejabberd -sasl sasl_error_logger {file,"//var/log/ejabberd/erlang.log"} -smp auto start

or

$ sudo ejabberdctl status
The node ejabberd@localhost is started with status: started ejabberd 2.1.x is running in that node

5. testing

$ epmd -names
epmd: up and running on port 4369 with data: name ejabberd at port 59502

$ sudo netstat -tpan | grep "beam\|epmd"
tcp 0 0 127.0.0.1:59502 0.0.0.0:* LISTEN 1341/beam
tcp 0 0 0.0.0.0:4369 0.0.0.0:* LISTEN 1131/epmd
tcp 0 0 0.0.0.0:5269 0.0.0.0:* LISTEN 1341/beam
tcp 0 0 0.0.0.0:5280 0.0.0.0:* LISTEN 1341/beam
tcp 0 0 10.146.47.148:59840 0.0.0.0:* LISTEN 965/beam
tcp 0 0 0.0.0.0:5222 0.0.0.0:* LISTEN 1341/beam
tcp 0 0 127.0.0.1:4369 127.0.0.1:52165 ESTABLISHED 1131/epmd
tcp 0 0 10.146.47.148:5280 210.71.153.52:49533 ESTABLISHED 1341/beam
tcp 0 0 127.0.0.1:52165 127.0.0.1:4369 ESTABLISHED 1341/beam

6. open your TCP ports in your Security Groups for the ports you use for xmpp server or web binding.

such as 5280, 5222 and 59502 (custom TCP ports).



7. open web page from your browser, such as

http://url0.info:5280/admin



you need to login with your admin user name and password, which you create one in step 3.

8. Good reference for testing server: http://lists.jabber.ru/pipermail/ejabberd/2007-October/003186.html

Tuesday, November 8, 2011

how to install Expat library on aws ec2 CentOS server.

how to install Expat library on aws ec2 CentOS server.

1. download the source code from http://fossies.org/unix/www/expat-2.0.1.tar.gz
2. gzip -d expat-2.0.1.tar.gz
3. tar xvf expat-2.0.1.tar
4. cd expat-2.0.1
5. ./configure
6. make
7. sudo make install

It's a requirement for build openfire on CentOS for a xmpp (jabber) server.