LinuxMint 17 安装 jabberd2 服务器与web客户端

说明:1-5步为安装web聊天服务,如不需要可跳过1-5步。


1. 安装nginx

sudo apt-get install nginx


2. 安装php5-fpm

sudo apt-get install php5-fpm


3. 安装jappix的文件

下载jappix。

 下载地址:http://jappix.org

将jappix的php源码拷贝到/usr/share/nginx/html下,完成文件安装。


4.  为jappix 配置nginx 

 nginx配置文件路径/etc/nginx/sites-enabled/default

配置文件添加修改:

server中:

inex index.php

locaation - /(app|i18n|log|test|tmp|tools)/ {

    deny all;

}

location / {

    try_files $uri $uri/ =404;

    index index.php;

}

location - \.php$ {

    fastcgi_pass unix:/var/run/php5-fpm.sock;

    fastcgi_index index.php;

    include fastcgi_params;

}

重启nginx.

sudo service nginx restart

5. 安装jappix 

a.安装前设置:

sudo kate /etc/php5/fpm/php.ini

修改:

post_max_size=100M

upload_max_size=100M

memory_limit=160M


b.在浏览器输入http://localhost.进入初次使用安装。

照提示一步一步安成设置,完成安装。


6. 安装 jabberd2 

 下载jabber2  源码备用。

下载地址:http://jabberd2.org

非编译安装:sudo apt-get install jabberd2 

非编译安装就完成了。

编译安装如下:

sudo apt-get install libpq-dev openssl libssl-dev libexpat-dev libidn11-dev libudns-dev libgsasl7-dev

./configure --enable-pgsql --enable-ssl --with-extra-include-path=./c2s/:usr/include/postgresql/

make

make install

 jabber用户

安装好后应是自动创建好了jabber用户与jabber用户组。

如没有添加:groupad jabber

userad -g jabber jabber

为jabber的 PID's和Logs新建目录

mkdir -p /usr/local/var/jabberd/pid/

chown R jabber:jabber /usr/local/var/jabberd/pid/


mkdir -p /usr/local/var/jabberd/log/

chown -R jabber:jabber /usr/local/var/jabberd/log/

jabberd 2 安装的缺少位置

/usr/local/etc/jabberd

设置配置文件的所有权

