FreeBSD网卡配置

Standard

网卡配置文件位于/etc/rc.conf,在编辑此文件前可使用ifconfig -a来查看网卡名称,如网卡名为”eth0″

#网关地址
defaultrouter="192.168.0.1"
#IP地址及子网掩码
ifconfig_eth0="inet 192.168.0.3 netmask 255.255.255.0"

网卡重启命令如下:
ifconfig eth0 down #STOP网卡eth0
ifconfig eth0 up #START网卡eth0
/etc/rc.d/netif restart #所有网卡重启
/etc/rc.d/netif restart && /etc/rc.d/routing restart

Linux系统常用信息查看命令

Standard

系统
# uname -a # 查看内核/操作系统/CPU信息
# head -n 1 /etc/issue # 查看操作系统版本
# cat /proc/cpuinfo # 查看CPU信息
# hostname # 查看计算机名
# lspci -tv # 列出所有PCI设备
# lsusb -tv # 列出所有USB设备
# lsmod # 列出加载的内核模块
# env # 查看环境变量

资源
# free -m # 查看内存使用量和交换区使用量
# df -h # 查看各分区使用情况
# du -sh <目录名> # 查看指定目录的大小
# grep MemTotal /proc/meminfo # 查看内存总量
# grep MemFree /proc/meminfo # 查看空闲内存量
# uptime # 查看系统运行时间、用户数、负载
# cat /proc/loadavg # 查看系统负载

磁盘和分区
# mount | column -t # 查看挂接的分区状态
# fdisk -l # 查看所有分区
# swapon -s # 查看所有交换分区
# hdparm -i /dev/hda # 查看磁盘参数(仅适用于IDE设备)
# dmesg | grep IDE # 查看启动时IDE设备检测状况

网络
# ifconfig # 查看所有网络接口的属性
# iptables -L # 查看防火墙设置
# route -n # 查看路由表
# netstat -lntp # 查看所有监听端口
# netstat -antp # 查看所有已经建立的连接
# netstat -s # 查看网络统计信息

进程
# ps -ef # 查看所有进程
# top # 实时显示进程状态

用户
# w # 查看活动用户
# id <用户名> # 查看指定用户信息
# last # 查看用户登录日志
# cut -d: -f1 /etc/passwd # 查看系统所有用户
# cut -d: -f1 /etc/group # 查看系统所有组
# crontab -l # 查看当前用户的计划任务

服务
# chkconfig –list # 列出所有系统服务
# chkconfig –list | grep on # 列出所有启动的系统服务

程序
# rpm -qa # 查看所有安装的软件包

另外这里还有些命令

老外辨别中国人的50种方法-转载

Standard

