Wednesday, 1 July 2009

htaccess redirect for SSL non-www to www

Use the following code in the htaccess file under the public_html folder for the concerned domain :
RewriteEngine On
RewriteCond %{HTTP_HOST} ^domain.com [NC]
RewriteRule ^(.*)$ https://www.domain.com/$1 [L,R=301]

Tuesday, 30 June 2009

How to install Flash Player 10 Under Ubuntu Linux 32 bit Edition

Adobe flash player version 10 (code-named "Astro") has been released and available for download. It has many new features such as:
+ Visual performance improvements
+ 3D effects
+ Custom Filters and Effects
+ Advanced Text Layout
+ Enhanced Drawing API
+ Performance improvements and much more.


You must uninstall any currently installed Flash Player before installing the beta under Linux or Mac / Windows computer. Open Firefox and type following at url box:


about:plugins


( Flash Player 9 installed)




Install Ubuntu flash 10 Player


Visit this url and grab .deb file. Uninstall old flashplayer 9 ( if installed ):
$ sudo apt-get remove flashplugin-nonfreeNow, install Flash 10 (make sure Firefox is not running):
$ sudo dpkg -i install_flash_player_10_linux.deb


Start firefox and type about:plugins. You should see list of plugins including Flash 10.


T2 :  Install Flash Player 10 Final in your home directory


If you need to install flash plugin in your home directory, type the following commands. To uninstall type the command:
$ cd ~/.mozilla
$ rm flashplayer.xpt libflashplayer.so


Visit adobe website to grab flash player 10 tar.gz (tar ball). Download and install flash player 10 (please exit any browsers you may have running):
$ cd /tmp
$ wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
$ tar -zxvf install_flash_player_10_linux.tar.gz
$ cd install_flash_player_10_linux
$ ./flashplayer-installer


Sample output:



Copyright(C) 2002-2006 Adobe Macromedia Software LLC.  All rights reserved.

Adobe Flash Player 10 for Linux

Adobe Flash Player 10 will be installed on this machine.

You are running the Adobe Flash Player installer as a non-root user.
Adobe Flash Player 10 will be installed in your home directory.

Support is available at http://www.adobe.com/support/flashplayer/

To install Adobe Flash Player 10 now, press ENTER.

To cancel the installation at any time, press Control-C.

NOTE: Please exit any browsers you may have running.

Press ENTER to continue...

----------- Install Action Summary -----------

Adobe Flash Player 10 will be installed in the following directory:

Mozilla installation directory = /home/vivek/.mozilla

Proceed with the installation? (y/n/q): y

NOTE: Please ask your administrator to remove the xpti.dat from the
components directory of the Mozilla or Netscape browser.

Installation complete.

Perform another installation? (y/n): n

Please log out of this session and log in for the changes to take effect.

The Adobe Flash Player installation is complete.

Now open Firefox and type about:plugins:




You can now view any flash based site.

How to install Flash Player 10 Under Ubuntu Linux 32 bit Edition

Adobe flash player version 10 (code-named "Astro") has been released and available for download. It has many new features such as:
+ Visual performance improvements
+ 3D effects
+ Custom Filters and Effects
+ Advanced Text Layout
+ Enhanced Drawing API
+ Performance improvements and much more.


You must uninstall any currently installed Flash Player before installing the beta under Linux or Mac / Windows computer. Open Firefox and type following at url box:


about:plugins


( Flash Player 9 installed)




Install Ubuntu flash 10 Player


Visit this url and grab .deb file. Uninstall old flashplayer 9 ( if installed ):
$ sudo apt-get remove flashplugin-nonfreeNow, install Flash 10 (make sure Firefox is not running):
$ sudo dpkg -i install_flash_player_10_linux.deb


Start firefox and type about:plugins. You should see list of plugins including Flash 10.


T2 :  Install Flash Player 10 Final in your home directory


If you need to install flash plugin in your home directory, type the following commands. To uninstall type the command:
$ cd ~/.mozilla
$ rm flashplayer.xpt libflashplayer.so


Visit adobe website to grab flash player 10 tar.gz (tar ball). Download and install flash player 10 (please exit any browsers you may have running):
$ cd /tmp
$ wget http://fpdownload.macromedia.com/get/flashplayer/current/install_flash_player_10_linux.tar.gz
$ tar -zxvf install_flash_player_10_linux.tar.gz
$ cd install_flash_player_10_linux
$ ./flashplayer-installer


Sample output:



Copyright(C) 2002-2006 Adobe Macromedia Software LLC.  All rights reserved.

Adobe Flash Player 10 for Linux

Adobe Flash Player 10 will be installed on this machine.

You are running the Adobe Flash Player installer as a non-root user.
Adobe Flash Player 10 will be installed in your home directory.

Support is available at http://www.adobe.com/support/flashplayer/

To install Adobe Flash Player 10 now, press ENTER.

To cancel the installation at any time, press Control-C.

NOTE: Please exit any browsers you may have running.

Press ENTER to continue...

----------- Install Action Summary -----------

