Wednesday 30 September 2009

phpSHIELD

. Download the source.

wget http://www.phpshield.com/loaders/phpshield.loaders.linux.zip

2. Extract it.


unzip phpshield.loaders.linux.zip

3. Find php.ini file.

php -i | grep php.ini



4. Add the following entries in php.ini file and save the file.

extension = “phpshield.5.2.lin”
extension_ts = “phpshield.5.2ts.lin”

5. Restart Apache service.


/etc/init.d/httpd restart



6. Check the module if it is installed.

php -i | grep phpSHIELD


How to install Xen

Xen is a virtual machine monitor that supports execution of multiple guest operating systems with unprecedented levels of performance and resource isolation.

Steps to install Xen on CentOS:

1. Execute the following command to install Xen and Xen kernel

yum install kernel-xen xen

2. Once the installation completes, you can find the new kernel “Xen kernel (vmlinuz-2.6.18-8.1.4.el5xen)” in grub.conf file.





title CentOS (2.6.18-8.1.4.el5xen)root (hd0,0)kernel /xen.gz-2.6.18-8.1.4.el5module /vmlinuz-2.6.18-8.1.4.el5xen ro root=/dev/VolGroup00/LogVol00module /initrd-2.6.18-8.1.4.el5xen.img

3. Change the default value as 0 in the file ‘/etc/grub.conf’

default=0

4. Create a new directory to make a virtual machine “/vm” and reboot the server

5. After the system has booted, the system has the new Xen kernel





# uname -r2.6.18-8.1.4.el5xen

6. To check if Xen has started, execute the command – “xm list”. It should list Domain-0 (dom0):





# xm listName ID Mem(MiB) VCPUs State Time(s)Domain-0 0 350 1 r—– 94.4

7. A tool called “virt-install” with which we can create virtual machines for Xen

virt-install

8. The tools asks a few questions before it creates a virtual machine as follows:





What is the name of your virtual machine? <– vm01How much RAM should be allocated (in megabytes)? <– 256What would you like to use as the disk (path)? <– /vm/vm01.imgHow large would you like the disk (/vm/vm01.img) to be (in gigabytes)? <– 4Would you like to enable graphics support? (yes or no) <– no

What is the install location? <– http://wftp.tu-chemnitz.de/pub/linux/centos/5.0/os/i386

9. virt-install has created the vm01 configuration file /etc/xen/vm01 for us (in dom0). It should look like this:





cat /etc/xen/vm01# Automatically generated xen config filename = “vm01?memory = “256?disk = [ ‘tap:aio:/vm/vm01.img,xvda,w’, ]

vif = [ ‘mac=00:16:3e:13:e4:81, bridge=xenbr0?, ]

uuid = “5aafecf1-dd66-401d-69cc-151c1cb8ac9e”

bootloader=”/usr/bin/pygrub”

vcpus=1

on_reboot = ‘restart’

10. To log in on that virtual machine, type: xm console vm01

That’s it

Some important Xen commands:

1. xm create -c /path/to/config – Start a virtual machine

xm create /etc/xen/vm01

2. xm shutdown – Stop a virtual machine

xm shutdown vm01

3. xm destroy – Stop a virtual machine immediately without shutting it down

xm destroy vm01

4. xm list – List all running systems

5. xm console – Log in on a virtual machine

xm console vm01

7. xm help – List of all commands

http://sarathin.blogspot.com/search?updated-min=2008-01-01T00:00:00%2B05:30&updated-max=2009-01-01T00:00:00%2B05:30&max-results=50

http://www.imagemagick.org/script/convert.php

http://panchathan.wordpress.com/

Example Usage • Option Summary

Use the animate program to animate an image sequence on any X server. See Command Line Processing for advice on how to structure your animate command or see below for example usages of the command.

Example Usage

We list a few examples of the animate command here to illustrate its usefulness and ease of use. To get started, lets animate an image sequence in the GIF format:

$magick> animate movie.gif

To animate a directory of JPEG images, use:

$magick> animate *.jpg

You can find additional examples of using animate in Graphics from the Command Line. Further discussion is available in More Graphics from the Command Line and Examples of ImageMagick Usage.

Option Summary

The animate command recognizes these options. Click on an option to get more details about how that option works.

Option Description

-alpha on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel

-antialias remove pixel-aliasing

-authenticate value decrypt image with this password

-backdrop background color

-background color background color

-border geometry surround image with a border of color

-bordercolor color border color

-channel type apply option to select image channels

-clip clip along the first path from the 8BIM profile

-clip-path id clip along a named path from the 8BIM profile

-coalesce merge a sequence of images

-colormap type Shared or Private

-colors value preferred number of colors in the image

-colorspace type set image colorspace

-comment string annotate image with comment

-compress type image compression type

-contrast enhance or reduce the image contrast

-crop geometry preferred size and location of the cropped image

-debug events animate copious debugging information

-decipher filename convert cipher pixels to plain

-define format:option define one or more image format options

-delay value animate the next image after pausing

-density geometry horizontal and vertical density of the image

-depth value image depth

-despeckle reduce the speckles within an image

-display server get image or font from this X server

-dispose method layer disposal method

-dither method apply error diffusion to image

-edge radius apply a filter to detect edges in the image

-endian type endianness (MSB or LSB) of the image

-enhance apply a digital filter to enhance a noisy image

-extract geometry extract area from image

-filter type use this filter when resizing an image

-flatten flatten a sequence of images

-flip flip image in the vertical direction

-flop flop image in the horizontal direction

-frame geometry surround image with an ornamental border

-gamma value level of gamma correction

-geometry geometry preferred size or location of the image

-gravity geometry horizontal and vertical backdrop placement

-help print program options

-identify identify the format and characteristics of the image

-immutable type prohibit image edits

-interlace type type of image interlacing scheme

-interpolate method pixel color interpolation method

-label name assign a label to an image

-limit type value pixel cache resource limit

-log format format of debugging information

-map filename transform image colors to match this set of colors

-mattecolor color frame color

-monitor monitor progress

-monochrome transform image to black and white

-negate replace every pixel with its complementary color

-page geometry size and location of an image canvas (setting)

-profile filename add, delete, or apply an image profile