1.You look like you are 18. 你看起来好像才18岁(东方人普遍看起来年轻, 呵呵)
2.You like to eat chicken feet. 你喜欢吃鸡脚
3.You suck on fish heads and fish fins。你吃鱼时会吸鱼头和鱼鳍(他们都是直接切掉的)
4.You have a Chinese knick-knack hanging on your rear view mirror. 你的车子后视镜上会吊中国摆设(偶没有,老爸不让, 说一看就是中国人, 俗, 郁闷)
5.You sing karaoke. 你唱KTV(唐人街才有的玩意儿)
6.Your house is covered with tile。你的房子铺的是瓷砖(老外都是木板)
7.Your kitchen is covered by a sticky film of grease。你的厨房覆盖着一层厚厚的油脂(爱炒东西的缘故)
8.Your stove is covered with aluminum foil. 你的炉子上面有铝箔
9.You leave the plastic covers on your remote control. 你的遥控器外面包着塑料(发现真的只有中国人才这样)
10.You”ve never kissed your mom or dad. 你从没吻过你父母(中国人谁这样啊)
11.You”ve never hugged your mom or dad. 你从没抱过你父母(幼儿园时算不算?)
12.Your unassisted vision is worse than 20/500. 你的视觉想象力低于20/500(不知啥意思)
13.You wear contacts,to avoid wearing your “coke bottle glasses”. 你戴隐形眼镜,这样才能避免戴你的”瓶底眼镜”(怎么说得中国人好像都近视? 偶就不怎么戴眼镜, 不过也近视两三百了, 呵呵)
14.You”ve worn glasses since you were in fifth grade. 你五年级开始就戴眼镜了. (中国人都是爱学习的好孩子… 怎么又跟眼镜有关?)
15.Your hair sticks up when you wake up. 你睡醒后头发会竖起来。
16.You”ll haggle over something that is not negotiable. 你会为一些不可质疑的事情辩论. (无理取闹???)
17.You love to use coupons. 你喜欢用折价券. (勤俭节约~~)
18.You drive around looking for the cheapest petrol. 你为了最便宜的汽油费不息开着车子到处找. (恩, 我爸就这样)
19.You drive around for hours looking for the best parking space. 你开着车子兜圈为了找到最好的停车位. (看来老外真的不太讲究这个。)
20.You take showers at night. 你晚上洗澡. (许多美国人都是早上洗, 不知道为什么)
21.You avoid the non-free snacks in hotel rooms. 旅店房间里的非免费食品你都不吃. (那些东西都是over-charged了的,谁那么笨啊)
22.You don”t mind squeezing 20people into one motel room. 你不介意二十个人挤一间汽车旅房. (那也太抠门了吧..。)
23.Most girls have more body hair than you,if you are male. 如果你是男人, 那么你身上的体毛比大多数女人少. (又不是大猩猩,老子要那么多体毛干什么?)
24.You tap the table when someone pours tea for you. 别人为你倒茶你就用手敲一下桌子。(在广东茶楼尤其如此, 不然没礼貌)
25.You say “Aiya!”and “Wah!”frequently。你经常说”哎(二声)呀(四声)” 和 “哇(四声)”。
26.You don”t want to wear your seatbelt because it is uncomfortable。你不喜欢系安全带因为安全带让你感觉不舒服. (晕~~~~~~~
27.You love Las Vegas,slot machines,and blackjack. 你喜欢拉斯维加斯, 老虎机和二十一点. (中国人好赌, 地球人都知道)
28.You unwrap Christmas gifts very carefully,so you can reuse the paper。你细心地打开你的圣诞节礼物,因为你要留着包装纸再用. (谁叫偶没钱啊)
29.You only buy Christmas cards after Christmas,when they are 50%off. 你只会在圣诞节后买圣诞卡, 因为他们打了五折. (^_^这根本就是在说我, 圣诞节卡留着下一年用,省下一笔钱好好吃一顿更划算^_^)
30.You have a vinyl tablecloth on your kitchen table。你的厨房桌子上有一条抹布. (老外只有纸巾)
31.You spit bones and other food scraps on the table.That”s why you need the vinyl tablecloth. 你把骨头和其他杂碎吐在桌子上, 所以你必须有抹布. (没吐在纸巾上的后果,老外真是浪费..。)
32.You have stuff in the freezer since the beginning of time. 你的电冰箱存着一万年前的食物。
33.You use the dishwasher as a dish rack. 你把洗碗机当碗橱
34.You have never used your dishwasher. 你从来没用过你的洗碗机。
35.You keep a Thermos of hot water available at all times. 你有一个热水瓶里面永远装着热水. (自来水不是人人都喝得惯的~~~)
36.You eat all meals in the kitchen. 你在厨房吃饭。
37.You save grocery bags,tin foil,and tin containers. 你把用过的塑料袋, 锡纸和锡盘留着。
38.You have a piano in your living room. 你客厅里有一架钢琴. (管他会不会弹, 看起来倍儿有面子)
39.You pick your teeth at the dinner table (but you cover your mouth)。你会在餐桌上剔牙, 但手遮着嘴。
40.You twirl your pen around your fingers. 你会转笔
41.You hate to waste food. 你讨厌浪费食物. (没去过大陆餐馆吃过饭的老外, 唉..。)
42.You have Tupperware in your fridge with three bites of rice or one leftover chicken wing。你冰箱里有三口剩饭和一只鸡翼。
43.You don”t own any real Tupperware -only a cupboard full of used but carefully rinsed margarine tubs,takeout containers,and jam jars. 你家里没有任何家用塑料制品,只有一橱子洗过再拿来用的油瓶,饭盒和酱坛子。
44.You also use the jam jars as drinking glasses. 你把果酱瓶当水杯用。
45.You have a collection of miniature shampoo bottles that you take every time you stay in a hotel. 你有收集旅馆免费洗发水瓶子的爱好
46.You carry a stash of your own food whenever you travel (travel means any car ride longer than 15minutes).These snacks are always dried and include dried plums,mango,ginger,and squid. 你每次外出十五分钟都会带着你的零食:干芒果, 李子或烤鱿鱼。
47.You wash your rice at least 2-3times before cooking it. 你会洗2-3次米。
48.Your dad thinks he can fix everything himself. 你爸以为自己可以修任何东西。
49.The dashboard of your Honda is covered by hundreds of small toys. 你的车子里堆了无数玩偶。
50.You don”t use measuring cups. 你不用量杯

Apache加VirtualHost后通过IP无法正确访问

Standard

问题:
之前在apache上配了svn和trac是通过IP进行访问.
现在要加了个VirtualHost,加完后发现原IP访问的DocumentRoot无法访问.

解决方法:
在vhost的配置中加上

<VirtualHost *:80>
ServerName 127.0.0.1
DocumentRoot /home/apache/htdocs
</VirtualHost>

Zend_Paginator分页代码

Standard

Models
Book.php

class Book extends Zend_Db_Table {
  ...
}

Controllers
IndexController.php

class IndexController extends Zend_Controller_Action {
 
  function init() {
    $this->initView();
    //set baseUrl
    $this->view->baseUrl = $this->_request->getBaseUrl();
  }
 
  function indexAction() {
    $this->view->title = "Title";
    $book = new Book();
    $this->view->books = $book->index();
 
    $pageNumber = 2;
    $paginator = Zend_Paginator::factory($this->view->books);
    $paginator->setItemCountPerPage($pageNumber);
    $paginator->setCurrentPageNumber($this->_getParam('page'));
    Zend_Paginator::setDefaultScrollingStyle('Sliding');
    $paginator->setView($this->view);
 
    $this->view->books = $paginator;
 
    $this->view->paginator = $paginator;
 
    $this->render();
  }
}

Views
views\scripts\index\index.phtml

<?php foreach ($this->books as $item) {?>
<ul id='ul_<?php echo $this->escape($item->id) ?>'>
  <li>
  <table width="100%"><tr><td width="60%">[<?php echo $this->escape($item->username) ?>]</b> Create by:<?php echo $this->escape($item->pubdate) ?></td><td align="right"><a href="<?php echo $this->baseUrl ?>/index/add/id/<?php echo $item->id ?>?height=280&width=280" class="thickbox" title="Edit">EDIT</a> <a href="#" id="del_<?php echo $this->escape($item->id) ?>" class="del">DEL</a></td></tr></table>
  </li>
  <li class="bottom"><?php echo nl2br($this->escape($item->content)) ?></li>
</ul>
<?php } ?>
<ul>
  <li>
  <?php echo $this->paginationControl($this->paginator, 'Elastic', 'pagelist.phtml'); ?>
  </li>
</ul>

views\scripts\pagelist.phtml

<?php if ($this->pageCount): ?>
<!-- yemaosheng.com -->
<div class="paginationControl">
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
   <a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'index', 'page'=>$this->previous)); ?>">< 上一页</a> |
