Sync Up the Repository by Rsync

rsync server : 192.168.0.132
rsync client : 192.168.0.133


1. Check and Install rsync :
[codesyntax lang=”bash”]

$ rpm -q rsync
$ yum install rsync

[/codesyntax]
or download and install from http://rsync.samba.org/

2. Configurations of rsync server (192.168.0.132) :
[codesyntax lang=”bash”]

$ vi /etc/rsyncd.conf
uid = root
gid = root
use chroot = no
max connections = 5
timeout = 3600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

[st]
path=/data/synctest/
auth user = kim
uid = root
gid = root
read only = true
list = false
ignore errors
host_allow =192.168.0.133
hosts deny = 0.0.0.0/32
secrets file = /etc/rsyncd.secrets

[/codesyntax]

3. User & Password :
[codesyntax lang=”bash”]

$ echo "kim:password" >> /etc/rsyncd.secrets
$ chown root:root /etc/rsyncd.secrets
$ chmod 600 /etc/rsyncd.secrets

[/codesyntax]

4. Open port 873 on both server and client :
[codesyntax lang=”bash”]

$ iptables -A INPUT -p tcp -m state --state NEW -m tcp --dport 873 -j ACCEPT

[/codesyntax]

5. Rsync daemon :
[codesyntax lang=”bash”]

# start
$ nohup /usr/bin/rsync --daemon --config=/etc/rsyncd.conf &
# stop
$ kill `cat /var/run/rsyncd.pid`

[/codesyntax]

6. Set autorun :
[codesyntax lang=”bash”]

$ echo '/usr/bin/rsync --daemon --config=/etc/rsyncd.conf' >> /etc/rc.local

[/codesyntax]or
[codesyntax lang=”bash”]

$ vi /etc/xinetd.d/rsync
set "disable" to no

[/codesyntax]




7. List all the files of remote dst-dir :
[codesyntax lang=”bash”]

$ rsync -r kim@192.168.0.133:/home/kim/

[/codesyntax]

8. Sync dir :
[codesyntax lang=”bash”]

# sync /data/synctest/ to /data/synctest2/
$ rsync -av --progress /data/synctest/ /data/synctest2/

# sync /data/synctest/ to /data/synctest2/ and delete the unsync files
$ rsync -av --progress --delete /data/synctest/ /data/synctest2/

# sync local /data/synctest/ to remote /home/kim/st/ :
$ rsync -avz --progress /data/synctest/ kim@192.168.0.133:/home/kim/st/

# sync remote folder /home/kim/st to be under /data/synctest/st
rsync -avz --progress kim@192.168.0.133:/home/kim/st /data/synctest/

# sync remote folder /home/kim/st/ to be /data/synctest/
rsync -avz --progress kim@192.168.0.133:/home/kim/st/ /data/synctest/

[/codesyntax]

Posted in RHEL | Tagged , | Leave a comment

Install yum on RHEL5

1. Delete the default yum :
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ rpm -aq | grep yum | xargs rpm -e --nodeps

[/codesyntax]

2. Install yum of from http://mirrors.163.com/centos/5/os/i386/CentOS/ :
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ wget http://mirrors.163.com/centos/5/os/i386/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm
$ wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm
$ wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
$ wget http://mirrors.163.com/centos/5/os/i386/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm

$ rpm -ivh python-iniparse-0.2.3-4.el5.noarch.rpm
$ rpm -ivh yum-metadata-parser-1.1.2-3.el5.centos.i386.rpm
$ rpm -ivh yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm yum-3.2.22-26.el5.centos.noarch.rpm

[/codesyntax]

3. Download Config to /etc/yum.repos.d/ :
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ wget http://sudone.com/download/CentOS-Base.repo -O /etc/yum.repos.d/CentOS-Base.repo

[/codesyntax]