-quantize colorspace reduce image colors in this colorspace

-quiet suppress all warning messages

-raise value lighten/darken image edges to create a 3-D effect

-regard-warnings pay attention to warning messages.

-remote command execute a command in an remote animate process

-resample geometry change the resolution of an image

-resize geometry resize the image

-respect-parentheses settings remain in effect until parenthesis boundary.

-roll geometry roll an image vertically or horizontally

-rotate degrees apply Paeth rotation to the image

-sample geometry scale image with pixel sampling

-sampling-factor geometry horizontal and vertical sampling factor

-scene value image scene number

-segment values segment an image

-seed value seed a new sequence of pseudo-random numbers

-set attribute value set an image attribute

-sharpen geometry sharpen the image

-size geometry width and height of image

-strip strip image of all profiles and comments

-transparent-color color transparent color

-trim trim image edges

-update seconds detect when image file is modified and reanimate

-verbose print detailed information about the image

-version print version information

-virtual-pixel method access method for pixels outside the boundaries of the image

-visual animate image using this visual type

-window id animate images to background of this window

-window-group id exit program when this window id is destroyed

Use the animate program to animate an image sequence on any X server. See Command Line Processing for advice on how to structure your animate command or see below for example usages of the command.

Example Usage

We list a few examples of the animate command here to illustrate its usefulness and ease of use. To get started, lets animate an image sequence in the GIF format:

$magick> animate movie.gif

To animate a directory of JPEG images, use:

$magick> animate *.jpg

You can find additional examples of using animate in Graphics from the Command Line. Further discussion is available in More Graphics from the Command Line and Examples of ImageMagick Usage.

Option Summary

The animate command recognizes these options. Click on an option to get more details about how that option works.

Option Description

-alpha on, activate, off, deactivate, set, opaque, copy", transparent, extract, background, or shape the alpha channel

-antialias remove pixel-aliasing

-authenticate value decrypt image with this password

-backdrop background color

-background color background color

-border geometry surround image with a border of color

-bordercolor color border color

-channel type apply option to select image channels

-clip clip along the first path from the 8BIM profile

-clip-path id clip along a named path from the 8BIM profile

-coalesce merge a sequence of images

-colormap type Shared or Private

-colors value preferred number of colors in the image

-colorspace type set image colorspace

-comment string annotate image with comment

-compress type image compression type

-contrast enhance or reduce the image contrast

-crop geometry preferred size and location of the cropped image

-debug events animate copious debugging information

-decipher filename convert cipher pixels to plain

-define format:option define one or more image format options

-delay value animate the next image after pausing

-density geometry horizontal and vertical density of the image

-depth value image depth

-despeckle reduce the speckles within an image

-display server get image or font from this X server

-dispose method layer disposal method

-dither method apply error diffusion to image

-edge radius apply a filter to detect edges in the image

-endian type endianness (MSB or LSB) of the image

-enhance apply a digital filter to enhance a noisy image

-extract geometry extract area from image

-filter type use this filter when resizing an image

-flatten flatten a sequence of images

-flip flip image in the vertical direction

-flop flop image in the horizontal direction

-frame geometry surround image with an ornamental border

-gamma value level of gamma correction

-geometry geometry preferred size or location of the image

-gravity geometry horizontal and vertical backdrop placement

-help print program options

-identify identify the format and characteristics of the image

-immutable type prohibit image edits

-interlace type type of image interlacing scheme

-interpolate method pixel color interpolation method

-label name assign a label to an image

-limit type value pixel cache resource limit

-log format format of debugging information

-map filename transform image colors to match this set of colors

-mattecolor color frame color

-monitor monitor progress

-monochrome transform image to black and white

-negate replace every pixel with its complementary color

-page geometry size and location of an image canvas (setting)

-profile filename add, delete, or apply an image profile

-quantize colorspace reduce image colors in this colorspace

-quiet suppress all warning messages

-raise value lighten/darken image edges to create a 3-D effect

-regard-warnings pay attention to warning messages.

-remote command execute a command in an remote animate process

-resample geometry change the resolution of an image

-resize geometry resize the image

-respect-parentheses settings remain in effect until parenthesis boundary.

-roll geometry roll an image vertically or horizontally

-rotate degrees apply Paeth rotation to the image

-sample geometry scale image with pixel sampling

-sampling-factor geometry horizontal and vertical sampling factor

-scene value image scene number

-segment values segment an image

-seed value seed a new sequence of pseudo-random numbers

-set attribute value set an image attribute

-sharpen geometry sharpen the image

-size geometry width and height of image

-strip strip image of all profiles and comments

-transparent-color color transparent color

-trim trim image edges

-update seconds detect when image file is modified and reanimate

-verbose print detailed information about the image

-version print version information

-virtual-pixel method access method for pixels outside the boundaries of the image

-visual animate image using this visual type

-window id animate images to background of this window

-window-group id exit program when this window id is destroyed

Monday 28 September 2009

Command-line Tools

ImageMagick includes a number of command-line utilities for manipulating images. Most of you are probably accustomed to editing images one at a time with a graphical user interface (GUI) with such programs as gimp or Photoshop. However, a GUI is not always convenient. Suppose you want to process an image dynamically from a web script or you want to apply the same operations to many images or repeat a specific operation at different times to the same or different image. For these types of operations, the command-line image processing utility is appropriate.


The ImageMagick command-line tools exit with a status of 0 if the command line arguments have a proper syntax and no problems are encountered. Expect a descriptive message and an exit status of 1 if any exception occurs such as improper syntax, a problem reading or writing an image, or any other problem that prevents the command from completing successfully.


In the paragraphs below, find a short description for each command-line tool. Click on the program name to get details about the program usage and a list of command-line options that alters how the program behaves. If you are just getting acquainted with ImageMagick, start with the convert program. Be sure to peruse Anthony Thyssen's tutorial on how to use ImageMagick utilities to convert, compose, or edit images from the command-line.



animate


animate an image sequence on any X server.

compare


mathematically and visually annotate the difference between an image and its reconstruction

composite


overlap one image over another.

conjure


interpret and execute scripts written in the Magick Scripting Language (MSL).

convert


convert between image formats as well as resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more.

