How to setup and configure Ejabberd on EC2 AWS?
Prerequisites -
- AWS Account
- EC2 instance
- Putty
Ec2 instance AMI details -
Ubuntu Server 16.04 LTS (HVM), SSD Volume Type — ami-00b7e666605d33085
Ubuntu Server 16.04 LTS (HVM),EBS General Purpose (SSD) Volume Type. Support available from Canonical (http://www.ubuntu.com/cloud/services).
1. Setup EC2 instance
Get your Ec2 instance running as you usually do. I have mentioned AMI details above which was used by me.
2. Login to your EC2 instance with Putty.
3. Install Ejabberd
sudo apt-get -y install ejabberd
Note- If you get any error like “package not found” then run sudo apt-get update and try the above command again.
4. Edit Config File to setup admin user and host
sudo vi /etc/ejabberd/ejabberd.yml
Make below changes in the config file
Note — Be very careful while editing the ‘yml’ file as it has indent based syntax.
hosts:
- “localhost”
acl:
##
## The ‘admin’ ACL grants administrative privileges to XMPP accounts.
## You can put here as many accounts as you want.
##
admin:
user:
- “admin”: “localhost”
4. Restart Ejabberd
sudo service ejabberd restart
5. Now register your admin user
sudo ejabberdctl register <username> <host> <password>
E.g
sudo ejabberdctl register admin localhost eja123
6. Make sure you have opened ports 5222 and 5280 on AWS for your EC2 instance from its security group.
7. Login to Admin Console Panel
1. Visit https://<your-ip-address>:5280/admin/ in your browser
2. Username — <username>@<host> E.g admin@localhost
3. Password — <password you set while registering>
That’s it, If you see console panel you have completed your setup.
Extra Points -
1. If you mess up your installation or if you mess up while editing your config file and you are not able to revert your changes. Then simply remove Ejabberd and try again from step 1.
To remove Ejabberd run following commands
sudo apt-get purge ejabberd
sudo apt-get autoremove
2. Other useful commands
sudo service ejabberd <start/stop/status>
OR
sudo ejabberdctl <start/stop/status>
3. To check Ejabberd Version
sudo ejabberdctl status
Anonymous Login Support (as well as authenticated login)-
sudo vi /etc/ejabberd/ejabberd.yml
Make below changes in the config file
auth_method: internal
host_config:
“localhost”:
auth_method:
- internal
- anonymous
anonymous_protocol: sasl_anon
allow_multiple_connections: false
To Enable History -
mod_mam:
default: always