<?php else: ?>
   <span class="disabled">< 上一页</span> |
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
  <?php if ($page != $this->current): ?>
     <a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'index', 'page'=>$page)); ?>"><?= $page; ?></a> |
  <?php else: ?>
    <?= $page; ?> |
  <?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
   <a href="<?php echo $this->url(array('controller'=>'index', 'action'=>'index', 'page'=>$this->next)); ?>">下一页 ></a>
<?php else: ?>
   <span class="disabled">下一页 ></span>
<?php endif; ?>
</div>
<?php endif; ?>

转载请写明出处: http://yemaosheng.com

ZendFramework zend_form登录验证码

Standard
<?php
class LoginForm extends Zend_Form
{
    public function init()
    {
        $username = $this->addElement('text', 'username', array(
            'filters'    => array('StringTrim', 'StringToLower'),
            'validators' => array(
                'Alpha',
                array('StringLength', false, array(3, 20)),
            ),
            'required'   => true,
            'label'      => '用户名:',
        ));
 
        $password = $this->addElement('password', 'password', array(
            'filters'    => array('StringTrim'),
            'validators' => array(
                'Alnum',
                array('StringLength', false, array(6, 20)),
            ),
            'required'   => true,
            'label'      => '密 码:',
        ));
 
        $captcha = $this->addElement('captcha', 'captcha', array(
            'captcha' =>  array(  
                // First the type...  
                'captcha' => 'Image',
                // Length of the word...  
                'wordLen' => 6,
                'fontsize'=>16,
                'width' => 100,
                'height' => 38,
                'dotNoiseLevel'=>2,
                // Captcha timeout, 5 mins  
                'timeout' => 300,  
                // What font to use...  
                'font' => $_SERVER["DOCUMENT_ROOT"].'/webapp/views/scripts/arial.ttf',  
                // Where to put the image  
                'imgDir' => $_SERVER["DOCUMENT_ROOT"].'/webroot/images/',  
                // URL to the images  
                // This was bogus, here's how it should be... Sorry again :S  
                'imgUrl' => 'http://yemaosheng.com/webroot/images/',
            ),
            'label' => '验证码:'
        ));
 
        $login = $this->addElement('submit', 'login', array(
            'required' => false,
            'ignore'   => true,
            'label'    => '登录',
        ));
 
        // We want to display a 'failed authentication' message if necessary;
        // we'll do that with the form 'description', so we need to add that
        // decorator.
        $this->setDecorators(array(
            'FormElements',
            array('HtmlTag', array('tag' => 'dl', 'class' => 'zend_form')),
            array('Description', array('placement' => 'prepend')),
            'Form'
        ));
    }
}
?>
<?php
public function loginAction() {
 
	$request = $this->getRequest();
 
        if (!$request->isPost()) {
            return $this->_helper->redirector('index');
        }
 
	/* 用$form->isValid的话这一段可以不用
	// Get out from the $_POST array the captcha part...
	$captcha = $request->getPost('captcha');
	// Actually it's an array, so both the ID and the submitted word
	// is in it with the corresponding keys
	// So here's the ID...
	$captchaId = $captcha['id'];
	// And here's the user submitted word...
	$captchaInput = $captcha['input'];
	// We are accessing the session with the corresponding namespace
	// Try overwriting this, hah!
	$captchaSession = new Zend_Session_Namespace('Zend_Form_Captcha_'.$captchaId);
	// To access what's inside the session, we need the Iterator
	// So we get one...
	$captchaIterator = $captchaSession->getIterator();
	// And here's the correct word which is on the image...
	$captchaWord = $captchaIterator['word'];
	// Now just compare them...
	if($captchaInput != $captchaWord){
		echo "验证码Error";
		exit;
	} 
	*/
 
        $form = $this->getForm();
        if (!$form->isValid($request->getPost())) {
            // Invalid entries
            $this->view->form = $form;
            return $this->render('index'); // re-render the login form
        }
}
public function getForm()
{
	return new LoginForm(array(
            'action' => '/user/login',
            'method' => 'post',
	));
}
?>