display


display an image or image sequence on any X server.

identify


describe the format and characteristics of one or more image files.

import


save any visible window on an X server and outputs it as an image file. You can capture a single window, the entire screen, or any rectangular portion of the screen.

mogrify


resize an image, blur, crop, despeckle, dither, draw on, flip, join, re-sample, and much more. Mogrify overwrites the original image file, whereas, convert writes to a different image file.

montage


create a composite image by combining several separate images. The images are tiled on the composite image optionally adorned with a border, frame, image name, and more.

stream


a lightweight tool to stream one or more pixel components of the image or portion of the image to your choice of storage formats. It writes the pixel components as they are read from the input image a row at a time making stream desirable when working with large images or when you require raw pixel components.

Thursday 24 September 2009

Installation of PHPmotion V2


System Requirements




[ALL versions of phpmotion]

In order to run PHPmotion you will need either to have a dedicated/vps server with the required modules installed OR a web hosting provider that has these features.

Servers - Linux/Unix

Required Modules


  • PHP 4.3 and above (including support of CLI)




  • MySQL database server




  • LAME MP3 Encoder




  • Libogg + Libvorbis




  • Mencoder and also Mplayer




  • FFMpeg-PHP




  • GD Library 2 or higher




  • CGI-BIN




  • Be able to run background processes


PHP Settings


  • open_basedir = (no value)




  • upload_max_filesize = 100M




  • post_max_size = 100M




  • max_execution_time = 1500




  • session.gc_maxlifetime = 14000




  • safe_mode = off




  • Thread saftery = disabled




  • enable_dl = On


PHPMotion does offer a server set up service http://phpmotion.com/content/view/12/30/

Installing PHPmotion V2




The following instructions only apply to Version 2 of PHPmotion. For V1 please refer to the instructions provided inside the downloaded zip file


  1. Determin what versin of PHP is running on your server. There are 2 ways to do this




  2. Download the appropriate version of phpmotion for your server (From our forum). We provide a version for both PHP4 and PHP5 servers


  3. Unzip the files on your computer


  4. Using your web hosting control panel or similar, create a mysql database and write down the details of the database once created


  5. Upload all the phpmotion files into your FTP folder


  6. CHMOD all the following files and directories to 777



    • /setup


    • /pictures


    • /classes


    • /temp



      • /logs




    • /addons


    • /uploads


    • /uploads/avi


    • /uploads/thumbs


    • /uploads/audio


    • /uploads/audio/temp


    • /uploads/pictures




  7. CHMOD all the following files and directories to 755



    • /cgi-bin/all files in there


    • /cgi-bin/audio/all files in there




  8. Start the installation wizard by going to http://YOUDOMAIN.COM/setup (replace with your real domain name)



IMPORTANT NOTES





  1. The following files MUST be uploaded in BINARY mode. Your FTP program will have an option for this



    • /classes/config.php


    • /watchingnow.php


    • /mp3_id3_utils.php





Installing PHPmotion V2 to a Sub-Folder




