2008年11月7日星期五

开发你自己的XMPP IM

http://phoenixtoday.blogbus.com/logs/20285574.html

http://phoenixtoday.blogbus.com/logs/17878527.html

http://phoenixtoday.blogbus.com/logs/17246727.html


http://initiative.yo2.cn/archives/591950

2008年11月5日星期三

wapshop网站安装

1. 安装Apache日志截断程序cronolog
wget -c wget http://cronolog.org/download/cronolog-1.6.2.tar.gz
tar -zxvf cronolog-1.6.2.tar.gz
cd cronolog-1.6.2
./configure --prefix=/usr/wapshop/install/cronolog
make
make install
2. 安装apache服务器,测试index.html
2.1 下载
wget -c http://apache.freelamp.com/httpd/httpd-2.2.9.tar.gz

2.2 解压缩,配置,编译,安装
tar -zxvf httpd-2.2.9.tar.gz
cd httpd-2.2.9
./configure \
--prefix=/usr/wapshop/install/apache2 \
--enable-so \
--enable-rewrite=static \
--enable-cache \
--enable-file-cache \
--enable-mem-cache \
--enable-disk-cache \
--enable-static-support \
--enable-static-htpasswd \
--enable-static-htdigest \
--enable-static-rotatelogs \
--enable-static-logresolve \
--enable-static-htdbm \
--enable-static-ab \
--enable-static-checkgid \
--disable-cgid \
--disable-cgi
========================================
编译配置说明
./configure //配置源代码树
--prefix=/usr/wapshop/install/apache2 //体系无关文件的顶级安装目录PREFIX ,也就Apache的安装目录。
--enable-so //打开 so 模块,so 模块是用来提 DSO 支持的 apache 核心模块
--enable-rewrite=static //打开rewrite 功能模块
--enable-mods-shared=all //编译全部的模板,对于不需要我们可以在httpd.conf去掉。这个选项打开可能会需要有更多的依赖库,在这里可以去掉
--enable-cache //支持缓存
--enable-file-cache //支持文件缓存
--enable-mem-cache //支持记忆缓存
--enable-disk-cache //支持磁盘缓存
--enable-static-support //支持静态连接(默认为动态连接)
--enable-static-htpasswd //使用静态连接编译 htpasswd - 管理用于基本认证的用户文件
--enable-static-htdigest //使用静态连接编译 htdigest - 管理用于摘要认证的用户文件
--enable-static-rotatelogs //使用静态连接编译 rotatelogs - 滚动 Apache 日志的管道日志程序
--enable-static-logresolve //使用静态连接编译 logresolve - 解析 Apache 日志中的IP地址为主机名
--enable-static-htdbm //使用静态连接编译 htdbm - 操作 DBM 密码数据库
--enable-static-ab //使用静态连接编译 ab - Apache HTTP 服务器性能测试工具
--enable-static-checkgid //使用静态连接编译 checkgid
--disable-cgid //禁止用一个外部 CGI 守护进程执行CGI脚本
--disable-cgi //禁止编译 CGI 版本的 PHP
--enable-ssl // 编译 ssl模块。这个选项打开可能需要更多的依赖库,在这里可以去掉
=============================
make
make install
2.3 配置apache2的端口和根目录
cd /usr/wapshop/install/apache2
cp conf/httpd.conf conf/httpd.conf.20081106
vi conf/httpd.conf
==========================================
Listen 80 --> Listen 8080 不过暂时使用80,因为需要映射该端口到10080

DirectoryIndex index.html --> DirectoryIndex index.php index.html

DocumentRoot "/usr/wapshop/install/apache2/htdocs" --> DocumentRoot "/usr/wapshop/htdocs"

Directory "/usr/wapshop/install/apache2/htdocs" --> Directory "/usr/wapshop/htdocs"
==========================================

2.4 配置cronolog日志截断程序
vi conf/httpd.conf
==========================================
CustomLog "logs/access_log" common
-->
CustomLog "|/usr/wapshop/install/cronolog/sbin/cronolog /usr/wapshop/install/apache2/logs/access_log.%Y%m%d" combined
==========================================
2.5 配置启动脚本
mkdir /usr/wapshop/install/init.d
cd /usr/wapshop/install/init.d
ln -s ../apache2/bin/apachectl apache2
启动命令: /usr/wapshop/install/init.d/apache2 start
关闭命令: /usr/wapshop/install/init.d/apache2 stop
2.6 测试服务器
mkdir /usr/wapshop/htdocs
vi /usr/wapshop/htdocs/index.html
===========================================
<html>
<head>
<title> test </title>
</head>
<body>
<h1>Test</h1>
</body>
</html>
===========================================
/usr/wapshop/install/init.d/apache2 start
wget http://127.0.0.1/index.html
cat index.html | grep -e "Test"