chown -R root:jabber /usr/local/etc/jabberd/*

chmod -R 640 /usr/local/etc/jabberd/*

7.配置domain

更改/etc/hostname:

更改为localhost



更改/etc/hosts:(注:localhost这个名字要与/etc/hostname中的名字一样,就是要改成电脑名。)

添加127.0.0.1   localhost.localdomain  localhost



完成后执行:

sudo service network-manager restart

sudo service networking restart


8. jabberd2 的一些设置

 主机名设置

在sm.xml

<sm>

         <local>

                       <id>computer_name(或localhost).localdomain</id>

在c2s.xml

<c2s>

           <local>

                        <id> computer_name(或localhost).localdomain</id>


9. 安装 postgresql

sudo apt-get install postgresql


10.给jabberd2 配置postgresql

注:如产生错误:

a. PostgreSql:createdb -U postgres mydb 错误:createdb: could not connect to database postgres: FATAL: P

b. psql -U myusername mydb 错误:psql: FATAL: Ident authentication failed for user "mypguser"
则:
sudo editor /etc/postgresql/9.3/main/pg_hba.conf
将其中的peer改成trust,完成上述错误的解决。
然后重启:sudo service postgresql restart

提供和配置PostgreSQL

PostgreSQL 和MySQL一样,提供一个非常易于管理的后端用于存储和验证. 和MySQL不同的是, PostgreSQL提供了更好的 unicode支持.

提供PostgreSQL

如果你使用PostgreSQL存储 和/或 验证请完成本节. 为了给Jabberd配置PostgreSQL, 你必须新建一个数据库,新建一个PostgreSQL用户并运行Jabberd 2分发包里带的PostgreSQL脚本.

为Jabberd新建数据库. (PostgreSQL服务器应该已经在运行):

      createdb -U postgres jabberd2

以上命令讲新建一个数据库,你可以在那个数据库运行接哦本来安装Jabberd PostgreSQL数据库.

N 注意: Unicode支持

如果你希望为你的PostgreSQL数据库激活Unicode支持, 把以上命令修改如下:
      createdb -U postgres -E UNICODE jabberd2

P 参数: PostgreSQL用户名和密码

新建你的Jabberd数据库用户, 输入以下命令:
      createuser -P -U postgres jabberd2

这个命令将初始化一个交互用户创建脚本. 当看到提示, 输入将来用于连接到你的PostgreSQL数据库的Jabberd的密码:

      Enter password for user "jabberd2":
      Enter it again:
      Shall the new user be allowed to create databases? (y/n) n
      Shall the new user be allowed to create more new users? (y/n) n
      CREATE USER

CREATE USER 信息表示命令执行成功.

在你的jabberd用户创建之后, 你已经准备好运行PostgreSQL安装脚本了. 这个脚本位于 '\[Jabberd Source Files\]\/tools'. 切换到 tools 目录并以jabberd2用户身份启动PostgreSQL控制台:

      psql -U jabberd2 jabberd2

然后, 从PostgreSQL控制台运行 db-setup.pgsql 脚本:

      jabberd2=>\i db-setup.pgsql

PostgreSQL现在准备好用于Jabberd了.

等下一步后可重启一下postgresql。

然后可用下面语句测试查入一个用户,但我查入后发现不能使用这个用户:

insert into authreg(username,realm,password) values('testuser1','localhost.localdomain','passowrd');

配置存储使用PostgreSQL(sm.xml)

如果你使用PostgreSQL存储,请完成本节. 大多数使用PostgreSQL存储的安装只需要设置驱动, 用户和密码.

在 sm.xml 里标为 Storage database configuration 的段落下, 确保 driver 是用 pgsql (PostgreSQL):

<sm>
        <!-- Storage database configuration -->
        <storage>
          <!-- By default, we use the MySQL driver for all storage -->
                               <driver>pgsql</driver>

P 参数: PostgreSQL用户名和密码

在  sm.xml 里标为  PostgreSQL driver configuration 的段落下, 把  secret 替换成你的PostgreSQL密码. 如果你不使用缺省用户(jabberd2)则还要修改用户名 :
      <!-- PostgreSQL driver configuration -->
      <pgsql>
        <!-- PostgreSQL connection info.
           For the rest of the options see
           http://www.postgresql.org/docs/8.0/interactive/libpq.html -->
        <conninfo>dbname=jabberd2 user=jabberd2 password=secret</conninfo>

       <!-- Database server host and port -->
        <host>localhost</host>
        <port>5432</port>
 
        <!-- Database name -->
        <dbname>jabberd2</dbname>
 
        <!-- Database username and password -->
        <user>jabberd2</user>
        <pass>secret</pass>
 
        <!-- Transaction support. If this is commented out, transactions
             will be disabled. This might make database accesses faster,
             but data may be lost if jabberd crashes. -->
        <transactions/>
      </pgsql>

注意只有你的PostgreSQL服务器运行在另一个主机上你才应该修改host设置. 只有你的PostgreSQL服务器运行在一个非标准端口(5432是PostgreSQL安装后的缺省端口)你才应该修改port设置. transaction support 段落则是不言自明的了.

现在Jabberd 2已经配置成使用PostgreSQL来存储了.

如果你希望使用一个不同于PostgreSQL的验证包, 跳到你选择的验证包:

否则, 继续到 4.5.3. 直接往下完成你的Jabberd 2配置.

配置验证使用PostgreSQL(c2s.xml)

如果你使用PostgreSQL来验证,请完成本节. Jabberd 2对于PostgreSQL验证配置的要求同上,除了包含在 c2s.xml 的信息.

在 c2s.xml 的 Authentication/registration database configuration (验证/注册 数据库配置)段落, 确保 driver 使用pgsql (PostgreSQL):

<c2s>
      <!-- Authentication/registration database configuration -->
      <authreg>
        <!-- Backend module to use -->
                             <module>pgsql</module>

P 参数: PostgreSQL用户名和密码

在  c2s.xml 的  PostgreSQL module configuration 段落, 把  secret 替换成你的PostgreSQL密码. 如果你不使用缺省用户(jabberd2)则还要修改用户名 :
<c2s>
    <pgsql>
      <!-- PostgreSQL connection info.
           For the rest of the options see
           http://www.postgresql.org/docs/8.0/interactive/libpq.html -->
      <conninfo>dbname=jabberd2 user=jabberd2 password=secret</conninfo>

      <!-- Alternatively you may set connection settings separately.
           These are used only in absence of 'conninfo' -->

      <!-- Database server host and port -->
      <host>localhost</host>
      <port>5432</port>

      <!-- Database name -->
      <dbname>jabberd2</dbname>

      <!-- Database username and password -->
      <user>jabberd2</user>
      <pass>secret</pass>
    </pgsql>

注意只有你的PostgreSQL服务器运行在另一个主机上你才应该修改host设置. 只有你的PostgreSQL服务器运行在一个非标准端口(5432是PostgreSQL安装后的缺省端口)你才应该修改port设置.

你的Jabberd 2的存储和验证配置现在完成了. 在转移到其他配置任务(例如 第五章 的配置SSL)之前,跳到 测试服务器 去开始测试你的服务器.


 

jabberd2 的postgresql的配置完成。

再重启服务:

sudo service postgresql restart

sudo service jabberd2 restart


11. 用gajim 创建测试用户

a. 安装GAJIM: sudo apt-get install GAJIM

b. 在GAJIM中的用户管理中,选择添加用户,选择创建一个新用户为添加用户。

c. 在弹出的对话框中输入服务器:localhost.localdomain(localhost 是本地主机名在/etc/hostname中修改),在自定主机名端口中输入127.0.0.1(或服务器IP) 与端口5222,点击forward.

d.输入username 与 password ,点击forward.

e.完成新用户注册


可照上面方法再添加一个用户,这样就可以完成消息发送测试。



jabberd2设置iptables防火墙:
sudo iptables -P INPUT DROP
sudo iptables -P OUTPUT ACCEPT
sudo iptables -P FORWARD DROP

sudo iptables -A OUTPUT -p tcp --sport 80 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 443 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 443 -j ACCEPT

sudo iptables -A OUTPUT -p tcp --sport 21 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 21 -j ACCEPT
sudo iptables -A OUTPUT -p tcp --sport 20 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 20 -j ACCEPT
sudo iptables -A INPUT -m state --state NEW,ESTABLISHED,RELATED -j ACCEPT

sudo iptables -A OUTPUT -p icmp -j ACCEPT
sudo iptables -A INPUT -p icmp -j ACCEPT
sudo iptables -A INPUT -i lo -p all -j ACCEPT
sudo iptables -A OUTPUT -o lo -p all -j ACCEPT

sudo iptables -A OUTPUT -p tcp --sport 5432 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 5432 -j ACCEPT


sudo iptables -A INPUT -p tcp -m tcp --dport 5222 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --dport 5222 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 5223 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --dport 5223 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 5269 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --dport 5269 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 5280 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --dport 5280 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 4369 -j ACCEPT
sudo iptables -A INPUT -p udp -m udp --dport 4369 -j ACCET
sudo iptables -A INPUT -p udp -m udp --dport 4369 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 53873 -j ACCEPT







评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值