If you are installing to a subfolder (example http://www.yourdomain.com/myvideos/)


  1. Follow ALL the standard setup instructions above


  2. The following files will need to be edited using a plain text editor like notepad



    • /cgi-bin/uu_default_config.pm


    • /cgi-bin/audio/uu_default_config.pm


    • uploader_conlib.php


    • audio_uploader_conlib.php






  1. /cgi-bin/uu_default_config.pm and /cgi-bin/audio/uu_default_config.pm


open each file and locate the section with:
config_file_name         => 'uu_default_config',
temp_dir => $ENV{'DOCUMENT_ROOT'} . '/temp/',
upload_dir => $ENV{'DOCUMENT_ROOT'} . '/uploads/avi/',
redirect_url => '/uploader_finished.php',
path_to_upload => '/uploads/avi/',

Change it to:
config_file_name         => 'uu_default_config',
temp_dir => $ENV{'DOCUMENT_ROOT'} . '/myvideos/temp/',
upload_dir => $ENV{'DOCUMENT_ROOT'} . '/myvideos/uploads/avi/',
redirect_url => '/myvideos/uploader_finished.php',
path_to_upload => '/myvideos/uploads/avi/',



  1. uploader_conlib.php and audio_uploader_conlib.php


open each file and locate the section with:
     $path_to_upload_script      = '/cgi-bin/uu_upload.pl';
$path_to_ini_status_script = '/cgi-bin/uu_ini_status.pl';

Change it to:
     $path_to_upload_script      = '/myvideos/cgi-bin/uu_upload.pl';
$path_to_ini_status_script = '/myvideos/cgi-bin/uu_ini_status.pl';

PROBLEMS AND DEBUGGING
VIDEO AND SOUND PROBLEMS

If you are having the following problems

1. Videos not showing
2. No sound
3. Missing thumbnail pictures
4. Any other video related problem

Debugging (recommended option)

- Open the file classes/config_inc.php

- Set the $log_encoder variable to yes.

- This will create a log file each time you upload a new video

- The log file will be located in the logs folder

Example : $log_encoder = "yes";



E mail issues

cd /home/username/mail/domain name -Here all mail accounts will be present.

cd 'mail account'

mail -v mailid . -To send mail through the shell

^To move frozen messages

exim -bprc | grep frozen | awk {'print $3'} | xargs exim -Mrm

^To get count of the mail

exim -bpc
pgrep exim | wc -l

^To get error logs
tail -f /usr/local/apache/logs/error_logs

^Print what Exim is doing right now:

root@localhost# exiwhat

^Test how exim will route a given address:

root@localhost# exim -bt alias@localdomain.com
user@thishost.com
<-- alias@localdomain.com   router = localuser, transport = local_delivery

root@localhost# exim -bt user@thishost.com

user@thishost.com

router = localuser, transport = local_delivery root@localhost# exim -bt user@remotehost.com   router = lookuphost, transport = remote_smtp   host mail.remotehost.com [1.2.3.4] MX=0

root@localhost# exim -bt user@remotehost.com
router = lookuphost, transport = remote_smtp
host mail.remotehost.com [1.2.3.4] MX=0

^Freeze a message:

root@localhost# exim -Mf [ ... ]

^Thaw a message:

root@localhost# exim -Mt [ ... ]

^Deliver a message:

root@localhost# exim -M [ ... ]

^Force a message to fail and bounce as "cancelled by administrator":

root@localhost# exim -Mg [ ... ]

^Remove all frozen messages:

root@localhost# exiqgrep -z -i | xargs exim -Mrm

^Remove all messages older than five days (86400 * 5 = 432000 seconds):

root@localhost# exiqgrep -o 432000 -i | xargs exim -Mrm

^Freeze all queued mail from a given sender:

root@localhost# exiqgrep -i -f luser@example.tld | xargs exim -Mf

^View a message's headers:

root@localhost# exim -Mvh

^View a message's body:

root@localhost# exim -Mvb

^View a message's logs:

root@localhost# exim -Mvl

^Add a recipient to a message:

root@localhost# exim -Mar

[
... ]

Edit the sender of a message:

root@localhost# exim -Mes

How to unblock Ip in Comcast, hotmail, yahoo

COMCAST

http://www.comcastsupport.com/Forms/NET/blockedprovider.asp

YAHOO
http://help.yahoo.com/l/us/yahoo/mail/postmaster/unblock.html

HOTMAIL

check

exim -bt If you receive "mx1.hotmail.com" like intication try: telnet mx1.hotmail.com 25 If this does not work IP is blocked in hotmail You need to add SPF record for specific domain if you face any issues with hotmail Go to WHM and add SPF record.

Mysql Issues

/var/lib/mysql --> mysql engine operates

To enter into database

mysql -u user -h ip -p 'password' database name

To grant privileges

grant all privileges on database.* to user@localhost identified by 'password';

Backup of Mysql

mysqldump 'database name' > mysql.sql
mysqldump -u 'username' --database 'db_name' > database.sql -p

To restore dump file

mysql 'database name' < mysql.sql
mysql -u 'username' --database 'db_name' < database.sql -p

To repair Mysql

/var/lib/mysql/database myisamcheck -r -s *.MYI

To check the mysql error logs

tail -f /var/lib/mysql/`hostname`.err

PHPsuexec: Fix permissions for “Internal Server Error”

Run the following commands from the user’s public_html directory:
(MAKE SURE YOU’RE IN THE PUBLIC_HTML DIRECTORY)

find -type d -exec chmod 755 ‘{}’ ;
find -type f -exec chmod 644 ‘{}’ ;
find -iname “*.pl” -exec chmod 755 ‘{}’ ; -o -iname “*.cgi” -exec chmod 755 ‘{}’ ;
chown `pwd|cut -d/ -f3`.`pwd|cut -d/ -f3` -R .

How to Install mod_evasive

Mod_Evasive will help to stop basic attacks on a server (HTTP, DDoS attack and brute force attack). Detection is performed by creating an internal dynamic hash table of IP Addresses and URIs, and denying any single IP address from any of the following:

-Requesting the same page more than a few times per second

-Making more than 50 concurrent requests on the same child per second

-Making any requests while temporarily blacklisted (on a blocking list)

Login to your server, on command line:

/usr/local/src
wget http://www.nuclearelephant.com/projects/mod_evasive/mod_evasive_1.10.1.tar.gz

tar -zxvf mod_evasive_1.10.1.tar.gz
cd mod_evasive

If you are using apache 1.3.x :
/usr/local/apache/bin/apxs -cia mod_evasive.c

And add this to httpd.conf:
Code:
DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600

If you are using apache 2.0.x :
/usr/sbin/apxs -cia mod_evasive20.c

Add this to httpd.conf:
Code:
DOSHashTableSize 3097
DOSPageCount 6
DOSSiteCount 100
DOSPageInterval 2
DOSSiteInterval 2
DOSBlockingPeriod 600

Restart apache and the installation should be complete.

/etc/init.d/httpd restart

Setting Register Globals per Domain on Apache

1) vi /etc/httpd/conf/httpd.conf
2)Use the below line under the virtual host of the respective domain
php_admin_flag register_globals on

For those who don't have access to their apache config files,

1)you can create a .htaccess file and place it in your home directory on the server.

php_admin_flag register_globals on

Accessing a Windows Partition from Linux

You can access another partition on your system (for example, a Windows partition), in two different ways.

You should first determine where your Windows partition is located by determining what physical hard disk your Windows partition is located in (such as the primary master IDE drive or the the first SCSI drive). To find this information, you can use the Hardware Browser, which lists detailed information about the hardware in your Red Hat Linux system.

To start the Hardware Browser, choose Main Menu => System Tools => Hardware Browser. Figure 16-1 shows Hardware Browser in action.

Select Hard Drives from the panel and find your Windows partition from the Disk Information displayed. Windows partitions normally use the FAT or FAT32 file system type. This file system type can be mounted and read within Linux; however, if your Windows partition uses NTFS, then you cannot mount and read from it as Red Hat Linux does not support NTFS file systems. Note the Device information for your Windows partition, as this is the device that you mount to access your Windows data.

Once you have determined where your Windows partition is located on your hard drive, log in as root (type su and then enter the root password) at a shell prompt.

Create a directory in which the Windows partition will be mounted by typing the following command. For example:

mkdir /mnt/windows

Before you can access the partition, you will need to mount it in the directory you just created. As root, type the following command at a shell prompt (where /dev/hda1 is the Windows partition you found via Hardware Browser):

mount -t vfat /dev/hda1 /mnt/windows

You may then logout of root user mode and access your Windows data by changing into the mounted Windows partition:

cd /mnt/windows

To automatically mount a Windows partition every time you boot your Red Hat Linux system, you must modify the /etc/fstab file, which configures all file systems and disk device mounting options.

At a shell prompt, su to root, following the above example.

Next, open the /etc/fstab in a text editor by typing (for example):

gedit /etc/fstab

Add the following on a new line (replacing /dev/hda1 with the Windows partition you found via Hardware Browser):

/dev/hda1 /mnt/windows vfat auto,umask=0 0 0

If partton is ntfs

mount -t ntfs -onls=utf8,umask=0222 /dev/hda1 /media/windows

Save the file and exit your text editor.

