Monday 15 April 2013

How to host multiple domains on the same http server using the same ip address

In Apache HTTP Server,we can use Name-based Virtual Hosts to host multiply domains on the same server using the same ip address. Using this method, you can have many different hosts sharing the same IP address. This method you need to configure your DNS server to map each hostname to the (same) IP address and set the Apache HTTP Server to recognize the different hostnames. This method of virtual hosting reduce the demand for IP addresses. Supposing you want to host 2 domains on 1 http server,you add the following to httpd.conf.

<virtualhost>
    # The first virtual host is also the default for *:80
    ServerName www.fc18.com
    ServerAlias fc18.com *.fc18.com
    DocumentRoot /var/www/html
</virtualhost>

<virtualhost>
    ServerName other.hosts.com
    ServerAlias hosts.com
    DocumentRoot /var/www/hosts
</virtualhost>

In the DNS server, you can add these to (bind) named.conf:

www.fc18.com.    A 192.168.0.16
fc18.com.        A 192.168.0.16
other.hosts.com. A 192.168.0.16
hosts.com.       A 192.168.0.16 
If you are using hosts file, you can add these to hosts file:

192.168.0.16 www.fc18.com
192.168.0.16 fc18.com
192.168.0.16 www1.fc18.com
192.168.0.16 other.hosts.com
192.168.0.16 hosts.com

Thursday 11 April 2013

Install APC (php) on Fedora 18

The Alternative PHP Cache (APC) is a bytecode optimization opcode cache for PHP. This free cache leads to faster runtime execution as it stores the final, compiled result in shared memory. To install APC, you can setup using YUM.
[root@localhost ~]# yum install php-pecl-apc
Using YUM method, it will create /etc/php.d/apc.ini , enabling apc extension module "extension = apc.so". If apc.ini is not found, you can insert "extension = apc.so" into php.ini. After apache restart(service httpd restart), you will see apc enabled in phpinfo.php. APC,cache,phpinfo

Wednesday 10 April 2013

How to setup MySQL Query Cache

The query cache stores the text of a SELECT statement together with the corresponding result that was sent to the client. If an identical statement is received later, the server retrieves the results from the query cache rather than parsing and executing the statement again.

By default query cache size is 0, which is deactivated. To enable it, you can set the query_cache_size to 1000000.

mysql> SET GLOBAL query_cache_size = 1000000;
Query OK, 0 rows affected (0.04 sec) 

mysql> SHOW VARIABLES LIKE 'query_cache_size';
+------------------+--------+ 
|Variable_name     | Value  | 
+------------------+--------+ 
| query_cache_size | 999424 | 
+------------------+--------+ 
1 row in set (0.00 sec)

Create barcodes on CENTOS/FEDORA Linux

To create barcode for Linux, you need to install "barcode" rpm. Suppose you want to create a 13 numbers barcode, and save it to postscript file, and convert the postscript file to pdf, you can do this.

[root@centos6-1 temp]# yum install barcode
[root@centos6-1 temp]# barcode -o test.ps -e EAN -b 9557447805435
[root@centos6-1 temp]# ps2pdf test.ps test.pdf

Tuesday 9 April 2013

How to install Perl modules using CPAN

To install additional Perl modules found in CPAN, but not in yum, you can download Perl-CPAN package. Lets say you need a Perl module call "Time::HiRes". You can do this.

[root@localhost ~]# yum install perl-CPAN
[root@localhost ~]# cpan
Terminal does not support AddHistory.
cpan shell -- CPAN exploration and modules installation (v1.9800)
Enter 'h' for help.
cpan[1]> install Time::HiRes

How to display multiple memcache servers statistics

To display multiple memcache servers statistics, you can run below php script.


<?php
$servers = array(
    array('127.0.0.1', 11211, 33),
    array('192.168.0.55', 11211, 67)
);

$memcache = new Memcache;
$memcache->addServer('192.168.0.23',11211);
$memcache->addServer('192.168.0.55',11211);
$return = $memcache->getExtendedStats();
$unique_key=array();
foreach ($return as $key => $value) {
    foreach ($value as $key2 => $value2) {       
        array_push($unique_key,$key2);
    }
}

$unique_key=array_unique($unique_key);   
echo "<table border='2' align=\"center\" width=\"100%\" >";
echo "<tr><th/>";
foreach ($return as $key => $value) {   
    echo "<th>$key</th>";   
}

echo "</tr>";
foreach ($unique_key as $key0) {   
    echo "<tr align=\"center\"><td>$key0</td>";   
    foreach ($return as $key => $value) {
        echo "<td>".$return[$key][$key0]."</td>";       
    }
    echo "</tr>";
}
echo "</table>";

?>

Monday 8 April 2013

Upgrade PECL Memcache extension

The following instructions will download latest PECL Memcache extension. Goto PECL Memcache website. Download the tgz file using wget, and install as follows.

$ mkdir /tmp/temp
$ cd /tmp/temp
$ wget http://pecl.php.net/get/memcache-3.0.8.tgz
$ tar -xzvf memcache-3.0.8.tgz
$ cd memcache-3.0.8/
$ phpize
$ ./configure
$ make
$ make test
$ make install
$ service httpd restart

search iomeweekly