编译安装LAMP+SVN+Trac+Memcached

Standard
##
## 转载请注明出处: http://yemaosheng.com
##
 
## 环境:Dell1950  CentOS5.3 x86
 
## 新建软件安装目录
 
mkdir /home/lib
mkdir /home/apache
mkdir /home/mysql
mkdir /home/memcached
mkdir /home/php
mkdir /home/svn
mkdir /home/trac
 
## 安装依赖包
 
# gettext-devel
yum install -y gettext-devel.x86_64
 
# zlib
tar zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/home/lib/zlib
make
make install
cd ..
 
# openssl
tar zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config \
	--prefix=/home/lib/openssl \
	--openssldir=/home/lib/openssl \
	--with-zlib-lib=/home/lib/zlib/lib \
	--with-zlib-include=/home/lib/zlib/include \
	shared \
	zlib \
	threads 
make
make test
make install
echo "/home/lib/openssl/lib" >> /etc/ld.so.conf.d/openssl.conf
ldconfig
cd ..
 
# apr
tar zxvf apr-1.3.5.tar.gz
cd apr-1.3.5
./configure --prefix=/home/lib/apr
make
make install
cd ..
 
# apr-util
tar zxvf apr-util-1.3.7.tar.gz
cd apr-util-1.3.7
./configure \
	--prefix=/home/lib/apr-util \
	--with-apr=/home/lib/apr
