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)

apache2.2.6+php5.2.9+mysql5.1.34编译安装

Standard
rpm -ivh gettext-devel-0.14.1-13.x86_64.rpm
 
# zlib
tar -zxvf zlib-1.2.3.tar.gz
cd zlib-1.2.3
./configure --prefix=/usr/local/zlib
make
make install
cd ..
 
# openssl
tar -zxvf openssl-0.9.8g.tar.gz
cd openssl-0.9.8g
./config \
	--prefix=/usr/local/openssl \
	--openssldir=/usr/local/openssl \
	--with-zlib-lib=/usr/local/zlib/lib \
	--with-zlib-include=/usr/local/zlib/include \
	shared \
	zlib \
	threads 
make
make test
make install
echo "/usr/local/openssl/lib" >> /etc/ld.so.conf.d/openssl.conf
ldconfig
cd ..
 
# http
tar jxvf httpd-2.2.6.tar.bz2
cd httpd-2.2.6
./configure \
	--prefix=/usr/local/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="cache disk_cache mem_cache" \
	--enable-rewrite=shared \
	--enable-proxy=shared \
	--enable-proxy-http=shared \
	--with-mpm=worker \
	--sysconfdir=/usr/local/apache/conf \
	--with-ssl=/usr/local/openssl \
	--with-z-dir=/usr/local/zlib \
	--with-perl 
make 
make install
cd ..
 
# DirectoryIndex index.php
# AddType application/x-httpd-php .php
# LoadModule php5_module        modules/libphp5.so
 
cp /usr/local/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=/usr/local/iconv
make
make install
cd ..
 
# libpng
tar jxvf libpng-1.2.23.tar.bz2   
cd libpng-1.2.23
env \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/zlib/lib" \
	./configure \
	--prefix=/usr/local/libpng
make
make check 
make install
cd ..
 
# freetype
tar jxvf freetype-2.3.5.tar.bz2 
cd freetype-2.3.5
env \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/zlib/lib" \
	./configure \
	--prefix=/usr/local/freetype2
make
make install
cd ..
 
# jpeg
mkdir -p \
	/usr/local/jpeg6/bin \
	/usr/local/jpeg6/lib \
	/usr/local/jpeg6/include \
	/usr/local/jpeg6/man1 \
	/usr/local/jpeg6/man/man1 
 
tar zxvf jpegsrc.v6b.tar.gz    
cd jpeg-6b
./configure \
	--prefix=/usr/local/jpeg6 \
	--enable-shared --enable-static
make
make install-lib  
make install
cd ..
 
# libxml
tar -zxf libxml2-2.6.30.tar.gz
cd libxml2-2.6.30
./configure \
	--prefix=/usr/local/libxml2 \
	--with-zlib=/usr/local/zlib
make
make install
cd ..
 
# gd
tar -jvxf gd-2.0.35.tar.bz2
cd gd-2.0.35 
./configure \
	--prefix=/usr/local/gd2 \
	--with-freetype=/usr/local/freetype2 \
	--with-png=/usr/local/libpng \
	--with-jpeg=/usr/local/jpeg6 \
	CPPFLAGS="-I/usr/local/zlib/include" \
	LDFLAGS="-L/usr/local/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=/usr/local/mysql \
	--enable-assembler \
	--without-debug \
	--with-mysqld-ldflags=-all-static \
	--with-charset=utf8 \
	--with-extra-charsets=all \
	--with-innodb \
	--with-unix-socket-path=/usr/local/mysql/mysql.sock \
	--enable-thread-safe-client \
	--with-mysqld-user=mysql
make
make install
 
cd ..
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  /usr/local/mysql; cp /usr/local/mysql/share/mysql/mysql.server /etc/init.d/mysqld ; /usr/local/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=/usr/local/php \
	--with-zlib=/usr/local/zlib \
	--with-zlib-dir=/usr/local/zlib \
	--with-apxs2=/usr/local/apache/bin/apxs \
	--with-mysql=/usr/local/mysql \
	--with-mysql-sock=/usr/local/mysql \
	--with-pdo-mysql=/usr/local/mysql \
	--with-libxml-dir=/usr/local/libxml2 \
	--with-gd=/usr/local/gd2 \
	--with-jpeg-dir=/usr/local/jpeg6 \
	--with-png-dir=/usr/local/libpng \
	--with-freetype-dir=/usr/local/freetype2 \
	--with-libxml-dir=/usr/local/libxml2 \
	--with-openssl=/usr/local/openssl \
	--with-iconv-dir=/usr/local/iconv \
	--with-ttf \
	--with-gettext \
	--enable-gd-native-ttf \
	--enable-mbstring \
	--enable-xml \
	--enable-pcntl \
	--enable-sockets \
	--enable-zip \
	--with-bz2 \
	--disable-debug 
make
make install
cp php.ini-dist /usr/local/php/lib/php.ini 
cd ..
 
# memcache
tar zxvf memcache-2.2.1.tgz
cd memcache-2.2.1
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-memcach
make 
make install
cd ..
 
sed -i 's#extension_dir = "./"#extension_dir = "/usr/local/php/lib/php/extensions/no-debug-zts-20060613/"\n\nextension = "memcache.so"\n#' /usr/local/php/lib/php.ini
sed -i 's#expose_php = On#expose_php = Off#' /usr/local/php/lib/php.ini
 
# soap
cd php-5.2.9/ext/soap
/usr/local/php/bin/phpize
./configure --with-php-config=/usr/local/php/bin/php-config --enable-soap
make
make install
cd
 
sed -i 's#extension = "memcache.so"#extension = "memcache.so"\nextension = "soap.so"#' /usr/local/php/lib/php.ini

LD_DEBUG

Standard

