Monday, November 23, 2009

php website for mobile devices

When it comes to making a website for mobile devices, a lot of things needs to be throw out of your site. :)

mobile devices are powered by low power processors; something which your laptop or desktop computer is far more advanced with.

Steps:

Place a detection on your index.php page (or your homepage) to redirect mobile users to a different site. Typically, your mobile version of site will begin with http://m.mysite.com

The mobile site should use 1 column layout for development. You cannot build a website with multiple columns (since mobile browsers decode html differently on many occassions; you do not want to mess up your site)

Use images which are low resolution, but suitable for viewing on mobile devices. In mobile devices, every penny counts when it comes to size of website. It is best to get rid of images which are around 50kb or more for mobile devices.

use lightweight css. (prevent mobile processors from doing a lot of job for you. So use, lightweight css for your website to load up faster on mobile devices.)

Below are links that can help you get started.

Redirect php website to mobile device

Developing light weight css for php website on mobile devices

PAMP (Open source by nokia for mobile devices)

Wednesday, November 4, 2009

install java in centos 5

Strangly, Java does not come installed in centos. Hence, here is the procedure.

Download jdk (which automatically includes jre) through Java JDK Download (Also, see the screenshot attached.)

Once downloaded, you can follow instructions over here,

Say you downloaded a .bin file, such as jdk-6u17-linux-i586.bin

$pwd
/home/myName

$ls
jdk-version-6-u17-linux-i586.bin

$chmod +x jdk-6u17-linux-i586.bin

going to directory where I want java to be installed

$cd /usr/local/

executing the .bin file

$/home/myName/jdk-6u17-linux-i586.bin

it will display some text on screen, that is the license agreement. Keep pressing enter to scroll. It is a long document, so you might want to press enter around 50 times or more. When the license agreement ends, you will see a question

Do you agree above license terms? [yes or no]

type yes and press enter.

and watch it installed.

After installation is done, the prompt will come back to you.

Now for the one last step. We need to create a link.

$ln -s /usr/local/jdk1.6.0_17/bin/java /usr/bin/java

(I am assuming, upon running the .bin file, you will see a folder named jdk1.6.0_17 in /usr/local/. The folder name could change, but it will be created in /usr/local/)

$java -version

It should show you the version installed.

$whereis java

will show you were java files and jave executable are placed.

If above two, does not work, it means java did not set in the path.

Your java is installed in /usr/local

Go there and look for folder. It should be jdk-1.6.0_17 (or something like that),do

$cd jdk-1.6.0_17/bin/

$pwd
/usr/local/jdk-1.6.0_17/bin/

Your path to java is /usr/bin/java (which is link to /usr/local/jdk-1.6.0_17/bin/java). You will need to set path in your .bash_profile

Look for my previous post on how to do it.


Making path change in .bash_profile and then how to refresh or reload

whenever you log into your linux and open a terminal, do this.

$pwd

This will show you your home directory. Typically, if you are root it is

/root

If you are having a user account in your name, it should be

/home/myName

Now, try this at the prompt,

$ls -all

And look for .bash_profile This file is the one who knows what paths are set in your account

You can add more paths to it and then save it. Once .bash_profile is saved, in order to make changes effective, you will need to do

$. .bash_profile
[Note the two dots before bash_profile]

OR


$source .bash_profile


And then do,

$echo $PATH

you will be able to see new paths shown.

Friday, October 30, 2009

Installing php 5.2.9

In CentOS, if you do

php --version

you will get it as 5.1.x