make
make install
cd ..
 
## 安装Apache
 
rm -rf /usr/lib/libexpat.so
ln -s /usr/lib64/libexpat.so /usr/lib/
tar zxvf httpd-2.2.11.tar.gz
cd httpd-2.2.11
./configure \
	--prefix=/home/apache \
	--enable-track-vars \
	--enable-rewrite \
	--enable-proxy \
	--enable-proxy-http  \
	--enable-cache \
	--enable-disk-cache \
	--enable-mem-cache \
	--enable-so \
	--enable-ssl \
	--enable-mods-shared=all \
	--enable-rewrite=shared \
	--enable-proxy=shared \
	--enable-proxy-http=shared \
	--with-mpm=worker \
	--sysconfdir=/home/apache/conf \
	--with-ssl=/home/lib/openssl \
	--with-z-dir=/home/lib/zlib \
	--with-apr=/home/lib/apr \
	--with-apr-util=/home/lib/apr-util \
	--with-perl 
make 
make install
cd ..
 
mv /etc/init.d/httpd /etc/init.d/httpd.bak
cp /home/apache/bin/apachectl /etc/init.d/httpd
chmod +x /etc/init.d/httpd
 
## 安装依赖包
 
# icon
tar zxvf libiconv-1.12.tar.gz
cd libiconv-1.12
./configure --prefix=/home/lib/iconv
make
make install
cd ..
 
# libpng
tar jxvf libpng-1.2.23.tar.bz2   
cd libpng-1.2.23
env \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib" \
	./configure \
	--prefix=/home/lib/libpng
make
make check 
make install
cd ..
 
# curl
tar zxvf curl-7.19.5.tar.gz
cd curl-7.19.5
./configure --prefix=/home/lib/curl
make
make install
cd ..
 
# freetype
tar jxvf freetype-2.3.5.tar.bz2 
cd freetype-2.3.5
env \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib" \
	./configure \
	--prefix=/home/lib/freetype2
make
make install
cd ..
 
# jpeg
mkdir -p \
	/home/lib/jpeg6/bin \
	/home/lib/jpeg6/lib \
	/home/lib/jpeg6/include \
	/home/lib/jpeg6/man1 \
	/home/lib/jpeg6/man/man1 
 
tar zxvf jpegsrc.v6b.tar.gz    
cd jpeg-6b
./configure \
	--prefix=/home/lib/jpeg6 \
	--enable-shared --enable-static
make
make install-lib  
make install
cd ..
 
# libxml
tar -zxvf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure \
	--prefix=/home/lib/libxml2 \
	--with-zlib=/home/lib/zlib
make
make install
cd ..
 
# gd
tar -jvxf gd-2.0.35.tar.bz2
cd gd-2.0.35 
./configure \
	--prefix=/home/lib/gd2 \
	--with-freetype=/home/lib/freetype2 \
	--with-png=/home/lib/libpng \
	--with-jpeg=/home/lib/jpeg6 \
	CPPFLAGS="-I/home/lib/zlib/include" \
	LDFLAGS="-L/home/lib/zlib/lib"
make
make install 
cd ..
 
## 安装Mysql
 
groupadd mysql
useradd -g mysql mysql
tar zxvf mysql-5.1.34.tar.gz
cd mysql-5.1.34
./configure \
	--prefix=/home/mysql \
	--enable-assembler \
	--without-debug \
	--with-mysqld-ldflags=-all-static \
	--with-charset=utf8 \
	--with-extra-charsets=all \
	--with-innodb \
	--with-unix-socket-path=/home/mysql/mysql.sock \
	--enable-thread-safe-client \
	--with-mysqld-user=mysql