The dynamic library loader used in linux (part of glibc) has some neat tricks. One of these is that you can set an environment variable called

LD_DEBUG

to show how symbols (variables and functions, for example) are resolved for a dynamic executable. This can sometimes help resolve obscure bugs where your application isn’t doing what you expect (assuming it is caused by symbols being resolved differently to what you were expecting).

This is very useful if you get segmentation violations or aborts for a program – this can sometimes be caused by linking against the wrong version of a library. This is also a really good way to understand what happens when you run any program! It has some self-documentation – for the impatient, you can do

$ LD_DEBUG=help /path/to/some/dynamic/executable

eg

$ LD_DEBUG=help ls

prints out:

Valid options for the LD_DEBUG environment variable are:

libs display library search paths
reloc display relocation processing
files display progress for input file
symbols display symbol table processing
bindings display information about symbol binding
versions display version dependencies
all all previous options combined
statistics display relocation statistics
help display this help message and exit

To direct the debugging output into a file instead of standard output a
filename can be specified using the LD_DEBUG_OUTPUT environment variable.

As a quick example of what it does:

$ LD_DEBUG=all ls 2>&1 > /dev/null | less

13442:
13442: file=librt.so.1; needed by ls
13442: find library=librt.so.1; searching
13442: search cache=/etc/ld.so.cache
13442: trying file=/lib/librt.so.1
13442:
13442: file=librt.so.1; generating link map
13442: dynamic: 0x400263ec base: 0x40020000 size: 0x00010d14
13442: entry: 0x400219c0 phdr: 0x40020034 phnum: 6
13442:
13442:
13442: file=libc.so.6; needed by ls
13442: find library=libc.so.6; searching
13442: search cache=/etc/ld.so.cache
13442: trying file=/lib/libc.so.6
13442:
13442: file=libc.so.6; generating link map
13442: dynamic: 0x40146ce4 base: 0x40031000 size: 0x0011ab00
13442: entry: 0x4004a184 phdr: 0x40031034 phnum: 6
13442:

13442: checking for version `GLIBC_2.2′ in file /lib/librt.so.1 required by file ls
13442: checking for version `GLIBC_2.1′ in file /lib/libc.so.6 required by file ls
13442: checking for version `GLIBC_2.2.3′ in file /lib/libc.so.6 required by file ls

13442: relocation processing: /lib/libpthread.so.0 (lazy)
13442: symbol=_errno; lookup in file=ls
13442: symbol=_errno; lookup in file=/lib/librt.so.1
13442: symbol=_errno; lookup in file=/lib/libc.so.6
13442: symbol=_errno; lookup in file=/lib/libpthread.so.0
13442: symbol=_errno; lookup in file=/lib/ld-linux.so.2
13442: binding file /lib/libpthread.so.0 to /lib/libc.so.6: normal symbol `_errno’ [GLIBC_2.0]
13442: symbol=_h_errno; lookup in file=ls
13442: symbol=_h_errno; lookup in file=/lib/librt.so.1
13442: symbol=_h_errno; lookup in file=/lib/libc.so.6
13442: symbol=_h_errno; lookup in file=/lib/libpthread.so.0
13442: symbol=_h_errno; lookup in file=/lib/ld-linux.so.2
13442: binding file /lib/libpthread.so.0 to /lib/libc.so.6: normal symbol `_h_errno’ [GLIBC_2.0]

In other words, every single function and external variable in the standard library that ls(1) uses must be located each time it is run (kind of obvious, really).

$ ldd /bin/ls
librt.so.1 => /lib/librt.so.1 (0x40020000)
libc.so.6 => /lib/libc.so.6 (0x40031000)
libpthread.so.0 => /lib/libpthread.so.0 (0x4014c000)
/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

Pureftpd + Mysql

Standard
yum install -y mysql mysql-server
 
wget http://download.pureftpd.org/pub/pure-ftpd/releases/pure-ftpd-1.0.22.tar.gz
tar zxvf pure-ftpd-1.0.22.tar.gz
cd pure-ftpd-1.0.22
./configure \
--prefix=/usr/local/pureftpd \
--with-probe-random-dev  \
--with-paranoidmsg \
--with-altlog \
--with-puredb \
--with-extauth \
--with-pam \
--with-cookie \
--with-throttling \
--with-ratios  \
--with-quotas \
--with-ftpwho \
--with-largefile \
--with-welcomemsg  \
--with-uploadscript \
--with-virtualhosts \
--with-diraliases \
--with-virtualchroot \
--with-peruserlimits \
--with-language=simplified-chinese \
--with-mysql \
--with-tls \
--with-rfc2640
 
#如遇到 configure: error: libmysqlclient is needed for MySQL support 的话就 cp /usr/lib/mysql/libmysqlclient.sq /usr/lib/
make
make install
 
mkdir –pv /usr/local/pureftpd/etc
cp pureftpd-mysql.conf /usr/local/pureftpd/etc
cp configuration-file/pure-config.pl /usr/local/pureftpd/sbin/
cp configuration-file/pure-ftpd.conf /usr/local/pureftpd/etc/
chmod 755 /usr/local/pureftpd/sbin/pure-config.pl
 
cd contrib
cp redhat.init /etc/init.d/pureftpd
chmod u+x /etc/init.d/pureftpd
chkconfig --add pureftpd
chkconfig pureftpd on
vi /etc/init.d/pureftpd #修改其相关默认路径到 /usr/local/pureftpd/
 
wget http://machiel.generaal.net/files/pureftpd/ftp_v2.1.tar.gz
tar zxvf ftp_v2.1.tar.gz
#为其配置web访问,运行 install.php,按提示操作
#http://yemaosheng.com

Pureftp web端管理软件 ftp_v2.1.tar.gz