Adobe Flash Player 10 will be installed in the following directory:

Mozilla installation directory = /home/vivek/.mozilla

Proceed with the installation? (y/n/q): y

NOTE: Please ask your administrator to remove the xpti.dat from the
components directory of the Mozilla or Netscape browser.

Installation complete.

Perform another installation? (y/n): n

Please log out of this session and log in for the changes to take effect.

The Adobe Flash Player installation is complete.

Now open Firefox and type about:plugins:




You can now view any flash based site.

Saturday, 20 June 2009

How to backup Xen with Logical Volume Mounts ; Works with HyperVM, SolusVM, FluidVM and More

Through our research and implementation of many Xen environments, it has become necessary to develop a reliable and secure method for backing up our Xen instances that are mounted on Logical Volumes (LVM).

The underlying problem is that the logical volume is usually a live file system that cannot be directly mounted / backed up or imaged safely.

We have written a script that processes all running Xen logical volumes, creates a snapshot of the volume and through that snapshot , uses dd to image the snapshot to another server over ssh.

You would be surprised at how well these dd images compress. Piping dd to bzip2 then to ssh to receive the image produces a very substantial compression ratio.

The initial trouble was writing the logic in the script to properly go through each Xen LV , create the snapshot, image and then remove the snapshot. Obviously extensive testing had to be completed to ensure reliability and proper error reporting.

This script should work with any 3rd party Xen control panel implementation (HyperVM, FluidVM, SolusVM to name a few). They all use the same underlying technology / framework. Since our script is a simple bash / shell script, it will run on any linux based system with little modification.

If you are using a LV for another purpose on the same box, it is probably a good idea to modify the script to ignore that so it doesn’t inadvertently get backed up.

Before implementing the script, it is probably a good idea to go through the motions manually just to see how it performs :
lvcreate -s -L 5G -n vm101_img_snapshot /dev/vps/vm101_img
dd if=/dev/vps/vm101_img_snapshot | bzip2 | ssh xenbackup@x.x.x.x "dd of=vm101_img.bz2"

One thing that you cant get around is space — you need to leave as much room as the largest Xen image on your logical volume — otherwise the script will fail at the snapshot creation process.

Find the script below. Hopefully it will help make your life easier (as well as being able to sleep at night) :
#!/bin/bash
# XEN Backup script
# Written by Star Dot Hosting

todaysdate=`date "+%Y-%m-%d"`

echo "XEN Backup Log: " $currentmonth > /var/log/backup.log
echo -e "------------------------------------" >> /var/log/backup.log
echo -e "" >> /var/log/backup.log

for obj0 in $(lvs --noheadings --separator ',' -o lv_name,lv_size | grep -v "swap" | awk -F "," '{printf "%sn", $1}');
do

#grab the snapshot size
snapsize=`lvs --noheadings --separator ',' -o lv_name,lv_size | grep -v "swap" | grep $obj0 | awk -F "," '{printf "%s", $2}'`

#create the snapshot
lvcreate -s -L $snapsize -n $obj0_snapshot /dev/xenlvm/$obj0 >> /var/log/backup.log 2>&1

#dd piped to bzip2 to compress the stream before piping it over the network via ssh to the destination box
dd if=/dev/xenlvm/$obj0_snapshot | bzip2 | ssh xenbackup@0.0.0.0 "dd of=/home/xenbackup/xen-backups/$obj0.$todaysdate.bz" >> /var/log/backup.log 2>&1

if [ "$?" -eq 1 ]
then
echo -e "***SCRIPT FAILED, THERE WERE ERRORS***" >> /var/log/backup.log 2>&1
cat /var/log/backup.log | mail -s "XEN Backup Job failed" admin@yourdomain.com
lvremove -f /dev/xenlvm/$obj0_snapshot
exit 1
else
echo -e "Backup of $obj0 Completed Successfully!" >> /var/log/backup.log 2>&1
fi

# remove the snapshot
lvremove -f /dev/xenlvm/$obj0_snapshot

done

cat /var/log/backup.log | mail -s "XEN Backup Job Completed" admin@yourdomain.com

Horde broken or not working correctly on cPanel

Simple, short & sweet post, this should easily fix any problems you’re having

/usr/local/cpanel/bin/update-horde --force

Also, this might be useful to run hourly, I leave this on our servers “just in case”.

(mysqlcheck --auto-repair eximstats ; mysqlcheck --auto-repair horde) >/dev/null 2>/dev/null

Friday, 19 June 2009

How To Transfer CPanel Accounts

To transfer account you should have root access on both servers. Because to transfer account you need every thing to backup for transfer including Cpanel User / Pass (Same), Website, Database, Emails, Users, Stats etc. . The thing i like about CPanel is it will transfer accounts 100%, you will not miss any single think related to your accounts. This method implies on VPS’s and Dedicated Server where you can access WHM (Web Host Manager) or root shell.

Lets consider we have two servers A and B. Server A is the old server with two accounts and Server B is new server to which we will transfer accounts.

Server A = 192.168.0.1
Server B = 172.20.0.1