3. 安装mysql服务器
3.0 需要安装g++ 和 ncurse-devel
wget -c ftp://mirror.switch.ch/pool/3/mirror/centos/4.6/os/x86_64/CentOS/RPMS/gcc-c++-3.4.6-9.x86_64.rpm
wget -c ftp://mirror.switch.ch/pool/3/mirror/centos/4.6/os/x86_64/CentOS/RPMS/libstdc++-devel-3.4.6-9.x86_64.rpm
wget -c ftp://mirror.switch.ch/pool/3/mirror/centos/4.6/os/x86_64/CentOS/RPMS/libstdc++-3.4.6-9.x86_64.rpm

wget -c ftp://ftp.chg.ru/pub/Linux/scientific/41/x86_64/SL/RPMS/ncurses-devel-5.4-13.x86_64.rpm

rpm -i gcc-c++-3.4.6-9.x86_64.rpm libstdc++-devel-3.4.6-9.x86_64.rpm libstdc++-3.4.6-9.x86_64.rpm ncurses-devel-5.4-13.x86_64.rpm

3.1 为了避免对系统的干扰,需要注意修改端口号和相关的目录。
wget -c http://mysql.mirror.rafal.ca/Downloads/MySQL-5.0/mysql-5.0.67.tar.gz
cd /usr/wapshop/download/mysql-5.0.67
mkdir /usr/wapshop/install/mysql5
mkdir -p /usr/wapshop/var/lib/mysql5
./configure \
--prefix=/usr/wapshop/install/mysql5 \
--localstatedir=/usr/wapshop/var/lib/mysql5 \
--with-comment=Source \
--with-server-suffix=-Community \
--with-mysqld-user=mysql \
--without-debug \
--with-big-tables \
--with-charset=utf8 \
--with-collation=utf8_unicode_ci \
--with-extra-charsets=all \
--with-pthread \
--enable-static \
--enable-thread-safe-client \
--with-client-ldflags=-all-static \
--with-mysqld-ldflags=-all-static \
--enable-assembler \
--without-innodb \
--without-ndb-debug

make
make install

cd /usr/wapshop/install/mysql5
groupadd mysql //添加 mysql 组
useradd -g mysql mysql //添加 mysql 用户
chown -R mysql .
chgrp -R mysql .
./bin/mysql_install_db --user=mysql
chown -R root .
chown -R mysql /usr/wapshop/var/lib/mysql5


cp share/mysql/my-huge.cnf .
vi my-huge.cnf
==========================================
port: 3306 --> 3307 两个地方
socket: /tmp/mysql.sock --> /tmp/mysqlwapshop.sock 两个地方
==========================================

cp share/mysql/mysql.server /usr/wapshop/install/init.d/mysqlwapshop
vi /usr/wapshop/install/init.d/mysqlwapshop
==========================================
datadir= --> datadir=/usr/wapshop/var/lib/mysql5
conf=/etc/my.cnf --> conf=/usr/wapshop/install/mysql5/my-huge.cnf
把"$bindir/mysqld_safe --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &"替换为(双引号中的)
"$bindir/mysqld_safe --defaults-file=/usr/wapshop/install/mysql5/my-huge.cnf --datadir=$datadir --pid-file=$server_pid_file $other_args >/dev/null 2>&1 &"(双引号中的)
==========================================
chmod 755 /usr/wapshop/install/init.d/mysqlwapshop
//chkconfig --add mysqlwapshop <-- 暂时不用

3.2 启动数据库
/usr/wapshop/install/init.d/mysqlwapshop start
3.3 确认服务正常启动
netstat -an | grep -e "LISTEN"|grep -e "3307"
3.4 修改root用户密码
./bin/mysql -u root -S /tmp/mysqlwapshop.sock
======================================================
mysql> use mysql
mysql> update user set password=password('wapshop') where user='root';
mysql> FLUSH PRIVILEGES;
======================================================
3.5 停止数据库运行
/usr/wapshop/install/init.d/mysqlwapshop stop

