How To: Install PHP 5.3 on CentOS 5.1 or RHEL 5.1

PHP 5.2 and PHP 5.3 has tons of functionalities which are not provided by PHP 5.1 and PHP 5.1 is the most recent version of PHP available in CentOS 5.1 and RHEL 5.1 via updates. Also, its difficult for people to upgrade OS(s) on production servers frequently and especially if the servers are running absolutely fine, it doesn’t really make sense to upgrade just for the heck of it. One more reason for no upgrades is the OS choices provided by many hosting companies. But a lot of CMS(s) and softwares are now recommending at least PHP 5.2 for an extended feature set.

I tried a lot of repos for CentOS including RPM Fusion, RPM Forge, EPEL etc., but none of them could provide even PHP 5.2. In some corner of my mind, I had a faint idea of Remi Collet publishing updates about Remi repository. Did a quick google search and found out that PHP 5.3 is actually available in the repository πŸ˜€

So, if you are really in need of PHP5.3 on your CentOS/RHEL 5.1 or lesser, head over to Repository Configuration Page and follow the instructions.

Note: The repository is not enabled on install (enabled=0). You need to enable it in /etc/yum.repos.d/remi.repo.

Once installed and enabled, you can update PHP, MySQL from remi repository using the following command

[root@fedora ~]$ yum update php php-* mysql-*

Warning: Drupal is still not totally compatible with PHP5.3 and if you run Drupal sites, be sure to investigate things before upgrading.

 

How To: New Mail Notification

mbooth commented on one of my last post (How To: GNOME GMail Notifier) informing that he/she uses mail-notification. I was curious to check it out for mail via IMAP and I found it way more useful as compared to Gnome Gmail Notifier. I especially like the option to configure it to check the mails every ten seconds. Thats way cool for anxious people like me πŸ™‚ Keeping in mind the huge advantages of mail-notification, I thought of writing an howto for configuring it πŸ™‚

Install Mail Notification

Installing something can’t be simpler. Just use the following command as root

[root@fedora ~]$ yum install mail-notification

Configuring mail-notification is very simple. Its as easy as it can get but there are tricks for special cases like Gmail forΒ  Google Apps hosted websites.

Launch Mail Notification

Mail notification loses a point here. It doesn’t show up in any of the menus. You have to launch it from command line. You can launch mail-notification from System -> Preferences -> Mail Notification (Thanks mbooth for correcting). Or use the following command as normal user to launch mail notification

[saini@fedora ~]$ mail-notification -p

Configure Status Icon Behaviour

On mail notification properties windows, select Status Icon tab and choose the appropriate behaviour.

Mail Notification Status Icon Action

New Message Popup Settings

Now go to Message Popups tab, and select appropriate options. If you don’t enable popups, using mail notification doesn’t really make sense (though none can prevent you from doing so πŸ™‚ ). Keeping popus stacked is good because it shows you all messages in case you get more than one new mails in an interval. Also, you can configure the expiration time for the popups.

Mail Notification Message Popups Settings

Add New Mailbox

Now select General tab and click of Add button. Mail-notification supports checking new mails from Evolution, Gmail, Yahoo! Mail, Windows Live Mail, any IMAP and POP3 Server and moreover your system mailbox πŸ™‚ Select Gmail for mailbox type. Enter username and password for Gmail account.

Mail Notification Supported Mailboxes

Mail Notification Add Gmail Account

Now move over to Details tab and set delay between checking mails. I keep it 10 seconds πŸ™‚

Mail Notification Gmail Account Settings

Add a Google Apps Hosted Email Account

This is totally optional πŸ™‚ Now we’ll add a Google Apps hosted account. This is a bit tricky. For mailbox type, you’ll have to select Gmail. For username, you’ll have to provide your email address.

Mail Notification Add Google Apps Hosted Account

Also, the mailbox name has to be modified in this case to make things work. Move over to Details tab and change mailbox name to your email address.

Mail Notification Google Apps Hosted Account Settings

Add a new IMAP mailbox (Gmail)

This is totally optional πŸ™‚ Keep mailbox type as IMAP. IMAP Server has to be imap.gmail.com . Username and password are same as Gmail Account.

Note: For this mailbox to work, you’ll have to enable IMAP in settings tab in Gmail.

Mail Notification Gmail IMAP Account