make
make install
cd ..
cp /home/mysql/share/mysql/mysql.server /etc/init.d/mysqld
chmod +x /etc/init.d/mysqld 
if [ -f my.cnf.slave ]; then mv my.cnf.slave /etc/my.cnf; else mv my.cnf.mast /etc/my.cnf; fi; mkdir -p /data/mysqllog/binlog /data/mysqllog/relaylog ; chown mysql.0 /data/mysqllog/binlog /data/mysqllog/relaylog  /home/mysql; cp /home/mysql/share/mysql/mysql.server /etc/init.d/mysqld ; /home/mysql/bin/mysql_install_db --user=mysql; /etc/init.d/mysqld start
 
## 安装PHP
 
tar zxvf php-5.2.9.tar.gz
cd php-5.2.9
./configure \
	--prefix=/home/php \
	--with-zlib=/home/lib/zlib \
	--with-zlib-dir=/home/lib/zlib \
	--with-apxs2=/home/apache/bin/apxs \
	--with-mysql=/home/mysql \
	--with-mysql-sock=/home/mysql \
	--with-pdo-mysql=/home/mysql \
	--with-libxml-dir=/home/lib/libxml2 \
	--with-gd=/home/lib/gd2 \
	--with-jpeg-dir=/home/lib/jpeg6 \
	--with-png-dir=/home/lib/libpng \
	--with-freetype-dir=/home/lib/freetype2 \
	--with-libxml-dir=/home/lib/libxml2 \
	--with-openssl=/home/lib/openssl \
	--with-iconv-dir=/home/lib/iconv \
	--with-curl=/home/lib/curl \
	--with-ttf \
	--with-gettext \
	--enable-gd-native-ttf \
	--enable-mbstring \
	--enable-xml \
	--enable-pcntl \
	--enable-soap \
	--enable-sockets \
	--enable-zip \
	--with-bz2 \
	--disable-debug 
 
make
make install
cp php.ini-dist /home/php/lib/php.ini 
cd ..
 
## 安装PHP扩展
 
# memcached
tar zxvf memcache-2.2.1.tgz
cd memcache-2.2.1
/home/php/bin/phpize
./configure --with-php-config=/home/php/bin/php-config --enable-memcach
make 
make install
cd ..
 
# APC
tar zxvf APC-3.0.19.tgz 
cd APC-3.0.19
/home/php/bin/phpize
./configure --enable-apc --enable-apc-mmap --with-apxs=/home/apache/bin/apxs --with-php-config=/home/php/bin/php-config 
make
make install
cd ..
 
# xdebug
tar zxvf xdebug-2.0.4.tgz
cd xdebug-2.0.4
/home/php/bin/phpize
./configure --enable-xdebug --with-php-config=/home/php/bin/php-config
make
make install
cd ..
 
sed -i 's#extension_dir = "./"#extension_dir = "/home/php/lib/php/extensions/no-debug-zts-20060613/"\n\nextension = "memcache.so"\nextension = "apc.so"\nextension = "xdebug.so"#' /home/php/lib/php.ini
sed -i 's#expose_php = On#expose_php = Off#' /home/php/lib/php.ini
 
#xdebug.auto_trace=on 监测函数调用过程
#xdebug.collect_params=on 收集函数参数
#xdebug.collect_return=on 收集函数返回值
#xdebug.profiler_enable=on 效能监测器
#xdebug.trace_output_dir="/tmp" 函数调用监测信息的输出文件的路径
#debug.profiler_output_dir="/tmp" 效能监测信息输出文件的路径
#sed -i 's#extension = "xdebug.so"#xdebug.auto_trace=on\nxdebug.collect_params=on\nxdebug.collect_return=on\nxdebug.profiler_enable=on\nxdebug.trace_output_dir="/tmp"\ndebug.profiler_output_dir="/tmp"#' /home/php/lib/php.ini
 
 
sed -i 's#DirectoryIndex index.html#DirectoryIndex index.html index.php#' /home/apache/conf/httpd.conf
sed -i 's#TypesConfig conf/mime.types#TypesConfig conf/mime.types\nAddType application/x-httpd-php .php#' /home/apache/conf/httpd.conf
 
tar zxvf phpmyadmin.tar.gz
mv phpmyadmin /home/apache/htdocs/
 
## 安装memcached
tar zxvf libevent-1.4.10-stable.tar.gz 
cd libevent-1.4.10-stable
./configure --prefix=/home/lib/libevent
make
make install
cd ..
 