But if you are planing to use zend search lucene (http://www.zend.com/community/downloads and look for Zend Framework 1.9 minimal) or any of other zend packages, system requirements shows you need 5.2.4 or higher.

So how to upgrade php to 5.2.9 in centos 5?

Best Method:

http://www.freshblurbs.com/install-php-5-2-centos-5-2-using-yum#comment-403

The solution presented by "Great" on the above link is the perfect one.

This is what he says,

All, we need to do is create /etc/yum.repos.d/CentOS-test.repo and enter following lines in it:

[c5-testing]
name=CentOS-5 Testing 
baseurl=http://dev.centos.org/centos/5/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing

Once done, just type

yum upgrade php

and you are good to go. Upon completion, the php is upgraded to 5.2.9

Others methods are:

(1)
One way to do so is http://www.atomicorp.com/wiki/index.php/PHP using yum.

But it did not work out for me, so I tried,

(2)
# wget ftp://xmlsoft.org/libxml2/libxml2-2.7.3.tar.gz
# tar xzvf libxml2-2.7.3.tar.gz
# cd libxml2-2.7.3
# ./configure
# make
# su -c “make install”


# wget http://uk2.php.net/get/php-5.2.9.tar.gz/from/uk.php.net/mirror
# tar zxvf php-5.2.9.tar.gz
# cd php-5.2.9
# ./configure –enable-soap
# make
# su -c “make install”


I took this solution from, http://imthi.com/blog/linux/install-or-update-php-5-on-centos.php#comment-28316 given by Brent.

It worked for me. after doing the above steps, when I did,

php --version

on command prompt. It should show, 5.2.9. But on apache, doing phpinfo() it showed 5.1.6 So the answer lies in PHPIniDir line in httpd.conf. Just need to add PHPIniDir "path/to/php" in httpd.conf.

Restart apache and system and enjoy !

Monday, October 26, 2009

Zend Lucene and Php

Zend Lucene is a powerful open source search engine. Couple of years ago, they extended their support to PHP. However, if you want zend lucene to work with Php, you will need PHP 5.0 Php 4 will not work.

Below are a few links to get you started.

http://www.phpriot.com/articles/zend-search-lucene

http://ganeshhs.com/zend-framework/zend-search-lucene-part1

http://framework.zend.com/manual/en/zend.search.lucene.html (complete guide)

Feel free to post any questions in comment section.

Saturday, October 24, 2009

Php and Design Pattern

Design Patterns are mostly studied while Java programming. However, now is not the case. With introduction of PHP 5 and its MVC (Model-View-Controller) structure. We can use Design Pattern with PHP too.

Below are few links which I found helpful in understanding Design Pattern in PHP.

http://sourcemaking.com/design_patterns

http://www.tonymarston.net/php-mysql/design-patterns.html

http://www.fluffycat.com/PHP-Design-Patterns/

http://www.ibm.com/developerworks/library/os-php-designptrns/

Feel free to ask any questions by posting in comments section.

Tuesday, September 29, 2009

graphical ssh for linux

Hi,

For those who are new into linux world. Graphical ssh for linux is always an issue. People look for GUI in linux.

There is one which I use named Konqueror.

How to get that? It is probably installed already in linux.

Go to, applications -> internet -> konqueror.

On the address bar, type

sftp://username@ip.address.of.site

or

sftp://username@www.mysite.com

and it will come up with graphical view of your ssh.

To add files,

draw your files from local machine into the browser window. You will see three options,

a. move
b. copy
c. cancel

Select your choice and transfer will begin.

NOTE: While transfering from konqueror window to your local machine. It is always a move operation. So be careful while dragging files from konqueror to your local machine.

Monday, September 28, 2009

firefox does not work after update

Hi,
When you updated centOS 5 packages, there is a possibility that current firefox 3.0 installed in your system will not work.

Here is what you need to do:

1) go to terminal window and type

$firefox

You should see, a message like this one,

Could not find compatible GRE between version 1.9b5pre and 1.9b5pre

It can also be like,

Could not find compatible GRE between version 1.9b5 and 1.9b5pre

When you get such a kind of error, do this.

2) get latest version of firefox at www.firefox.com

3) go to location where you downloaded the tar.bz2

4) tar -xvjf firefox*.tar.bz2
Here firefox* means it can be firefox-3.5.3 or any other.

5) this will create a folder with name firefox into your current folder.

6) you can transfer all contents from firefox folder into a new folder in /usr/lib.

$cd /usr/lib/
$mkdir firefox
$cd firefox
$mv path/to/firefox/tar/extracted/location .

7) once all files are copied to new /usr/lib/firefox/ , do the following

$pwd
/usr/lib/firefox/
$./firefox-bin

8) this will open a new window and will tell you about update of any existing plugin

9) click update to update all plugins.

10) once plugins are installed,firefox browser will open and ask to set it as default browser.

11) make firefox your default browser.

12) close firefox browser and go back to terminal. You will get a prompt back once firefox brower gets closed.

13) exit the terminal.

You are done!

Go to applictions->internet->mozilla firefox browser and it will open up for you.

In my case, the old bookmarks in firefox were restored. So, there is no problem.

Milan Pandya