How to turn off Innodb engine?

November 17, 2009    |   Posted by admin   |    Category: Linux Administration

How to turn off Innodb Engine in Mysql?

When Mysql is installed, Innodb Engine is set to ON by default. You can verify whether Innodb is set to On or Off by using ‘mysqladmin variables’. Login to the server as root and execute:

root@host [~]# mysqladmin variables | grep have_innodb
| have_innodb                     | ENABLED

To turn off Innodb, you need to edit the Mysql Configuration file at /etc/my.cnf and add the following line:

skip-innodb

Save the file and restart the mysql service. You now execute the ‘mysqladmin variables’ to check the status of Innodb engine.

Comments Off on How to turn off Innodb engine?

Shell Script for Disk Space Notification

November 13, 2009    |   Posted by admin   |    Category: Scripts

Shell Script for Disk Space Notification

The Disk Space Notification script can be scheduled to run once in a week which will check the Disk Space Usage on the server. The Shell script will send out an email to the admin if the Disk Space Usage is greater than the Threshold.

Create a file /home/diskspace.sh and paste the following code in it:

#!/bin/sh

#Threshold is set to 70 here.
THRESHOLD=70
MAILTO=”youremailaddress”
TEMPFILE=/tmp/diskspace.temp
HOSTNAME=`hostname`

rm -f $TEMPFILE

#Calculate the Current Disk Usage with the below command.
CDU=$(df -h | tail -1 | awk ‘{print $5}’ | sed ‘s/%//’)

#Compare the current value with the threshold one.
if [ $(expr $CDU “>=” $THRESHOLD) -ne 0 ]
then
echo “Warning!!! Disk Space usage on server $HOSTNAME is ${CDU}%” >> $TEMPFILE
fi

#Send an email if /tmp/diskspace.temp is present.
if [ -e $TEMPFILE ]
then
mail -s “Disk Space Notification” $MAILTO < $TEMPFILE
fi

rm -f $TEMPFILE

Save the file. Now you need to schedule a cron to execute the script once in a week.

crontab -e

and set the following cronjob:

0 1 * * 0  /bin/sh  /home/diskspace.sh

Save the file and restart the crond service. The cronjob will now execute on Sunday at 1.00AM and will send a notification if the disk space usage on the server is above the threshold.

PHP Warning: POST Content-Length exceeds the limit

November 13, 2009    |   Posted by admin   |    Category: Linux Administration

PHP Warning: POST Content-Length of xxxxx bytes exceeds the limit of xxxxxx bytes in Unknown on line 0

You receive the “POST Content-Length” error message when a file greater than the size defined in the php.ini file is uploaded via the browser.

The file you are uploading using the POST method should not exceed the value of post_max_size defined in php.ini file. If it does, it results in the above error message.

Solution:
In case you are looking to upload a larger file size, you need to increase the value of “post_max_size” in php.ini.

1) To locate the exact php.ini file, your PHP is using

php -i | grep php.ini

2) Edit the php configuration file

pico /usr/local/lib/php.ini

3) If you are looking to upload a file of 30M, set post_max_size and to upload_max_filesize to 40M.

post_max_size = 40M
upload_max_filesize = 40M

4) Save the file and restart the httpd service

service httpd restart

You should be done now.

Howto: Enable SuPHP/phpSuExec on a cPanel server?

November 11, 2009    |   Posted by admin   |    Category: cPanel Management

How to install and enable SuPHP on a cPanel server OR
How to install phpSuExec on a Linux Server?

SuPHP Or PHPSuExec as most people call is a module that increases the security of the server and executes PHP files under the owner of the file instead of the Apache user i.e. nobody. The advantages of having suPHP are:

1. Files and Directories those need 777 permissions to write into will no longer need those permissions and will result in an “Internal Server Error” The maximum permissions a directory or a file will need is 755 so it won’t be world writable anymore.

It helps to track down spammers if bulk emails are sent out via a PHP script since the script will be executed under the users UID/GID level and not nobody.

2.You need to place all the php directives for ex. safe_mode in the php.ini of a domain instead of .htaccess. You have to create a separate php.ini for the account and manipulate the values of php directives. If they are placed in .htaccess it will result in an “Internal Server Error”.