tar zxvf memcached-1.2.8.tar.gz
cd memcached-1.2.8
./configure \
	--prefix=/home/memcached \
	--with-libevent=/home/lib/libevent \
	--enable-64bit
make
make install
ln -s /home/lib/libevent/lib/libevent-1.4.so.2 /usr/lib64/libevent-1.4.so.2
/home/memcached/bin/memcached -l 127.0.0.1 -d -p 11211 -u nobody -m 128
cd ..
 
## 安装SVN
tar zxvf subversion-1.6.2.tar.gz
tar zxvf subversion-deps-1.6.2.tar.gz
tar zxvf sqlite-amalgamation-3.6.14.2.tar.gz
 
cd subversion-1.6.2
./configure \
	--prefix=/home/svn \
	--with-apxs=/home/apache/bin/apxs \
	--enable-maintainer-mode
 
make
make install
 
make swig-py
make install-swig-py 
 
cd ..
 
echo /home/svn/lib/svn-python > /usr/lib/python2.4/site-packages/subversion.pth
 
# Create SVN Repo
mkdir /srv/svn
mkdir /srv/trac
 
/home/svn/bin/svnadmin create /srv/svn/project
 
touch /srv/svn/project.htpasswd
htpasswd -m /srv/svn/project.htpasswd svnroot
echo -e "<Location /svn>\nDAV svn\nSVNParentPath /srv/svn\nAuthType Basic\nAuthName \"project Repository\"\nAuthzSVNAccessFile /srv/svn/svn-acl-conf\nAuthUserFile /srv/svn/project.htpasswd\nRequire valid-user\n</Location>" >> /home/apache/conf/httpd.conf
echo -e "[project:/]\nsvnroot =  rw" >> /srv/svn/svn-acl-conf
 
## 安装Trac
yum install flex
tar zxvf mod_python-3.3.1.tgz
cd mod_python-3.3.1
./configure \
	--with-apxs=/home/apache/bin/apxs \
	--with-python=/usr/bin/python2.4 \
	--with-max-locks=32
make
make install_dso
make install_py_lib
cd ..
 
yum install -y python-setuptools
rpm -i clearsilver-0.10.4-1.el5.rf.i386.rpm
rpm -i python-clearsilver-0.10.4-1.el5.rf.i386.rpm
 
tar zxvf Trac-0.11.4.tar.gz
cd Trac-0.11.4
python setup.py build && python setup.py install
 
# vi /home/apache/conf/httpd.conf
# Add: LoadModule python_module modules/mod_python.so
 
trac-admin /srv/trac/project initenv
sed -i 's#php_path = php#php_path = /home/php/bin/php#' /srv/trac/project/conf/trac.ini
# vi /srv/trac/project/conf/trac.ini 在 [mimeviewer] 后加上 pygments_default_style = trac 修改[trac] default_charset = utf-8
 
chown -R apache.apache /srv/svn/project
chown -R apache.apache /srv/trac/project
 
# 生成trac的用户名密码
touch /srv/trac/project.htpasswd
htpasswd -m /srv/trac/project.htpasswd tracroot
# 生成tracroot用户的权限
trac-admin /srv/trac/project permission add tracroot TRAC_ADMIN
 
echo -e "<Location /trac/project>\nSetHandler mod_python\nPythonHandler trac.web.modpython_frontend\nPythonOption TracEnv /srv/trac/project\nPythonOption TracUriRoot /trac/project\n</Location>\n<Location "/trac/project/login">\nAuthType Basic\nAuthName \"trac\"\nAuthUserFile /srv/trac/project.htpasswd\nRequire valid-user\n</Location>" >> /home/apache/conf/httpd.conf
 
/etc/init.d/httpd restart
 
## OK
 
http://127.0.0.1/svn/project
http://127.0.0.1/trac/project
memcached: telnet 127.0.0.1 11211
 
/home/lib (关联库)
/home/apache  (2.2.11)
/home/mysql  (5.1.34)
/home/php  (5.2.9)
/home/memcached  (1.2.8)
/home/svn  (1.6.2)
/home/trac  (0.11.4)