4. 安装php环境,测试phpinfo.php
4.0 需要lib-xml2
wget -c ftp://ftp.pbone.net/mirror/www.startcom.org/AS-4.0.0/updates/x86_64/zlib-devel-1.2.1.2-1.2.x86_64.rpm
wget -c ftp://ftp.pbone.net/mirror/www.startcom.org/AS-4.0.0/os/x86_64/StartCom/RPMS/libxml2-devel-2.6.16-6.x86_64.rpm
rpm -i libxml2-devel-2.6.16-6.x86_64.rpm zlib-devel-1.2.1.2-1.2.x86_64.rpm

4.1 下载
wget -c http://cn.php.net/get/php-5.2.6.tar.gz/from/this/mirror
4.2 解压缩,编译,安装
tar -zxvf php-5.2.6.tar.gz
cd php-5.2.6
ln -sf libjpeg.so.62.0.0 libjpeg.so
ln -sf libpng.so.3.1.2.7 libpng.so

./configure \
--prefix=/usr/wapshop/install/php5 \
--with-apxs2=/usr/wapshop/install/apache2/bin/apxs \
--with-mysql=/usr/wapshop/install/mysql5 \
--disable-debug \
--with-zlib \
--enable-mbstring \
--with-gd \
--with-jpeg-dir \
--with-png-dir \
--enable-fastcgi \
--with-config-file-scan-dir=/usr/wapshop/install/php5/etc/php \
--with-mysqli=/usr/wapshop/install/mysql5/bin/mysql_config

make
make test
make install

mkdir -p /usr/wapshop/install/php5/etc/php
cp php.ini-dist /usr/wapshop/install/php5/etc/php/php.ini

4.3 整合php和apache2
#make install 会自动修改http.conf 加上 LoadModule php5_module modules/libphp5.so

只需要在最后一行加上:
AddType application/x-httpd-php .php

4.4 测试phpinfo()
/usr/wapshop/install/init.d/apache2 stop
/usr/wapshop/install/init.d/apache2 start
cd /usr/wapshop/htdocs/
vi index.php
=========================================
phpinfo();
?>
=========================================
需要确认有 gd 和 mysqli 的支持。

2008年10月30日星期四

damn small linux

http://www.damnsmalllinux.org/

2008年10月28日星期二

Linux/Unix Shell Script To Find Your Google Page Rank

http://linuxshellaccount.blogspot.com/2008/10/linuxunix-shell-script-to-find-your.html

2008年10月27日星期一

ouxunsi视频网站搭建(2)

openfire + red5 + (openmeetings / jwchat / spark)
1. 安装JDK1.6
下载jdk-6u3-linux-i586.bin
# chmod +x jdk-6u3-linux-i586.bin
# ./jdk-6u3-linux-i586.bin
# mv jdk1.6.3 /usr/local/ ----------移动位置
# mv jdk1.6.3 jdk1.6 ----------文件夹改名
配置环境变量
# vi /etc/profile
在末尾追加
#Java environment
export JAVA_HOME=/usr/local/jdk1.6
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar
export PATH=$JAVA_HOME/bin:$PATH
:wq保存退出。
# source /etc/profile -------------使配置生效
执行# java -version 命令,显示
java version "1.6.0_03"
Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
Java HotSpot(TM) Client VM (build 1.6.0_03-b05, mixed mode, sharing)


2.安装ANT
下载apache-ant-1.7.0-bin.tar.gz
# tar zxvf apache-ant-1.7.0-bin.tar.gz
# mv apache-ant-1.7.0 /usr/local/
# mv apache-ant-1.7.0 ant
配置环境变量
# vi /etc/profile
在末尾追加
#Ant environment
export ANT_HOME=/usr/local/ant
export PATH=$ANT_HOME/bin:$PATH
:wq保存退出。
# source /etc/profile
执行ant -version命令,显示
Apache Ant version 1.7.0 compiled on December 13 2006
安装成功!


2.安装openfire

在http://www.igniterealtime.org/downloads/index.jsp#openfire上下载openfire-3.5.1-1.i386.rpm包
# rpm -ivh openfire-3.5.1-1.i386.rpm
默认安装在 /opt/openfire
# vi /etc/sysconfig/iptables
追加下面2行
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 9090 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 9091 -j ACCEPT
:wq保存退出后执行
# service iptables restart
可以使用下面的命令启动服务:
# /opt/openfire/bin/openfire.sh
或者用保存在/etc/init.d/下的openfire脚本启动服务,命令是/etc/init.d/openfire start
脚本如下:
#!/bin/sh
#
# openfire Stops and starts the Openfire XMPP service.
#
# chkconfig: 2345 99 1
# description: Openfire is an XMPP server, which is a server that facilitates \
# XML based communication, such as chat.
# config: /opt/openfire/conf/openfire.xml
# config: /etc/sysconfig/openfire
# pidfile: /var/run/openfire.pid
#
# This script has currently been tested on Redhat, CentOS, and Fedora based
# systems.
#