1 Transfer using WHM
Login to Server B WHM using following url

http://172.20.0.1:2086

where 2086 is the port on which WHM is running.

In the middle page select Transfer and then on Transfer page select Copy multiple accounts/packages from another server.

It will open new page to put info of the Server through which you are going to transfer i.e Server A.

Remote server type is (WHM version will be auto detected on multi account copies): leave as it is
Remote server address (ip address or FQDN): put server hostname or IP
Remote SSH port: 22 is the default, if you have changed ssh port on old server use that one here.
Do not compress transfers (cPanel 10.8.3+ required on both ends): leave at it is
Turn off SSL (cPanel 11.23.6+ required on both ends): leave at it is
Allow override*: leave at it is
Login as : Choose USER if you have sudo or direct root login are not allowed. Else select ROOT (recommended)
Select authentication method: Choose Password here, if you are using Public Key then you have to upload Key using Security -> Manage SSH Keys to use here.
Root Password: put root password here

After putting all information above click on Fetch Account List. In few second you will see list of accounts from Server A to transfer. Select the account using check boxes to copy, if need to copy all select Select All to check all accounts. When done with select click on Copy. (Beware once you click on Copy dont close browser or click on Back button).

You will see account transfer log on your browser and when finished it will show nice summary about transfer.

2 Transfer using Shell (Command Line)
SSH your Server A using putty from windows and command line from linux.

ssh 192.168.0.1

Now first of all we will create full backup to transfer and all the backups created are placed under /home directory.

2.1 Create One Account Backup
If you wish to backup single account, then execute following command

/scripts/pkgacct cpaneluser

you will find corresponding backup in /home directory named cpmove-cpaneluser*.tar.gz

2.2 Create all Accounts Backup
To create all accounts backup on your server, execute following command

cat /var/cpanel/users | while read a; do
/scripts/pkgacct $a
done

again you will find all accounts backup under /home named cpmove-cpaneluser*.tar.gz

2.3 SCP Backups to New Server
After creating backup you have to transfer all accounts backup to your new server i.e Server B using SCP.

scp cpmove-* root@172.120.0.1:/home

Besure all backups should move to /home directory of new server.

If you have done all accounts backup then you should have to move /var/cpanel/users file for restore on new server i.e Server B in /home directory with name user.txt

scp /var/cpanel/users root@172.120.0.1:/home/user.txt

2.4 Restore Backup
To restore single account backup execute following command.

/scripts/restorepkg cpaneluser

where cpaneluser is of old server and can be found on backup filename after cpmove. i.e

cpmove-cpaneluser*.tar.gz

To restore all accounts

cat /home/user.txt | while read a; do
/scripts/restorepkg $a
done

Now you can List Account in WHM to see all accounts are transferred successfully to your new server and you can login to cpanel accounts of user using same Cpanel user / pass as old server.

Sunday, 14 June 2009

How To Install FFmpeg, Mplayer, Mencoder, FFmpeg-PHP on CentOS 5.x

In this how to we'll describe how to install ffmpeg, mplayer, mencoder, flvtool2, ffmpeg-php with all supported codecs to convert / manipulate videos easily on CentOS 5.x. If you want to run sites like youtube e.g www.indianpad.in, www.danceindiadance.in this howto will help you to install the base for your software. There are many other way to perform this but this works for me, so i want to share. --SR

1 Setting Up RPMForge Respository.


RPMForge repository (http://dag.wieers.com) is the biggest rpm respository for RHEL, CentOS for all versions. To enable RPMForge respository run following command to install all necessary files for getting RPMForge repository. The following command directly install rpm from http://da.wieers.com site.
rpm -Uhvhttp://apt.sw.be/redhat/el5/en/i386/rpmforge/RPMS/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

This rpm will add necessary files in our repository configuration and can be viewed at /etc/yum.repos.d/rpmforge.repo

2 Install ffmpeg, mplayer, mencoder with all supported modules.


Now we have rpmforge repository, so we will use yum to install ffmpeg, mplayer, mencoder as well as all dependent software.
yum -y install ffmpeg ffmpeg-devel mplayer mencoder flvtool2

This command will some time to download and install all packages depends on your internet speed.

3 Install FFMPEG-PHP


ffmpeg-php is an extension for PHP that adds an easy to use, object-oriented API for accessing and retrieving information from video and audio files. ffmpeg-devel and php-devel is needed to compile ffmpeg-php from source code. Use following steps to install ffmpeg-php
cd /usr/src
wget http://garr.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.6.0.tbz2
tar jxvf ffmpeg-php-0.6.0.tbz2
cd ffmpeg-php-0.6.0
phpize
./configure
make
make install

It will copy the ffmpeg.so module in php default module location. Now you have to edit php.ini file to enable ffmpeg-php support in it by using ffmpeg.so module.
vi /etc/php.ini

and append following line
extension=ffmpeg.so

Restart apache service to take effect of php.ini
/etc/init.d/httpd restart

Run following command to ffmpeg module listing in php.
php -m | grep ffmpeg

Have a nice streaming. :)