Archive for the ‘ Web ’ Category

Changing default apache page on Ubuntu

Open your Apache configuration file httpd.conf

on ubuntu it is in /etc/apache2/httpd.conf and open it using

sudo gedit /etc/apache2/httpd.conf

then put your desired filename on directory index—

DirectoryIndex index.html index.htm default.htm index.php

Changing default apache page on Ubuntu

Open your Apache configuration file httpd.conf

on ubuntu it is in /etc/apache2/httpd.conf and open it using

sudo gedit /etc/apache2/httpd.conf

then put your desired filename on directory index—

DirectoryIndex index.html index.htm default.htm index.php


Changing English date format to Bangla date format

i use here the following function to change English date format to Bangla date format when displaying —-

function getBanglaDate($date){
 $engArray = array(
 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December',
 'am', 'pm'
 $bangArray = array(
 'জানুয়ারি', 'ফেব্রুয়ারি', 'মার্চ', 'এপ্রিল', 'মে', 'জুন', 'জুলাই', 'আগস্ট', 'সেপ্টেম্বর', 'অক্টোবর', 'নভেম্বর', 'ডিসেম্বর',
 'সকাল', 'দুপুর'

 $converted = str_replace($engArray, $bangArray, $date);
 return $converted;


calling procedure is like —


 if($GLOBALS['lang'] == "bn"){
 $date = date( 'j F, Y, a g:i',strtotime($publisheddate) ) ;
 $date = getBanglaDate($date);
 }else if($GLOBALS['lang'] == "en"){
 $date = date( 'j F, Y, g:i a',strtotime($publisheddate) ) ;

So when if send a date format like  “28 July, 2010, 12:00 am”  then it returns   “২৮ জুলাই, ২০১০, সকাল ১২:০০”    date format


Simple steps to setting up virtual host host on Ubuntu Server

Virtual host is a virtual environment over the top of your current web server to simulate a separate hosting environment. Using virtual host you can enable site specific features and keep your development environment totally separate from another one.

For tutorial you need to mod_rewrite enabled.

Step 1: setup hosts file

open /etc/hosts and add a virtual domain with a specific local IP.

Lets assume that our virtual domain name is “” and It will listen to the ip “″

so on /etc/hosts file we will add

now whenever you browse your browser will actually hit

Step2: configure virtual host with apache
Now goto /etc/apache2/sites-available and create a file named “

sudo touch ruzdi
sudo gedit /etc/apache2/sites-available/ruzdi

write the following contents inside. but please note to create the appropriate directory before linking your virtual host with that, for example we’ve create a folder named “/var/opt/ruzdi” and linked that directory as my document root in the following configuration file.

        DocumentRoot /opt/ruzdi
        <Directory /opt/ruzdi/>
                Options FollowSymLinks
                AllowOverride All


now create a symbolic link of this file to /etc/apache2/sites-enabled directory as “

sudo ln -s /etc/apache2/sites-available/ruzdi /etc/apache2/sites-enabled/ruzdi

**** here look directory location is /opt/ruzdi so you must create a directory named “ruzdi” on /opt location

Step 3: restart apache

simple, either one of the followings

sudo a2ensite ruzdi


sudo /etc/init.d/apache2 restart

now on your browser to http://

***This is post is similar Hasin Hyder blog post I just change a little. In my case on the hosts file port was not working so I removed it and I got everything all right.

source :


Hasin Hyder

Setting up zend framework on ubuntu server

Now i am going to install the Zend Framework. Download the most recent version from the Zend Framework website and extract it to the /opt folder.

To enable us to easily switch out different versions, we will create a symbolic link to this folder (just right click and select the ‘Make link’ option and name it ‘zend’ and place it to your favourite location in my case I placed it to /var/www/ )

Next, we will tell php to include the zend framework in the include_path.

sudo gedit /etc/php5/apache2/php.ini

Add/Change the include_path in to :

include_path = ".:/var/www/zend/library"

Note that I used the symbolic link in the include path.. This way, when there is a new version of ZF, we can just switch out the symlink without having to edit the ini file!

In order to use the zend framework command line tool (/var/www/zend/bin/, we need to install the php command line interface (php5-cli).

sudo apt-get install php5-cli

Note that the CLI uses a different version of the php.ini file (NOT the one in the apache2 folder but in the cli folder!). We need to tell CLI also where the zend framework directory is located.

sudo gedit /etc/php5/cli/php.ini

and set:

include_path = ".:/var/www/zend/library"

The final step is to include the path to /opt/Zend/bin in the unix PATH variable (this way, you can use instead of /var/www/ zend/bin/ use the following command .

sudo gedit ~/.bashrc

Add the following line at the end:


The Zend Framework relies on the apache “rewrite” module. So, go ahead and enable the “rewrite” module using the following command:

sudo a2enmod rewrite

Restart apache..

sudo /etc/init.d/apache2 restart

and you should be all set

Simple steps to Installing Xdebug on Ubuntu Server

First install pear

sudo apt-get install php5-dev php-pear

Now install xdebug thru PECL.

sudo pecl install xdebug

Now we need to find where went (the compiled module)

find / -name '' 2> /dev/null /usr/lib/php5/20090626/

20090626 is for my case it might be different for you

Then edit php.ini

sudo gedit /etc/php5/apache2/php.ini

Add the following line:


Then restart apache

sudo /etc/init.d/apache2 restart

for changes to take effect.

sudo /etc/init.d/apache2 restart

For checking it is install or not —

create a file on /var/www/  as info.php

and open it

sudo gedit /var/www/info.php

and write —


Now we call that file in a browser (e.g. http://localhost/info.php):

Xdebug Test

Xdebug Test

Cheers ………

Simple steps to install Apache, MySql , PHP (LAMP) and PhpMyAdmin On Ubuntu Server

Install mysql :

First we install MySQL 5 like this:

sudo apt-get install mysql-server mysql-client

You will be asked to provide a password for the MySQL root user – this password is valid for the user root@localhost as well as, so we don’t have to specify a MySQL root password manually later on:

New password for the MySQL “root” user: <– yourrootsqlpassword
Repeat password for the MySQL “root” user: <– yourrootsqlpassword

Install apache:

Apache2 is available as an Ubuntu package, therefore we can install it like this:

sudo apt-get install apache2

Now direct your browser to http://localhost/ and you should see the Apache2 placeholder page (It works!):

Apache Test

Apache Test

Apache’s default document root is /var/www on Ubuntu, and the configuration file is /etc/apache2/apache2.conf. Additional configurations are stored in subdirectories of the /etc/apache2 directory such as /etc/apache2/mods-enabled (for Apache modules), /etc/apache2/sites-enabled (for virtual hosts), and /etc/apache2/conf.d.

Install php:

We can install PHP5 and the Apache PHP5 module as follows:

sudo apt-get install php5 libapache2-mod-php5

We must restart Apache afterwards:

sudo /etc/init.d/apache2 restart

Testing PHP5 / Getting Details About Your PHP5 Installation

The document root of the default web site is /var/www. We will now create a small PHP file (info.php) in that directory and call it in a browser. The file will display lots of useful details about our PHP installation, such as the installed PHP version.

sudo gedit /var/www/info.php

and write —


Now we call that file in a browser (e.g. http://localhost/info.php):

PHP Test

PHP Test

As you see, PHP5 is working, and it’s working through the Apache 2.0 Handler, as shown in the Server API line. If you scroll further down, you will see all modules that are already enabled in PHP5. MySQL is not listed there which means we don’t have MySQL support in PHP5 yet.

Getting MySQL Support In PHP5

To get MySQL support in PHP, we can install the php5-mysql package. It’s a good idea to install some other PHP5 modules as well as you might need them for your applications. You can search for available PHP5 modules like this:

sudo aptitude search php5

Pick the ones you need and install them like this:

sudo apt-get install php5-mysql php5-curl php5-gd php5-idn php-pear php5-imagick php5-imap php5-mcrypt php5-memcache php5-mhash php5-ming php5-ps php5-pspell php5-recode php5-snmp php5-sqlite php5-tidy php5-xmlrpc php5-xsl php5-json

Now restart Apache2:

sudo /etc/init.d/apache2 restart

Now reload http://localhost/info.php in your browser and scroll down to the modules section again. You should now find lots of new modules there, including the MySQL module.

Install php gd library :

sudo apt-get install php5-gd

Enable rewrite module

sudo a2enmod rewrite

Now restart Apache2:

sudo /etc/init.d/apache2 restart

Cnage apache settings —

Run the followint command

sudo gedit /etc/apache2/sites-enabled/000-default

then change –

<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews

AllowOverride None

Order allow,deny

allow from all



<Directory /var/www/>

Options Indexes FollowSymLinks MultiViews

AllowOverride all

Order allow,deny

allow from all


install  phpMyAdmin

PhpMyAdmin  is a web interface through which you can manage your MySQL databases. It’s a good idea to install it:

sudo apt-get install phpmyadmin

You will see the following questions:

Web server to reconfigure automatically: <– apache2
Configure database for phpmyadmin with dbconfig-common? <– No

Afterwards, you can access phpMyAdmin under http://localhost/phpmyadmin/:

Phpmyadmin Test

Phpmyadmin Test

Only 10 easy steps to install Memcached Server and access it with PHP

Running You First Application using Memcached Server  thats good you are in right place ———

memcached is a high-performance memory object caching system intended to speed up dynamic web applications by alleviating database load.

memcached is meant to work in concert with something like the MySQL query cache, not replace it. The two implementations excel at vastly different things: memcached is an object cache, while MySQL provides a query cache.

memcached is extremely fast. It uses libevent, which provides a mechanism to execute a callback function when a specific event occurs on a file descriptor, to scale to any number of open connections. On a modern Linux system memcached utilizes epoll, is completely non-blocking for network I/O, ensures memory never gets fragmented, and uses its own slab allocator and hash table to achieve 0(1) virtual memory allocation.

Memcache consists of two parts; a server library which runs the caching daemon and a client library which allows PHP to interact with the server. The server library is called memcached and it depends on the libevent library, so the first step in the installation process is getting a recent copy of libevent.

Hi this time i am introducing cahching using memchache Server with some easy steps—

***** Remember for ubuntu users if any command does not support or running on command line then goto

System->Administration->Synaptic Package Manager and search by the package name and install

Step1: Install libevent

on fedora

yum install libevent

yum install libmemcached libmemcached-devel

or on ubuntu

sudo apt-get install libevent

sudo apt-get libmemcached libmemcached-devel

Step 2: Install Memcached Server

on fedora

yum install memcached

or on ubuntu

sudo apt-get install memcached

Step 3: Start Memcached server

memcached -d -m 512 -l -p 11211 -u nobody

(d = daemon, m = memory, u = user, l = IP to listen to, p = port)

Step 4: Check your memcached server is running successfully

ps -eaf | grep memcached

Testing the memcached daemon with telnet

Step 5:Connect Memcached server via telnet

telnet 11211

Step 6: Check current status of Memcached Server on telnet prompt


Step 7: Exit telnet


Step 8: Install PHP client to access Memcached Server

if do not have pear install then first intall pear package —-

on fedora

yum <em>install php</em>-<em>pear </em>(if pear is already this command is not necessary)

on ubuntu

sudo apt-get install php-pear  (if pear is already this command is not necessary)


pecl install memcache


sudo pecl install memcache

It will make “”,

you have add a line

on your



sudo gedit /etc/php5/apache2/php.ini


Step 9: Restart your apache server

on fedora

service httpd restart

or on ubuntu

sudo /etc/init.d/apache2 restart

Check your php info

create a file info.php on your local server and write

echo phpinfo();

then run on the browser you will find ————-


Memcache Image

Memcache Image

Step 10: Open your favorite editor to write the following code and execute it, it will cache your data into Memcached server and access it back for you


$memcache = new Memcache;

$memcache->connect('', 11211) or die ("Could not connect"); //connect to memcached server

$mydata = "Chache me Ruzdi"; //string to be cached

$memcache->set('ruzdi', $mydata, false, 100); //add the data to memcached server

$cacheData = $memcache->get('ruzdi'); //retrieve your data from memcache server

var_dump($cacheData); //dump you data which is retrived from memcached server


Cheers …….

This is written with the help of following site——–