The next time the system is rebooted, the /etc/fstab file is read, and the Windows partition is automatically mounted in the directory /mnt/windows. To access the partition at a shell prompt, type the command cd /mnt/windows. To navigate through directories or files with spaces, surround the name of the directory or file with quotation marks, as in ls "Program Files".

SCP command

Copying files from our machine to another machine scp
Example:
[root@washington]# scp /home/samba/temp.tar.gz 192.168.0.118:/home/
scp -rP 4242 directory/ user@IP:/home/(if port and user is there)

Copying files from another machine to our machine scp
[root@washington ]#scp 192.168.0.118:/home/temp.tar.gz /root

How to set mail quota in Helm

Login to the teminal.

Select 'Mail enable enterprise'.

Select mail enable management > Messaging manager > Post Offices

Select the 'domain'

Select 'Mail Boxes'

Select the email account.

Click on the properties

Change the quota which is under tab 'general'.

How to block a particular email in IMAIL

The "Block Senders" option allows iMail users to block addresses from which they don't want to receive mail. Incoming mail from addresses on the list will be deleted automatically.
To add address to the blocking list, just
->Enter your iMail Personal Settings
->Select the Block Senders option, and
->Enter the full email address in "user@domain.com" format
Please note the followings when using the "Block Senders" option:
->You can put up to 50 email addresses.
->Messages from those senders will be deleted automatically.
->It applies to messages being delivered to the INBOX only.
(The "Block Senders" option is particular useful for iMail users who are using PC-Pine or users who will access to their mailboxes from different machines (no need to set Message Filters on those machines again).
Also check this link which will be more useful
http://skc.smyrna.k12.de.us/users/cbush/block.htm

How to install Rkhunter

Installing:
wget http://jaist.dl.sourceforge.net/sourceforge/rkhunter/rkhunter-1.2.9.tar.gz
tar -zxvf rkhunter-1.2.9.tar.gz
cd rkhunter-1.2.9
./installer.sh
Now you can run a test scan with the following command:
/usr/local/bin/rkhunter -c
How to setup a daily scan report?
vi /etc/cron.daily/rkhunter.sh
add the following replacing your email address:
#!/bin/bash
cd /usr/local/bin/./rkhunter -c --cronjob 2>&1 mail -s "Daily Rkhunter Scan Report"email@domain.com
chmod +x /etc/cron.daily/rkhunter.sh
Updating rkhunter

gets the latest database updates from their central server and matches your OS better to prevent false positives.
rkhunter --update

I just got a false positive!! What do i do?
False positives are warnings which indicates there is a problem, but aren't really a problem. Example: some Linux distro updated a few common used binaries like `ls` and `ps`. You (as a good sysadmin) update the new packages and run (ofcourse) daily Rootkit Hunter. Rootkit Hunter isn't yet aware of these new files and while scanning it resports some "bad" files. In this case we have a false positive. You could always have your datacenter or a system administrator check out the server to verify that it is not compromised.
More information on rkhunter can be found here: http://www.rootkit.nl

How to add SPF record from WHM

Please refer to this to understand what is SPF: http://openspf.org

Once you know what SPF record you need to enter into your dns zone, please login to WHM. Go to DNS Functions, Edit DNS Zone. Select the zone to edit, and click the Edit button.

Now you are editing the dns zone. On this page, when adding spf record for the first time, add the new record below the line which says:

Add New Entries Below this Line

The first text field will contain your domain name with a terminating dot i.e. example.com.

Leave the number as it is in next field. After IN, select TXT from the drop down. In the next text field, add the SPF record with quotation marks e.g.

"v=spf1 a ~all"

Click Save button and allow a couple of hours for dns propagation.

How to add a spanish or other language domain in WHM

Go to http://punycode.bluerider.com/idn/
Gave the domain name in the space 'Punycode or Unicode Text '
After that you will get a punnytexy.
Place this text in WHM and add.
But after this, in the browser the domain name will redirect to the new text.

How to Change the Timezone in Linux

Steps



  1. For ubuntu: [1]http://webonrails.com/2009/07/15/change-timezone-of-ubuntu-machine-from-command-line/



  1. Logged in as root, check which timezone your machine is currently using by executing `date`. You'll see something like Mon 17 Jan 2005 12:15:08 PM PST, PST in this case is the current timezone.

  2. Change to the directory /usr/share/zoneinfo here you will find a list of time zone regions. Choose the most appropriate region, if you live in Canada or the US this directory is the "America" directory.

  3. If you wish, backup the previous timezone configuration by copying it to a different location. Such as
    mv /etc/localtime  /etc/localtime-old


  4. Create a symbolic link from the appropiate timezone to /etc/localtime. Example:
    ln -sf /usr/share/zoneinfo/Europe/Amsterdam /etc/localtime


  5. If you have the utility rdate, update the current system time by executing
    /usr/bin/rdate -s time-a.nist.gov


  6. Set the ZONE entry in the file /etc/sysconfig/clock file (e.g. "America/Los_Angeles")

  7. Set the hardware clock by executing:
    /sbin/hwclock --systohc


To change the Time Zone for a particular user

Open your .htaccess file and add the following line.
SetEnv TZ
Eg: SetEnv TZ Europe/London.

IPv6 Conference 2008 and DNS

[youtube http://www.youtube.com/watch?v=8iIngiGqjrA&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1]

MySQL client error

Error:


Client does not support authentication protocol requested by server; consider upgrading MySQL client


Fix:


Execute the following commands in MySQL prompt.


UPDATE mysql.user SET Password = OLD_PASSWORD(’new password’) WHERE host = ‘localhost’ AND User = ‘root’;


FLUSH PRIVILEGES;

MySQL password reset in Windows

1. Stop the MySQL service

2. Go to the MySQL installation folder

3. Find the file my.ini

4. Add the line “skip-grant-tables = 1? in my.ini

5. Start MySQL service

6. Now, in command prompt, go to the MySQL bin folder, type ‘mysql’

7. Execute the following command

UPDATE user SET Password=PASSWORD(’YOUR_PASSWORD’) WHERE Host=’localhost’ AND User=’root’;

8. Remove the line “skip-grant-tables = 1? from my.ini

9. Restart MySQL service

Install PECL uploadprogress Extension

1. Go to the directory /usr/local/src.

cd /usr/local/src

2. Download PECL uploadprogress extension.

wget http://pecl.php.net/get/uploadprogress-1.0.1.tgz

3. Extract the package.

tar zxvf uploadprogress-1.0.1.tgz

4. Go to the directory ‘uploadprogress-1.0.1?

cd uploadprogress-1.0.1

5. Execute the following commands.

phpize
./configure
make
make install

6. Add the extension ‘uploadprogress.so’ in PHP configuration file.

Note: You can find php.ini file using the command “php -i | grep php.ini”.

echo “extension=uploadprogress.so” >> /usr/local/lib/php.ini

7. Restart Apache service.

service httpd restart

8. Verify the installation using the command “php -m | grep -i upload”.

Basics in FreeBSD

In this PDF, I tried to explain the basic things in freebsd and its file system structure. I hope, it will help you to learn about FreeBSD.

Send a comment if you have any doubts

MySQL installation in FreeBSD

Here is the steps to install MySQL in FreeBSD servers.

1. cd /usr/ports/databases/mysql*-server/

Note: * indicates that you can select the MySQL version as your wish.

2. make install clean

3. /usr/local/bin/mysql_install_db

4. chown -R mysql /var/db/mysql/

5. chgrp -R mysql /var/db/mysql/

6. /usr/local/bin/mysqld_safe –user=mysql &

7. /usr/local/bin/mysqladmin -u root password newpassword

8. Open the file /etc/rc.conf and add the following line


mysql_enable=”YES”

Prevent DDoS attack

Sometimes you can see the following errors in the log file (/var/log/messages) in FreeBSD servers.

Limiting open port RST response from 295 to 200 packets/sec
Limiting open port RST response from 260 to 200 packets/sec

This is the symptom of DDoS attack on the server. We can avoid this by executing the following commands.

sysctl net.inet.udp.blackhole=1
sysctl net.inet.tcp.blackhole=2

This will prevent the server from DDoS attacks.

ffmpeg: error while loading shared libraries: libavdevi

Error:-
ffmpeg: error while loading shared libraries: libavdevice.so.52:
cannot open shared object file: No such file or directory.

Execute the following command to fix this issue:-

echo “/usr/local/lib” >> /etc/ld.so.conf
echo “/usr/lib” >> /etc/ld.so.conf
ldconfig

error: ‘PIX_FMT_RGBA32? undeclared

Error:

/root/ffmpeg-php-0.5.0/ffmpeg_frame.c:495: error: ‘PIX_FMT_RGBA32? undeclared (first use in this function)
make: *** [ffmpeg_frame.lo] Error 1










Fix:

1. Open the file “/root/ffmpeg-php-0.5.0/ffmpeg_frame.c” using vi editor.
2. Go to the line you are getting this error. [In this example, line #495].
3. Execute the following command.

Press ESC and :%s/PIX_FMT_RGBA32/PIX_FMT_RGB32

4. Save the file and recompile it once again.

named issue


Issue:- named service is running in the server. But, domains are not resolving to any query.


Cause: If you find the following error in the log file, then it seems to be a bug in CentOS version 5 and cPanel version 11.


view localhost_resolver: received notify for zone ‘domain.com’: not authoritative


Fix:


1. Open the named configuration file /etc/named.conf


2. Search the following entries in external views



match-clients         { localhost; };
match-destinations    { localhost; };

3. Change them as follows:



match-clients { any; };
match-destinations { any; };

4. Restart named service.



DNS, FTP and Telnet

This is a good an animated presentation to know about DNS, FTP and Telnet.

Have a look at this video.





nslookup

Have a look at this video. It’s well explained about nslookup client.
[youtube http://www.youtube.com/watch?v=TiWSrrnG70k&color1=0xb1b1b1&color2=0xcfcfcf&feature=player_embedded&fs=1]

Easyapache error


If you get the following error while performing easyapache:



Can’t locate Curses.pm in @INC (@INC contains: /scripts/../lib /var/cpanel/easy/apache/custom_opt_mods /usr/local/cpanel /var/cpanel/perl/easy /scripts /usr/local/lib/perl5/5.8.8/i686-linux /usr/local/lib/perl5/5.8.8 /usr/local/lib/perl5/site_perl/5.8.8/i686-linux /usr/local/lib/perl5/site_perl/5.8.8 /usr/local/lib/perl5/site_perl .) at /usr/local/lib/perl5/site_perl/5.8.8/Curses/UI/Common.pm line 20. BEGIN failed–compilation aborted at /usr/local/lib/perl5/site_perl/5.8.8/Curses/UI/Common.pm line 20. Compilation failed in require at (eval 2509) line 3. …propagated at /usr/local/lib/perl5/5.8.8/base.pm line 85. BEGIN failed–compilation aborted at /usr/local/lib/perl5/site_perl/5.8.8/Curses/UI.pm line 2. Compilation failed in require at /var/cpanel/perl/easy/Cpanel/Easy/Apache/UI/CLI/Config.pm line 5. BEGIN failed–compilation aborted at /var/cpanel/perl/easy/Cpanel/Easy/Apache/UI/CLI/Config.pm line 5. Compilation failed in require at /var/cpanel/perl/easy/Cpanel/Easy/Apache/UI/CLI.pm line 404.

then execute the following command from shell prompt.


/scripts/realperlinstaller –force Curses::UI


Now you can perform easyapache without any issue.


OR



!! The perl module ‘Acme::Spork’ (v0.0.7) is too old to use. It must be at least version ‘0.0.8?.

!! To install it execute this command as root ‘/scripts/perlinstaller Acme::Spork’ !!

Then fire ::


# /scripts/perlinstaller –force Acme::Spork

How to Configure Application Pool in IIS

An application pool provides you with a way of isolating Web sites from each other even though they are being hosted on a common server.


Each application pool is given its own set of server resources.


The main advantage is, if a Web site crashes, it won’t effect sites in other application pools.


There are a few ways to tune Application Pool’s performance.


1. To do so, Start | IIS | website | Right click on Application Pool which you need to configure.


2. Click “Recycling” tab | Check the box “Recycle worker processes” and enter the value as 1740


3. Click “Performance” tab | Check the box “Shutdown worker processes after being idle for” under “Idle Timeout” section and enter the value as 20



Check the box “Limit the kernel request queue” under “Request kernel limit” section. The value is 4000.

4. Enter the value as 1 for “Maximum number of worker processes” under “Web garden” section


5. Click “Health” tab | Check the box “Enable pinging” | Enter the value as 20 for “ping worker process every”

Check the box “Enable rapid-fail protection” | Enter the value as 5 for “Failures” and “Time period”

Set the value as 90 for “Worker process must startup within” under the section “Startup time limit”

Set the value as 90 for “Worker process must shutdown within” under the section “Shutdown time limit”

Commands of the day

To shutdown the system at a particular time


# shutdown -h hours:minutes &


To find the files with an extension .html,


# locate *.html


To list the files having SUID configured in the system, use the command:


#  find / -perm -u+s

How to do basic MySQL optimization

MySQL – Intro


Pronounced “my ess cue el” (each letter separately).


MySQL is an open-source high-performance, multi-threaded, multi-user relational database management system (RDBMS) built around a client- server architecture.


It was designed specifically for speed and stability and has become one of the most popular RDBMS for database-driven Web application.


Information is stored in “Tables” which can be thought of as the equivalent of Excel spreadsheets. A single MySQL database can contain many tables at once and store thousands of individual records. It’s fast, reliable and flexible.



MySQL Variables


max_connections


MySQL is multi-threaded, so there may be many clients issuing queries to a single table simultaneously.


The number of simultaneous client connections allowed. By default, this is 100.



max_user_connections


The maximum number of simultaneous connections allowed to any given MySQL account. A value of 0 means “no limit”.



key_buffer_size


key_buffer_size is the size of the buffer used for index blocks. The key buffer is also known as the key cache.



myisam_sort_buffer_size


The size of the buffer that is allocated when sorting MyISAM indexes during a REPAIR TABLE or when creating indexes with CREATE INDEX or ALTER TABLE.


join_buffer_size


The size of the buffer that is used for joins that do not use indexes and thus perform full table scans. Normally, the best way to get fast joins is to add indexes.


Increase the value of join_buffer_size to get a faster full join when adding indexes is not possible.


One join buffer is allocated for each full join between two tables.



read_buffer_size


Each request that performs a sequential scan of a table allocates a read buffer.



sort_buffer_size


Each thread that needs to do a sort allocates a buffer of this size. Increase this value for faster ORDER BY or GROUP BY operations.



table_cache


The number of open tables for all threads. Increasing this value increases the number of file descriptors that mysqld requires.



thread_cache_size


How many threads the server should cache for reuse. When a client disconnects, the client’s threads are put in the cache if there are fewer than thread_cache_size threads there.


Requests for threads are satisfied by reusing threads taken from the cache if possible, and only when the cache is empty is a new thread created.


Increasing the value to improve performance if we have a lot of new connections.



wait_timeout


The number of seconds the server waits for activity on a non-interactive connection before closing it.


This timeout applies only to TCP/IP and Unix socket file connections, not to connections made via named pipes, or shared memory.



connect_timeout


The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake.



max_allowed_packet


The maximum size of one packet or any generated/intermediate string.



max_connect_errors


If there are more than this number of interrupted connections from a host, that host is blocked from further connections.


You can unblock blocked hosts with the FLUSH HOSTS statement.



query_cache_limit


Don’t cache results that are larger than this number of bytes. The default value is 1MB.



query_cache_size


The amount of memory allocated for caching query results. The default value is 0, which disables the query cache.


The allowable values are multiples of 1024; other values are rounded down to the nearest multiple.



open_files_limit


The number of files that the operating system allows mysqld to open.



Sample values for optimizing MySQL


[mysqld]



max_connections = 400
key_buffer = 128M (128MB for every 1GB of RAM)

myisam_sort_buffer_size = 64M
join_buffer_size = 2M
read_buffer_size = 2M (1MB for every 1GB of RAM)

sort_buffer_size = 3M (1MB for every 1GB of RAM)
table_cache = 1024
thread_cache_size = 286
interactive_timeout = 25
wait_timeout = 1800
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 16M (32MB for every 1GB of RAM)

query_cache_type = 1
tmp_table_size = 16M

thread_concurrency=2 (Number of CPUs x 2)




[mysqld_safe]
open_files_limit = 8192


[mysqldump]
quick
max_allowed_packet = 16M


[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M

No space left on device: mod_rewrite: Error

If you find the errors in Apache error logs as follows:


No space left on device: Couldn’t create accept lock [or]


No space left on device: mod_rewrite: could not create rewrite_log_lock Configuration Failed


Then, execute the following commands. It’ll fix this issue.




ipcs -s | grep nobody
for i in `ipcs -s | grep nobody | awk ‘{print $2}’`; do ipcrm -s $i; done

The above errors will occur if the Apache user occupies a great number of semaphores.

Access denied with code 403

Error from domain’s error log:


mod_security: Access denied with code 403. Error reading request body, error code 70007: The timeout specified has expired




Fix:


1. Open Apache configuration file


It should be either /usr/local/apache/conf/httpd.conf or /etc/httpd/conf/httpd.conf.


2. Navigate to Timeout


3. Set this value to 300


4. Restart Apache service.

Clear domlogs

cd /usr/local/apache/domlogs


for i in `du -sch * | grep G`; do :> $i; done


for i in `du -sch * | grep [0-9][0-9][0-9]M`; do :> $i; done


for i in `du -sch * | grep [0-9][0-9]M`; do :> $i; done


for i in `du -sch * | grep [0-9]M`; do :> $i; done


/etc/init.d/httpd restart

Tuesday 22 September 2009

Access a file from other domain/server

I tried this piece of code:

RewriteEngine ON
RewriteRule ^aboutus.html$ http://www.domain1.com/about_us.php [P]

Its working, but for few files i use secured connection.

If i use

RewriteRule ^aboutus.html$ http://www.domain1.aboutus.php [P]

it is works perfectly

But

RewriteRule ^aboutus.html$ https://www.domain1.aboutus.php [P]

It gives an internal server error.

URL file-access is disabled in the server configuration

* Warning: include() [function.include]: URL file-access is disabled in the server configuration in /home/xxxxxx/public_html/index.php on line 104

I've recently upgraded Apache and PHP on my VPS, and one of the unpleasant surprises was that some scripts which tried including pages from remote sites (I know, not the most secure approach, but there were reasons for that) got broken.



allow_url_fopen


Traditionally, all the websites Google finds suggest that you double-check that your php.ini config has the allow_url_fopen enabled:




allow_url_fopen = On



Well, in my case it was enabled, but scripts were still broken. The really weird thing was that the upgrade procedure didn't include changing the php.ini in any way, so it was fully working before and I kind of expected it to continue working.



allow_url_include


After some quick research, I've found out that PHP 5.1 introduced a new security option to accompany the allow_url_fope, and this was exactly the option which broke my scripts:




allow_url_include = On



There you have it, hope it helps you next time you come across this problem!

Rebuilding Software RAID

One of our clients had a hard drive fail. The harddisk was marked faulty and removed as well. Client inserted new HDDs, and needed us to rebuild the array. Hot swappable HDs would have done the job real quick. But not here. There is some process involved in rebuilding the array.

A normal array will have the output similar to below – Notice the [UU] – U could mean “Used”. A fully functional RAID system would show [UU] for each slice.


cat /proc/mdstat
Personalities : [raid1]
md0 : active raid1 sda1[0] sdb1[1]
1052160 blocks [2/2] [UU]


A degraded array will look like,

cat /proc/mdstat
Personalities : [raid1]
md2 : active raid1 sdb2[1]
8385856 blocks [2/1] [_U]


_ means degraded array i.e partition missing from array.

Use fdisk to create partitions similar to the one working in the HDD. Using fdisk, then n , p t etc to recreate the partitions are not needed if you have sfdisk in the server.

sfdisk – Partition table manipulator for Linux

fdisk -l or cat /proc/mdstat will give you the device name which is active and the below command will give the partition table of sdb to part.sdb file

sfdisk -d /dev/sdb > part.sdb

sfdisk –-force /dev/sda < part.sdb will copy the partition table to this new sda disk saving the time.

BE CAREFUL ON WHAT PARTITION TABLES ARE COPIED. Don't copy unused drive's partition table to the active one :D


Finally, once the partition table is copied, execute this

# mdadm --add /dev/md0 /dev/sda1
# mdadm --add /dev/md1 /dev/sda3
# mdadm --add /dev/md2 /dev/sda2
# mdadm --add /dev/md3 /dev/sda5

Saturday 19 September 2009

I forgot my password and need a reset

DATABASE
We cannot reset this kind of password. Instead, you must create a new user with a new password. Do not worry, this will not erase or change any of the data in your database!

  1. Go to cPanel, click Mysql Databases.

  2. Add New User with the desired password.

  3. Add the new User To Database.

  4. Change your site configuration settings to the new user name and password.

Wednesday 16 September 2009

How To Backup Remote Linux Host Using rsnapshot rsync Utility

In the previous article we reviewed how to backup local unix host using rsnapshot utility.


In this article, let us review how to backup remote Linux host using this utility.




1. Setup Key Based Authentication


As we’ve explained earlier setup the key based authentication as explained either in ssh-keygen and ssh-copy-id article or openSSH article.



[root@local-host]# ssh-keygen

[root@local-host]# ssh-copy-id -i ~/.ssh/id_rsa.pub remote-host

2. Verify the password less login between servers


Login to the remote-host from local-host without entering the password.



[root@local-host]# ssh remote-host
Last login: Sun Mar 15 16:45:40 2009 from local-host

[root@remote-host]#

3. Configure rsnapshot and specify Remote Host Backup Directories


Define your remote-host destination backup directories in /etc/rsnapshot.conf as shown below. In this example,




  • root@remote-host:/etc – Source directory on the remote-host that should be backed-up. i.e remote backup destination directory.

  • remote-host-backup/ – destination directory where the backup of the remote-host will be stored. Please note that this directory will be created under local-host /.snapshots/{internal.n}/ directory as shown in the last step.


# vi /etc/rsnapshot.conf

backup root@remote-host:/etc/ remote-host-backup/ exclude=mtab,exclude=core

4. Test rsnapshot Configuration


Perform configuration test to make sure rsnapshot is setup properly and ready to perform Linux rsync backup.



# rsnapshot configtest
Syntax OK

5. Add Crontab Entry for rsnapshot


Once you’ve verified that the rsync hourly and daily backup configurations are setup properly in the rsnapshot cwrsync utility, it is time to set this puppy up in the crontab as shown below.



# crontab -e
0 */4 * * * /usr/local/bin/rsnapshot hourly
30 23 * * * /usr/local/bin/rsnapshot daily

Check out Linux crontab examples article to understand how to setup and configure crontab.



6. Manually test the remote-host backup once


[root@local-host]# /usr/local/bin/rsnapshot hourly

[root@local-host]# ls -l /.snapshots/hourly.0/
total 8
drwxr-xr-x 3 root root 4096 Jul 22 04:19 remote-host-backup
drwxr-xr-x 3 root root 4096 Jul 13 05:07 localhost

[root@local-host]# ls -l /.snapshots/hourly.0/remote-host-backup/
total 4
drwxr-xr-x 93 root root 4096 Jul 22 03:36 etc

Troubleshooting Tips


Problem: rsnapshot failed with ERROR: /usr/bin/rsync returned 20 as shown below.



[root@local-host]# /usr/local/bin/rsnapshot hourly
rsync error: received SIGINT, SIGTERM, or SIGHUP (code 20) at rsync.c(260)
[receiver=2.6.8]
----------------------------------------------------------------------------
rsnapshot encountered an error! The program was invoked with these options:
/usr/local/bin/rsnapshot hourly
----------------------------------------------------------------------------
ERROR: /usr/bin/rsync returned 20 while processing copyman@192.168.2.2:/etc/

Solution: This typically happens when the users who is performing the rsnapshot (rsync) doesn’t have access to the remote directory that you are trying to backup. Make sure the remote host backup directory has appropriate permission for the user who is trying to execute the rsnapshot.