#####
# Begin setup work
#####

# Initialization
PATH="/sbin:/bin:/usr/bin:/usr/sbin"
RETVAL=0

# Check that we are root ... so non-root users stop here.
[ "`id -u`" = 0 ] || exit 1

# Get config.
[ -f "/etc/sysconfig/openfire" ] && . /etc/sysconfig/openfire

# If openfire user is not set in sysconfig, set to daemon.
[ -z "$OPENFIRE_USER" ] && OPENFIRE_USER="daemon"

# If pid file path is not set in sysconfig, set to /var/run/openfire.pid.
[ -z "$OPENFIRE_PIDFILE" ] && OPENFIRE_PIDFILE="/var/run/openfire.pid"

# -----------------------------------------------------------------

# If a openfire home variable has not been specified, try to determine it.
if [ -z "$OPENFIRE_HOME" -o ! -d "$OPENFIRE_HOME" ]; then
if [ -d "/usr/share/openfire" ]; then
OPENFIRE_HOME="/usr/share/openfire"
elif [ -d "/usr/local/openfire" ]; then
OPENFIRE_HOME="/usr/local/openfire"
elif [ -d "/opt/openfire" ]; then
OPENFIRE_HOME="/opt/openfire"
else
echo "Could not find Openfire installation under /opt, /usr/share, or /usr/local."
echo "Please specify the Openfire installation location as variable OPENFIRE_HOME"
echo "in /etc/sysconfig/openfire."
exit 1
fi
fi

# If log path is not set in sysconfig, set to $OPENFIRE_HOME/logs.
[ -z "$OPENFIRE_LOGDIR" ] && OPENFIRE_LOGDIR="${OPENFIRE_HOME}/logs"

# Attempt to locate java installation.
if [ -z "$JAVA_HOME" ]; then
if [ -d "${OPENFIRE_HOME}/jre" ]; then
JAVA_HOME="${OPENFIRE_HOME}/jre"
elif [ -d "/etc/alternatives/jre" ]; then
JAVA_HOME="/etc/alternatives/jre"
else
jdks=`ls -r1d /usr/java/j*`
for jdk in $jdks; do
if [ -f "${jdk}/bin/java" ]; then
JAVA_HOME="$jdk"
break
fi
done
fi
fi
JAVACMD="${JAVA_HOME}/bin/java"

if [ ! -d "$JAVA_HOME" -o ! -x "$JAVACMD" ]; then
echo "Error: JAVA_HOME is not defined correctly."
echo " Can not sure execute $JAVACMD."
exit 1
fi

# Prepare location of openfire libraries
OPENFIRE_LIB="${OPENFIRE_HOME}/lib"

# Prepare openfire command line
OPENFIRE_OPTS="${OPENFIRE_OPTS} -DopenfireHome=${OPENFIRE_HOME} -Dopenfire.lib.dir=${OPENFIRE_LIB}"

# Prepare local java class path
if [ -z "$LOCALCLASSPATH" ]; then
LOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar"
else
LOCALCLASSPATH="${OPENFIRE_LIB}/startup.jar:${LOCALCLASSPATH}"
fi

# Export any necessary variables
#export JAVA_HOME JAVACMD
export JAVA_HOME=/usr/local/jdk1.6
export JAVACMD=/usr/local/jdk1.6/bin/java
# Lastly, prepare the full command that we are going to run.
OPENFIRE_RUN_CMD="${JAVACMD} -server ${OPENFIRE_OPTS} -classpath \"${LOCALCLASSPATH}\" -jar \"${OPENFIRE_LIB}/startup.jar\""

#####
# End setup work
#####



start() {
OLD_PWD=`pwd`
cd $OPENFIRE_LOGDIR

# Start daemons.
echo -n "Starting openfire: "

rm -f nohup.out
sudo su -s /bin/sh -c "nohup $OPENFIRE_RUN_CMD > $OPENFIRE_LOGDIR/nohup.out 2>&1 &" $OPENFIRE_USER
RETVAL=$?
PID=`ps ax --width=1000 | grep openfire | grep startup.jar | awk '{print $1}'`

if [ $RETVAL -eq 0 -a ! -z "$PID" -a ! -z "$OPENFIRE_PIDFILE" ]; then
echo $PID > $OPENFIRE_PIDFILE
fi

echo

[ $RETVAL -eq 0 -a -d /var/lock/subsys ] && touch /var/lock/subsys/openfire

sleep 1 # allows prompt to return
cd $OLD_PWD
}

