» tagged pages
» logout

sorted by: recent | see : popular
Content Tagged with Jabber-linux + linux

隐藏apache和php的版本信息

web server避免一些不必要的麻烦,可以把apache和php的版本信息不显示

隐藏 Apache 版本信息

/etc/apache2/apache2.conf 或 /etc/httpd/conf/httpd.conf

ServerTokens ProductOnly
ServerSignature Off

重启 apache
现在 http 头里面只看到:
Server: Apache

隐藏 PHP 版本
php.ini

expose_php On
改成
expose_php Off

重启apache后,php版本在http头中隐藏了。
类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource

sshd 监听两个或多个端口方法

in /etc/ssh/sshd_config
ListenAddress 0.0.0.0:22
ListenAddress 0.0.0.0:10023
ListenAddress 0.0.0.0:10024
ListenAddress 0.0.0.0:10025

以上监听22,10023,10024,10025
为了减少一些无聊的猜密码的流量,可以把22去掉
类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource

更改一个目录的apache的默认字符集

首先确保apache允许目录单独设置
in /etc/apache2/apache2.conf 或 /etc/httpd/conf/httpd.conf

AllowOverride None
=>
AllowOverride All

如下

<Directory "/var/www/html">
    Options Indexes FollowSymLinks
    AllowOverride All
    Order allow,deny
    Allow from all
</Directory>

在具体目录的 .htaccess 增加gb2312,或utf8,iso8859-1等
AddDefaultCharset gb2312
类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource

禁止或停用SELinux

暂时
echo 0 > /selinux/enforce
改成1打开。
永久:
修改/etc/selinux/config
SELINUX=disabled

See also: Turning off or disabling SELinux
http://www.revsys.com/writings/quicktips/turn-off-selinux.html

类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource

无光驱CDROM通过ISO文件从Windows安装Ubuntu(非vm环境)

安装全新的Ubuntu, 没有光驱或不想刻录CD, 也不是装在VMWARE上(VM可以直接映射iso成cd)
奸商已经在机上装了xp

用下面方法32/64 bit 都已经安装成功,自己Windows PC也在VMWare上安装了Ubuntu

1. 创建 c:\hd-media
2. Download vmlinuz and initrd.gz from
    http://archive.ubuntu.com/ubuntu/dists/feisty/main/installer-i386/current/images/hd-media/
    and save them to hd-media
3.下载 Ubuntu ISO 文件,迅雷搜一下一大堆。
   或者去官方: Download the ALTERNATE ubuntu-installer CD from [WWW] http://www.ubuntulinux.org/download/
注意:只对 Alternate Ubuntu install CD 有效
   如:ubuntu-7.04-server-i386.iso
  
   下载后请保存在C:\
  
4. 下载 Grub For Dos
    http://sarovar.org/download.php/1138/grub_for_dos-0.4.2.zip
    解压里面的 grldr 保存在 c:\grldr. 其他文件不需要。

5. 修改 c:\boot.ini(需要显示隐藏系统文件才能看到), 后面添加
        c:\grldr="Install Ubuntu"
       
6. 创建新文本文件 c:\menu.lst

      title Install Ubuntu
      kernel   (hd0,0)/hd-media/vmlinuz root=/dev/ram0 ramdisk_size=128000
      initrd   (hd0,0)/hd-media/initrd.gz

7. 重新启动 Windows, 启动菜单里面选择



64-bit Ubuntu:
(AMD64, INTEL EM64T系列)

1. 创建 c:\hd-media
2. Download vmlinuz and initrd.gz from
    http://archive.ubuntu.com/ubuntu/dists/feisty/main/installer-amd64/current/images/hd-media/
    and save them to hd-media
3.下载 Ubuntu ISO 文件,迅雷搜一下很多选择。
   或者去官方: Download the ALTERNATE ubuntu-installer CD from [WWW] http://www.ubuntulinux.org/download/
注意:只对 Alternate Ubuntu install CD 有效
   如:ubuntu-7.04-server-amd64.iso
  
   下载后请保存在C:\
  