Now move over to Connection tab. Connection for Gmail IMAP has to be SSL enabled. So, select “SSL/TLS on separate port” and make sure the port number is 993.

Mail Notification Gmail IMAP Account Connection Settings

Well thats all you need to do for configuring things for getting new mail notifications lightning fast πŸ™‚ Now sit back and relax until someone sends you a mail πŸ™‚

The only major disadvantage that I found with mail-notification is that it doesn’t stay in notification area all the time. It appears only when there is a new mail.

 

How To: Configure Dual Display with ATI Radeon (fglrx)

As promised in my last post (News: ATI Catalyst Display Drivers 9.9 Released), I am back with a post on configuring dual display with ATI Radeon HD Graphics Card and proprietary catalyst (fglrx) drivers from ATI.

Hardware Used

Graphics Card: ATI Radeon HD 3200 (256MB, onboard)
Monitor 0: ViewSonic VG1930WM 1440×900 (19″ LCD, Connected via DVI port)
Monitor 1: Samsung SyncMaster 793S 1280×1024 (17″ CRT, Connected via VGA port)

Types of Dual Display

  • Mirror: Both screens have same content, identical refresh rate and resolution.
  • Clone: Both screens have same content but refresh rates and resolutions can be different.
  • Horizontal: Both screens can have different content, refresh rates and resolution. Screen 1 is left or right of Screen2.
  • Vertical: Same as horizontal. The only difference is that Screen1 is above or below Screen2.

In this post, we are interested in Horizontal setup with xinerama on. This way we can have two desktops allowing full screen modes on both of them and allowing us to drag and drop windows from one screen to the other.

Install ATI Drivers

If you don’t have ATI drivers installed already, follow this How To: Install ATI Catalyst (fglrx) Drivers on Fedora 11 (works for any version of ATI Catalyst drivers).

Generate xorg.conf file

If you don’t see the xorg.conf file at /etc/X11/xorg.conf, then you need to generate it to proceed to next step. Use the following command as root to generate one

[root@fedora ~]$ Xorg -configure

This command will generate the default xorg.conf file at /root/xorg.conf.new. Copy it to /etc/X11/xorg.conf.

[root@fedora ~]$ cp /root/xorg.conf.new /etc/X11/xorg.conf

Backup xorg.conf file

Backup your original xorg.conf file so that you can restore it in case the configuration doesn’t work the way you expected.

[root@fedora ~]$ cp /etc/X11/xorg.conf /etc/X11/xorg.conf.backup

Generate Configuration for Dual Display

Now we are ready to generate the configuration for dual display. Use the following command with appropriate arguments (in accordance with your hardware configuration)

# --screen-layout will place second screen on left of your first screen. Other possible values are right,above,below.
# --xinerama=on option enables you to have two different desktops and one of them being passive.
# You can drag and drop windows from one desktop to the other. Task bars appear only on one of the desktops.
[root@fedora ~]$ aticonfig --initial=dual-head --screen-layout=left --xinerama=on
# --resolution=_screen_number_,widthxheight
[root@fedora ~]$ aticonfig --resolution=0,1440x900 --resolution=1,1280x1024
# Set horizontal sync and vertical refresh rates for both monitors.
[root@fedora ~]$ aticonfig --hsync=0,30-60 --hsync=1,30-60 --vrefresh=0,30-60 --vrefresh=1,30-60

You can download my xorg.conf file via this link.

Reboot or Logout and Login Again

If you just setup your ATI drivers and configured the dual display, you need to reboot so that fglrx module can be loaded properly. If you rebooted after setting up the drivers, just logout and login again to checkout your dual display πŸ™‚ If everything works fine, say thanks to me and if not blame ATI πŸ˜›

Adjust DPI for Normal Font Size

I faced a problem with my font sizes being too big while using xinerama. It was easy to fix by adjusting DPI. Go to System -> Preferences -> Appearance. Go to Fonts tab. Click Details located near the bottom right corner. On that window, try descreasing the “Dots Per Inch” value. Mine worked fine with 85 DPI.

Below is an image of my dual display setup. Click to enlarge.

Dual Display Configuration ViewSonic Samsung Using ATI Radeon Catalyst (fglrx)

 

How To: GNOME GMail Notifier