stop() {
# Stop daemons.
echo -n "Shutting down openfire: "

[ -f "$OPENFIRE_PIDFILE" ] && kill `cat $OPENFIRE_PIDFILE`
RETVAL=$?
echo

[ $RETVAL -eq 0 -a -f "$OPENFIRE_PIDFILE" ] && rm -f $OPENFIRE_PIDFILE
[ $RETVAL -eq 0 -a -f "/var/lock/subsys/openfire" ] && rm -f /var/lock/subsys/openfire
}

restart() {
stop
sleep 10 # give it a few moments to shut down
start
}

condrestart() {
[ -e "/var/lock/subsys/openfire" ] && restart
return 0
}

status() {
pid=`cat $OPENFIRE_PIDFILE 2>&1`
if [ "$?" = "1" ]; then
echo "openfire is not running"
RETVAL=0
else
ps -p $pid > /dev/null 2>&1
if [ "$?" = "0" ]; then
echo "openfire is running"
RETVAL=0
else
echo "openfire is not running"
RETVAL=0
fi
fi
}


# Handle how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
condrestart)
condrestart
;;
reload)
restart
;;
status)
status
;;
*)
echo "Usage $0 {start|stop|restart|status|condrestart|reload}"
RETVAL=1
esac

exit $RETVAL
脚本到此结束。
设置为开机自启动
# chkconfig openfire on
# chkconfig --list openfire
openfire 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭
设置成功!
接下来在浏览器中输入http://你的服务器的IP:9090即可开始即时通讯服务器配置
(1)语言选择:中文简体
(2)服务期设置:选择域及端口,建议默认
(3)数据库设置:根据需要,这里选“标准数据库”
(4)标准数据库设置:选择MySQL,数据库URL填入你的数据库地址,端口和数据库名称(请自行创建)用户名密码填入你的mysql的帐号密码,其他根据需要选择填写。继续之后会在你的mysql中创建表并初始化。
(5)特性设置:如果你不打算用LDAP,保留默认
(6)管理员帐户设置:填入系统管理员信息
(7)安装完成
至此,Openfire安装完毕。你可以继续登录到管理控制台,进行更为详细的设置。
服务器到此安装完成。建议客户端在windows上使用spark,因为Spark和Openfire能够很好的相互支持,是黄金组合。
下载地址:http://www.igniterealtime.org/downloads/index.jsp#spark
安装比较简单,安装完成后就可以注册-->登录-->使用了。挺不错的开源聊天软件。

3. 安装Red5
下载Red5的安装文件,下载地址:http://osflash.org/red5
# tar zxvf red5-0.6.3.tar.gz
# cd red5-0.6.3
# ant
编译完后把dist文件夹内的文件copy到 /var/www/red5 文件夹下。
# vi /etc/sysconfig/iptables
开放端口,添加以下内容:
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1935 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1936 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 1945 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5080 -j ACCEPT
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8088 -j ACCEPT

# /etc/rc.d/init.d/iptables restart
重启防火墙
#cd /var/www/red5
# ./red5.sh &
启动服务
可以访问http://ip:5080。
安装完成。

http://www.javaeye.com/topic/212656

2008年10月26日星期日

phpbb3 用户同步的想法

1. 需要考虑已有用户的同步问题,已有用户的密码采用了md5加密。
2. 注册时,将新用户的密码md5加密后,再送给phpbb3注册
3. 登录时,判断该用户是否在phpbb3中,假如没有则自动同步。
4. 修改phpbb3的注册入口到当前主站的注册入口
5. 修改phpbb3的用户登录入口,需要将用户输入的密码进行md5加密后,再送给phpbb3验证
6. 修改phpbb3的用户修改密码入口,到主站的修改密码入口。

http://www.gnuedu.org/view/printview-23.html

2008年10月16日星期四

Flex Mp3 Player

1. http://axel.cfwebtools.com/index.cfm/2007/10/18/Open-source-flex-xml-mp3-player
2. http://ntt.cc/2008/02/19/a-small-open-source-flash-mp3-player.html
3. http://www.lemlinh.com/flash-source-as-30-xml-mp3-player