4. Test :
[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ yum search kernel
$ yum install ImageMagick
$ yum update

[/codesyntax]

Posted in RHEL | Tagged , | 2 Comments

Install eAccelerator for PHP

1. Environment :

PHP 5.2.14 : /usr/local/webserver/php
PHP-FPM 0.5.14 : /usr/local/webserver/php/etc/php-fpm.conf
eAccelerator 0.9.6.1 : /data/soft_misc/eaccelerator-0.9.6.1.tar.bz2


2. Install eAccelerator :

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ cd /data/soft_misc/
$ tar -xjf eaccelerator-0.9.6.1.tar.bz2
$ cd eaccelerator-0.9.6.1
$ /usr/local/webserver/php/bin/phpize
$ ./configure --enable-eaccelerator=shared --with-php-config=/usr/local/webserver/php/bin/php-config
$ make
$ make install

[/codesyntax]

3. Configurations of eAccelerator :

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ mkdir -p /data/eaccelerator_cache
$ vi /usr/local/webserver/php/etc/php.ini

[eaccelerator]
zend_extension="/usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="256"
eaccelerator.cache_dir="/data/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"

[/codesyntax]

4. Reload PHP-FPM :

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ /usr/local/webserver/php/sbin/php-fpm reload

[/codesyntax]

5. See phpinfo to check if eAccelerator is Installed

Posted in PHP | Tagged , | Leave a comment

Mini Login Form in Magento Home Page

1. Find and modify cms_index_index tag within /layout/cms.xml :

[codesyntax lang=”xml” lines=”no” container=”pre” tab_width=”4″]
<cms_index_index translate=”label”>
<label>CMS Home Page</label>
<reference name=”head”>
<action method=”setForcedTitle”><title>Homepage登录框</title></action>
</reference>
<reference name=”content”>
<block type=”customer/form_login” name=”customer_form_mini_login” after=”-” template=”customer/form/mini.login.phtml” />
</reference>
</cms_index_index>
[/codesyntax]

2. Hide the form within /template/customer/form/mini.login.phtml if the customer is logged in :

[codesyntax lang=”php” lines=”no” container=”pre” tab_width=”4″]

<?php if (!Mage::getSingleton( 'customer/session' )->isLoggedIn()):?>
<div class="block block-login">
    ......
</div>
<?php endif ?>

[/codesyntax]

3. Modify the page header within /template/page/html/head.phtml :

[codesyntax lang=”php” lines=”no” container=”pre” tab_width=”4″]

<title>
<?php
if (Mage::getSingleton('cms/page')->getTitle() == 'Home') {
    echo $this->getDefaultTitle();
} elseif ($this->getForcedTitle()) {
    echo Mage::getStoreConfig('design/head/title_prefix') . ' '
       . $this->getForcedTitle() . ' '
       . Mage::getStoreConfig('design/head/title_suffix');
} else {
    echo $this->getTitle();
}
?>
</title>

[/codesyntax]

4. Create the cms page in backend and set it as home page, then you can see the login form.

Posted in Magento | Tagged | 2 Comments

Use SMTP with Telnet

Test local SMTP :

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ telnet localhost 25
$ helo localhost
$ mail from:xx@abc.com
$ rcpt to:xqpmjh@gmail.com
$ data
$ subject:and i love you too!
$ yes, this is the content end by "."
$ .
$ quit

[/codesyntax]
Test remote SMTP (with auth) :

[codesyntax lang=”bash” lines=”no” container=”pre” tab_width=”4″]

$ telnet smtphost 25
$ auth login
$ base64_encode(myusername)   # this means must be base64_encode
$ base64_encode(mypassword)   # this means must be base64_encode
$ helo nickname
$ mail from:myusername   # this means we must use the same user name as login
$ rcpt to:xqpmjh@gmail.com
$ data
$ subject:and i love you too!
$ yes, this is the content end by "."
$ .
$ quit

[/codesyntax]

Posted in Linux | Tagged , | Leave a comment