Store Session with Memcached in Magento

app/etc/local.xml :

[codesyntax lang=”xml”]

<config>
    <global>
        <session_save><![CDATA[memcache]]></session_save>
        <session_save_path><![CDATA[tcp://127.0.0.1:11211?persistent=1&weight=2&timeout=10&retry_interval=10]]></session_save_path>
        <session_cache_limiter><![CDATA[]]></session_cache_limiter>
        <cache>
            <backend>memcache</backend>
            <slow_backend></slow_backend>
            <memcached>
                <servers>
                    <server>
                        <host><![CDATA[127.0.0.1]]></host>
                        <port><![CDATA[11211]]></port>
                        <persistent><![CDATA[0]]></persistent>
                        <weight><![CDATA[]]></weight>
                        <timeout><![CDATA[]]></timeout>
                        <retry_interval><![CDATA[]]></retry_interval>
                        <status><![CDATA[]]></status>
                    </server>
                </servers>
                <compression><![CDATA[0]]></compression>
                <cache_dir><![CDATA[]]></cache_dir>
                <hashed_directory_level><![CDATA[]]></hashed_directory_level>
                <hashed_directory_umask><![CDATA[]]></hashed_directory_umask>
                <file_name_prefix><![CDATA[]]></file_name_prefix>
            </memcached>
        </cache>
    </global>
</config>

[/codesyntax]

Posted in Magento | Tagged | 2 Comments

Linux C hello world

1. vi functions.c
[codesyntax lang=”c”]

#include <stdio.h>

void hello_world(void)
{
    printf("hello world!!\n");
}

[/codesyntax]

2. vi hello.c
[codesyntax lang=”c”]

#include <stdio.h>
#include <stdlib.h>

void hello_world(void);

int main(int argc, char **argv)
{
    hello_world();
    exit(0);
}

[/codesyntax]

3. Make Executable hello
[codesyntax lang=”bash”]

# Object Files
$ gcc -g -c functions.c hello.c
# Executable hello
$ gcc -g -o hello functions.o hello.o
# Run hello
$ ./hello

[/codesyntax]

4. To make functions shared
[codesyntax lang=”bash”]

# create functions.o
$ gcc -fPIC -c functions.c
# Create functions.so
$ gcc -shared -o libfuc.so functions.o
# Make libfuc.so shared
$ mv libfuc.so /lib/
# Link libfuc.so to output
$ gcc -o hello -lfuc hel.c
# to see the libraries linked
$ ldd hello
$ ./hello

[/codesyntax]

Posted in C, Linux | Tagged , | Leave a comment

My Linux files/dirs Distribution

Here is my linux files/dirs distribution. Main purpose is to easily centralized data maintenance.

 

Company abc’s directory
/data/abc/

 

All web applications
/data/abc/vhosts/

 

All the packages and dependencies
/data/abc/soft_misc/ 放所有linux的安装包和依赖包

 

Logs
/data/abc/weblog/

 

Cache folder for eaccelerator_cache
/data/abc/eaccelerator_cache/

 

For storing MySQL data
/data/abc/mysqldata/
/data/abc/mysqldata/mysql_m1 分布式mysql master数据库
/data/abc/mysqldata/mysql_s1 分布式mysql slave 1 数据库
/data/abc/mysqldata/mysql_s2 分布式mysql slave 2 数据库

 

For subversion data and configurations
/data/abc/svndata/

 

Installation destination of company abc
/usr/local/abc/

 

Web servers destination, e.g. apache, nginx, ruby, php
/usr/local/abc/webserver

 

For subversion server
/usr/local/abc/svnserver

 

Posted in Linux | Tagged | Leave a comment

Install Webbench

1. Install
[codesyntax lang=”bash”]

$ wget http://home.tiscali.cz/~cz210552/distfiles/webbench-1.5.tar.gz
$ mkdir /usr/local/man
$ tar zxvf webbench-1.5.tar.gz
$ cd webbench-1.5
$ make && make install

[/codesyntax]

2. Test
[codesyntax lang=”bash”]

$ webbench -c 500 -t 30 http://127.0.0.1/index.html
# to see your cpu and process
$ top

[/codesyntax]

Posted in Linux | Tagged , | Leave a comment

Encode PHP by ionCube

1. Environment :
PHP 5.2.14
PHP-FPM 0.5.14

2. Encode with ionCube :
Download(purchase or try free trial) ionCube encoder from http://www.ioncube.com/
[codesyntax lang=”bash”]

$ cd /data/soft_misc/
$ tar xzf ioncube_encoder_evaluation.tar.gz
$ cd ioncube_encoder_evaluation
# encode the includes folder and ignore the configuration file : constants.php
$ ./ioncube_encoder5 --ignore "constants.php" -o /home/projects/abc/includes_ed /home/projects/abc/includes/
$ mv -f includes_ed/* includes/
$ rm -rf includes_ed

[/codesyntax]

3. Install ionCube Loaders (See http://www.ioncube.com/) :
[codesyntax lang=”bash”]

# download and unzip
$ cd /data/soft_misc/
$ wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz
$ tar -zxvf ioncube_loaders_lin_x86.tar.gz

# copy the extension to somewhere
$ cp ioncube/ioncube_loader_lin_5.2.so /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/

# modify php.ini
$ vi /usr/local/webserver/php/etc/php.ini
zend_extension = /usr/local/webserver/php/lib/php/extensions/no-debug-non-zts-20060613/ioncube_loader_lin_5.2.so

[/codesyntax]

[codesyntax lang=”bash”]

# restart PHP and Nginx
$ /usr/local/webserver/php/sbin/php-fpm restart
$ /usr/local/webserver/nginx/sbin/nginx -s reload

[/codesyntax]

See : ionCube-Encoder-USER-GUIDE

Posted in Optimization, PHP | Tagged , | Leave a comment