GNOME GMail (Google GMail) Notifier is an awesome tool for GNOME/Linux users if you are addicted to checking mails every few minutes. GMail Notifier solves a bit of your problems by notifying about multiple gmail accounts. One more plus point is that it can display GMail Notifications for new mails in accounts for which you are using Google Apps. Below is a step by step howto on installing and configuring GMail Notifier in Fedora (may apply to other distros as well).

Install GNOME GMail Notifier

You can download and install it from GNOME GMail notifier home page or just use yum

[root@fedora ~]$ yum install gnome-gmail-notifier

Launch Gmail Notifier

If installation was successful, go to Applications -> Internet -> Gmail Notifier.

GNOME Gmail Notifier

Open Preferences

Right click on Email icon in taskbar and click Preferences.

GNOME Gmail Notifier Select Prefreneces

Select Preferences

Set inbox update time to 1 minute. Check display notifications for new messages and errors. Also select a sound to play for new mails.

GNOME Gmail Notifier Prefreneces

Add GMail Account

Click Add on preferences window and add your GMail account.

GNOME Gmail Notifier Add GMail Account

Add Mail Account (Google Apps) (Optional)

If you don’t know what Google Apps is, leave this step. If you do know, then add your mail account.

GNOME Gmail Notifier Add Google Apps Account

Check Mail

If you can’t wait for 1 minutes to see GMail Notifier in action, just right click on email icon in taskbar and click Check Mail.

GNOME Gmail Notifier Check New Mails

Mail Notifications

Whenever you get a new mail, you’ll have bubble like the one in image below and a sound will also be played.

GNOME Gmail Notifier New Mail Notification

Enjoy the notifications πŸ™‚

 

How To: Install and Use Twython (Python Wrapper for Twitter API)

As promised in my previous post, here is a brief howto on getting started with twython. The main advantage of Twython over several other python (or any other language) wrappers for Twitter API is that it works even when you are behind your organizations proxy.

Download Twython

You can download latest version of twython from twython page on github. You can either clone using git (if you have git installed) or can click the download button.

Install Twython

Once you are done with extracting the downloaded tar file. Change directory to twython and run these command as root.

1
2
3
4
5
6
[root@fedora ~]$ git clone git://github.com/ryanmcgrath/twython.git
[root@fedora ~]$ cd twython/dist
[root@fedora dist]$ tar -xvzf twython-0.8.tar.gz
[root@fedora dist]$ cd twython-0.8/
[root@fedora dist]$ python setup.py build
[root@fedora dist]$ python setup.py install

Use Twython from Python Interpreter

Below is a direct copy paste lines from my interpreter. See how things are working (learning by doing).

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
[saini@bordeaux ~]$ python
Python 2.6 (r26:66714, Mar 17 2009, 11:44:21) 
[GCC 4.4.0 20090313 (Red Hat 4.4.0-0.26)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> # first of all, import twython module
>>> import twython
>>> # Authenticate your twitter account with your twitter username
... # and password with twitter.setup method.
>>> client = twython.setup('Basic','myusername','mypassword')
>>> client.authenticated
True
>>> #Lets update our current status on twitter with some cool message.
>>> client.updateStatus('Testing #twython. The coolest #TwitterAPI :)')
>>> # Now go and check your current status on twitter. Surprised!!!
>>> # Get your or anyone's followers
>>> client.getFollowersIDs(screen_name='gofedora')
>>> # Output truncated.
>>> # Get help for any function.
>>> print client.createFriendship.__doc__
createFriendship(id = None, user_id = None, screen_name = None, follow = "false")
 
	Allows the authenticating users to follow the user specified in the ID parameter.
	Returns the befriended user in the requested format when successful. Returns a
	string describing the failure condition when unsuccessful. If you are already
	friends with the user an HTTP 403 will be returned.
 
	Parameters:
		** Note: One of the following is required. (id, user_id, screen_name)
		id - Required. The ID or screen name of the user to befriend.
		user_id - Required. Specfies the ID of the user to befriend. Helpful for disambiguating when a valid user ID is also a valid screen name. 
		screen_name - Required. Specfies the screen name of the user to befriend. Helpful for disambiguating when a valid screen name is also a user ID. 
		follow - Optional. Enable notifications for the target user in addition to becoming friends. 
>>>

So now you are ready to do wonders with twython. Write your own code and blog/brag about it πŸ™‚