4. 下载 Grub For Dos
    http://sarovar.org/download.php/1138/grub_for_dos-0.4.2.zip
    解压里面的 grldr 保存在 c:\grldr. 其他文件不需要。

5. 修改 c:\boot.ini(需要显示隐藏系统文件才能看到), 后面添加
        c:\grldr="Install Ubuntu"
       
6. 创建新文本文件 c:\menu.lst

      title Install Ubuntu
      kernel   (hd0,0)/hd-media/vmlinuz root=/dev/ram0 ramdisk_size=128000
      initrd   (hd0,0)/hd-media/initrd.gz

7. 重新启动 Windows, 启动菜单里面选择
类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource

linux 向外TCP最大连接只能打开28232个端口限制tuning

Tim http://hi.baidu.com/jabber

可能牛人都知道怎么设置,只不过将解决思路记录一下。性急的人看最后3行就行了。

因为想测试一下java mustang(jdk1.6)使用epoll的性能,Tim最近写了一个Java NIO的client在linux去连服务器,原理上一个client是可以打开65535个端口的(而且只需要一个线程, nonblocking io就是好),但是每个 Linux client 在打开 28231-28233左右的连接之后就说
Cannot assign requested address
这时候使用 telnet 去连服务器报同样错误:
Unable to connect to remote host: Cannot assign requested address
说明不是Java程序的问题。用 tcpdump 监听了一下,发现没有网络流量,那可能是本地内核的限制了。

用 netstat 去看客户机的显示全部本地端口都使用 30000~60000 左右的。
联想到 Windows 默认 5000 个端口的限制,觉得 Linux 应该也设了一个限制。

在网上google解决办法可能关键词没找好,没发现答案(搜索上面出错那个字符串很难得到答案),只知道这个字符串是error.h里面是 “EADDRNOTAVAIL”。找不到解决办法,只好看 Linux 源代码了,笨人用笨方法

解开Linux 2.6源代码,根据 socket 接口应该看 connect() 的实现

打开 tcp_ipv4.c, 找到

/* This will initiate an outgoing connection. */
int tcp_v4_connect(struct sock *sk, struct sockaddr *uaddr, int addr_len)

应该就是这里了,看进去, 它调用了另外一个函数

/*
 * Bind a port for a connect operation and hash it.
 */
static int tcp_v4_hash_connect(struct sock *sk)

这个函数中间判断了一个sysctl_local_port_range的变量,不符合条件就 return -EADDRNOTAVAIL;
那问题就是 sysctl_local_port_range 了

找下上下文关于 sysctl_local_port_range 的设置

in tcp.c, 这里是设置初始值
void __init tcp_init(void)

    /* Try to be a bit smarter and adjust defaults depending
     * on available memory.
     */
    if (order > 4) {
        sysctl_local_port_range[0] = 32768;
        sysctl_local_port_range[1] = 61000;
        sysctl_tcp_max_tw_buckets = 180000;
        sysctl_tcp_max_orphans = 4096 << (order - 4);
        sysctl_max_syn_backlog = 1024;
    }

注释说程序要改进一下,根据内存的情况来动态分配开多大端口,不过现在的版本是写死的 :(

定义的地方:
/*
 * This array holds the first and last local port number.
 * For high-usage systems, use sysctl to change this to
 * 32768-61000
 */
int sysctl_local_port_range[2] = { 1024, 4999 };

Tim的最终解决办法:因为上面有个注释说可以用 sysctl 来设置,怎么设呢,一行字

echo "net.ipv4.ip_local_port_range = 1024 65000" >> /etc/sysctl.conf; sysctl -p

搞定了,一个client可以发起65000个连接了,写程序的人每天就要面对这些意想不到的问题。

说明:以上方法在 Linux 2.6.9 上通过, 如果你的内核版本不同改了不生效不要来找 Tim :)
类别:Linux Tuning 查看评论

Jabber-linux: Jabber XMPP resource