3. All the files and directories uploaded via the browser will have the ownership of the user they are uploaded under instead of ‘nobody’.

4.You will be able to edit/remove the files which are uploaded via the browser using Ftp.

5. The directives placed in a php.ini of an account will only effect the directory it is placed and won’t effect recursively as opposed to .htaccess.

Below is a small guide on installation, activation and verification of SuPHP on a cPanel server:

1. Installing SuPHP using easyapache script OR “Apache Update” option in WHM. Login to your server as root and execute the easyapache script:

# /scripts/easyapache

Once you execute the script, it will open a new screen asking you to select various options. On the first screen, you have to select the profile. You can use the default settings and select “Start customizing based on profile”. You then have to select the Apache version, then the PHP version on the next screen.

On the 5th screen, it will list different modules and the first one is “Mod SuPHP”. Select the modules using space bar and select “Save and Build”. All the previous options along with Suphp module will be compiled again. It will take around 30 minutes to complete the compilation process.

2. Enable SuPHP. Once the installation completes, you have to enable SuPHP to make it work. To enable SuPHP, simply execute the following command:

# /usr/local/cpanel/bin/rebuild_phpconf 5 none suphp 1

where,

5, is PHP version 5.
none, is we do not need PHP4.
suphp, is we need to enable suphp
1, is we need Apache Suexec enabled.

Verify the new configuration:

# /usr/local/cpanel/bin/rebuild_phpconf --current
Available handlers: suphp dso cgi none
DEFAULT PHP: 5
PHP4 SAPI: none
PHP5 SAPI: suphp
SUEXEC: enabled

If you see ‘suphp’ in front of PHP5, it’s time to restart the Apache service for the changes to take effect.

service httpd restart

3. Verify if SuPHP is working. Create a php file say phpinfo.php under an account and set the permissions to 777.

touch /home/user/public_html/phpinfo.php
chmod 777 /home/user/public_html/phpinfo.php

You should see a “Internal Server Error” on browsing the file. If you do, SuPHP is working so make sure files/directories are owned by owner and permissions should be no more than 755.

The log file resides at:

/usr/local/apache/logs/suphp_log

Hope this article helps you to enable SuPHP from the command line.

Related Links:
How to install/enable SuPHP on a Plesk server?

call_handlers: DEFER during call ‘/usr/local/psa/handlers/info/05-grey-tqyVhg/executable’ handler OR Message cannot be delivered and error “Unable to stat entry

November 11, 2009    |   Posted by admin   |    Category: Plesk Management

Error:

call_handlers: DEFER during call ‘/usr/local/psa/handlers/info/05-grey-tqyVhg/executable’ handler

OR

Message cannot be delivered and error “Unable to stat entry ‘/usr/local/psa/handlers/info/10-spam-0gemCa/executable’

You see the above error message in the mail logs because the configuration of the handlers i.e. 10-spam-0gemCa are broken. In this case, you need to either delete them OR move them elsewhere so that you can recreate the configuration by using the ‘mchk’ utility of Plesk

Solution:

1. Stop the mail service

# /usr/local/psa/admin/sbin/mailmng --stop-service

OR

# service qmail stop

2. Backup old handlers in a temporary directory

# mkdir /usr/local/temp
# cp -a /usr/local/psa/handlers/before-* /usr/local/temp/
# cp -a /usr/local/psa/handlers/info /usr/local/temp/

3. Remove the handlers

# rm -rf /usr/local/psa/handlers/before-*/*
# rm -rf /usr/local/psa/handlers/info/*

4. Recreate handlers using mchk utility

# /usr/local/psa/admin/sbin/mchk --with-spam

5. Start mail service:

# /usr/local/psa/admin/sbin/mailmng --start-service

OR

service qmail start

BTW, the path to mailogs is /usr/local/psa/var/log/maillog.

Comments Off on call_handlers: DEFER during call ‘/usr/local/psa/handlers/info/05-grey-tqyVhg/executable’ handler OR Message cannot be delivered and error “Unable to stat entry