ABHIONLINUX
Site useful for linux administration and web hosting

2009/12/23

Installing fantastico on a cPanel Server

Here are the steps:-
============

Login to server WHM >> Plugins >> Fantastico De Luxe WHM Admin >> Click here >> Select a version from the drop down menu >> Follow the remaining installation steps, using the default information.

If the Fantastico install option is not available,then we have to download Fantastico manually onto our server.

=========================================
1) Login to the server via ssh

2) Change the folder using the command:

[root@localhost ~]#cd /usr/local/cpanel/whostmgr/docroot/cgi

3) Download the Fantastico install file using the command

[root@localhost ~]#wget http://www.netenberg.com/files/free/fantastico_whm_admin.tgz

4) Extract the install file using the command:

[root@localhost ~]#tar -xzpf fantastico_whm_admin.tgz

5) Remove the install file using the command:

[root@localhost ~]#rm -rf fantastico_whm_admin.tgz

6) Log out of the SSH connection.

7) log back into cPanel.

8)Go through Plugins >> Fantastico De Luxe WHM Admin

9) Continue the install using the above mentioned steps.
========================================

Fantastico Showing Blank Page

Fantastico is showing blank page after installation.New installation was also giving the blank page.

FIX:-
====
Change the following on config.php file.

#define(”PLUGIN_ROOTDIR”,”/tmp”);
define(”PLUGIN_ROOTDIR”,”plugins”);

Cause:-
The server is PHP-SUEXEC enabled so the plugin_rootdir should be given
as “plugins” in config.php file.

Fix for memory limit error in joomla site

You could see memory limit error on joomla sites. Even though you increase memory limit on php.ini file, it will not solve.

In Apache error logs you can find the following:-

===================================================
[Wed Feb 6 05:56:26 2008] [error] (22)Invalid argument: setrlimit: failed to set memory limit
[Wed Feb 7 09:48:26 2008] [error] (22)Invalid argument: setrlimit: failed to set memory limit
===================================================
Fix:-
Remove the following entries from apache configuration file.

1. RLimitMEM 519640064
2. RLimitCPU 240

Restart apache after this. This will fix the issue

Error "This application is currently not available” in fantastico

The user is getting the following error while accessing fantastico :
This application is currently not available

Fix:-
====
You have to make register_global = On in /usr/local/cpanel/3rdparty/etc/php.ini

“cannot connect to mysql ” in fantastico

If you are getting an error like “cannot connect to mysql ” in fantastico
then check if the soft link is there in /tmp. If there is no softlink.Issue the following command:-

[root@bigboy ~]#ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock

Configuration files in cpanel server

Apache:-

/usr/local/apache/ bin->Apache binaries are stored here
/usr/local/apache/conf–>configuration files – httpd.conf
/usr/local/apache/cgi-bin->Cgi bin directory
/usr/local/apache/domlogs–>domain log files are stored here
/usr/local/apache/htdocs->default doucument root of the server
/usr/local/apache/include–>contains header files
/usr/local/apache/modules–>Contains shared object (.so) files
/usr/local/apache/logs–>apache logs contains access_log, errorlog and suexec_log

Exim:-

->/etc/exim.conf – exim configuration file
->/etc/localdomains – list of the domains which are allowed to relay mail
->/var/log/exim_mainlog – exim main log file
-> /var/log/exim_rejectlog – Contains the logs for the rejected mails.
->/var/log/exim_paniclog – Contains exim errors
->/var/spool/exim/input-Mail queue for exim
->/etc/valiases/domainname.com- Email forwarders and catchall.
->/etc/vfilters/domainname.com-Email filter
->/home/username/etc/domainname/passwd-POP authentication file

ProFTPD:-

-> /etc/proftpd-configuration file
->/var/log/messages-ftp logs
->/etc/proftpd/username- All the ftp accounts and password will be listed here.

Pure-FTPD:-

->/etc/pure-ftpd.conf-Pureftpd configuration file.
->/etc/pure-ftpd/ip-address-document root for the anonymous ftp

Mysql:-

/etc/my.cnf->configuration file
/root/.my.cnf->Contains the root password
/var/lib/mysql –Data directory which contains all the MySql databases.

SSHD:-

/etc/ssh/sshd_config->configuarton file
/var/log/messages-> Log file
/etc/banner->Contains the banner to be displayed

Named:-

/etc/named.conf->Main configuration file
/var/named->Directory which contains the db records
/var/log/messages-> Log file

Cpanel Configuration files:-

/usr/local/cpanel-/bin –> cpanel binaries
/usr/local/cpanel/cgi-sys –> Contains cgi files like formmail.cgi etc
/usr/local/cpanel-/base –> phpmyadmin, squirrelmail, skins, webmail etc
/usr/local/cpanel-/logs -> cpanel access log, error log etc
/usr/local/cpanel/ 3rdparty/ –Fantastico,mailman files are located here
/usr/local/cpanel-/addons –> AdvancedGuestBook, phpBB etc
/var/cpanel/users/username – >cpanel user file
/var/cpanel/cpanel.config –> cpanel configuration file.
/var/cpanel/resellers –> Reseller configuration files.
/var/log/dcpumon –> Top log process
/etc/wwwacct.conf –> account creation default file
/etc/cpupdate.conf – >cPanel Updation Config file
/etc/cpbackup.conf –> Backup configuration file
/var/cpanel/bandwidth –> Contains bandwidth usage details of the domains.

Name server and IP configuration files:-

/etc/sysconfig/network –Network configuration files
/etc/hosts->Contains hostname of the server
/etc/resolv.conf –> Resolver Configuration
/etc/nameserverips –>Contains the name server IP details
/etc/ips –>List of all the ip addresses except the shared ip on the server.
/etc/ipaddrpool – >ip addresses which are free
/etc/ips.dnsmaster –> name server ips

How to setup Wild Card Entry For a Domain

Edit the DNS zone file:-

Open the zone db file corresponding to the domain (For eg, domain.com)
[root@localhost ~]#vi /var/named/domain.com.db
Add the following line:-
================
* IN A IPaddress
=================
save and exit
restart named

[root@localhost ~]# /etc/init.d/named restart

Edit httpd conf file:-

[root@localhost ~]#vi /usr/local/apache/conf/httpd.conf

Add the following entry:-

===================
server alias *.domain.com
===================

save and exit

restart httpd

How to check DNS zone file configuration for errors

You can use the named-checkzone command to check the zone db for errors:-

[root@server]# named-checkzone abhionlinux.com /var/named/abhionlinux.com.db
Output:-
zone abhionlinux.com/IN: loaded serial 12
OK


or

[root@server]# named-checkconf /etc/named.conf

Install YUM in the server

for file in \
gmp-4.1.4-10.el5.x86_64.rpm \
readline-5.1-1.1.x86_64.rpm \
python-2.4.3-21.el5.x86_64.rpm \
libxml2-2.6.26-2.1.2.1.x86_64.rpm \
libxml2-python-2.6.26-2.1.2.1.x86_64.rpm \
expat-1.95.8-8.2.1.x86_64.rpm \
python-elementtree-1.2.6-5.x86_64.rpm \
sqlite-3.3.6-2.x86_64.rpm \
python-sqlite-1.1.7-1.2.1.x86_64.rpm \
elfutils-0.125-3.el5.x86_64.rpm \
rpm-python-4.4.2-48.el5.x86_64.rpm \
m2crypto-0.16-6.el5.2.x86_64.rpm \
python-urlgrabber-3.1.0-2.noarch.rpm \
yum-3.2.8-9.el5.centos.1.noarch.rpm
do rpm -Uvh http://mirror.centos.org/centos-5/5.2/os/x86_64/CentOS/$file;
done

DB_RUNRECOVERY: Fatal error, run database recovery

If you are getting error message like this when you are trying to do an yum update.

Error message like ->
============================================
ror: error(-3097 getting "system-config-display.mo" records from Basenames index
rpmdb: PANIC: fatal region error detected; run recovery
error: db4 error(-3097 from dbcursor->c_get: DB_RUNRECOVERY: Fatal error, run database recovery
error: error(-3097 getting "system-config-display.mo" records from Basenames index
rpmdb: PANIC: fatal region error detected; run recovery
error: db4 error(-3097 from dbcursor->c_get: DB_RUNRECOVERY: Fatal error, run database recovery
error: error(-3097 getting "system-config-display.mo" records from Basenames index
rpmdb: PANIC: fatal region error detected; run recovery
error: db4 error(-3097 from dbcursor->c_get: DB_RUNRECOVERY: Fatal error, run database recovery
error: error(-3097 getting "system-config-display.mo" records from Basenames index
************************************************** *****

try the following steps.

rm -f /var/lib/rpm/__db*
rpm -vv --rebuilddb
rpm -Va
yum update

2009/12/22

How to increase the size of /tmp partition in Linux?

Proceed with the given steps:-
========================
1)Stop MySql service and process kill the tailwatchd process.

[root@localhost ~]# /etc/init.d/mysqld stop
Stopping MySQL: [ OK ]
[root@localhost ~]#pstree -p | grep tailwatchd
Find the tailwatchd process id and kill it
[root@localhost ~]# kill -9 2522

2)Take a backup of /tmp as /tmp.bak
[root@localhost ~]#cp -prf /tmp /tmp.bak

3)Create a 2GB file in the avaliable freespace

==============================
[root@localhost dev]# dd if=/dev/zero of=/usr/tmpDSK bs=1024k count=2048
2048+0 records in
2048+0 records out
2147483648 bytes (2.1 GB) copied, 73.6908 seconds, 29.1 MB/s
==============================

[root@localhost dev]# du -sch /usr/tmpDSK
2.1G /usr/tmpDSK
2.1G total

4)Assign ext3 filesystem to the file
====================================
[root@localhost dev]# mkfs -t ext3 /usr/tmpDSK
mke2fs 1.39 (29-May-2006)
/usr/tmpDSK is not a block special device.
Proceed anyway? (y,n) y
Filesystem label=
OS type: Linux
262144 inodes, 524288 blocks
26214 blocks (5.00%) reserved for the super user
First data block=0
Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done
This filesystem will be automatically checked every 25 mounts or
180 days, whichever comes first. Use tune2fs -c or -i to override.
====================================
5) Check the file system type:-

[root@localhost dev]# file /usr/tmpDSK

/usr/tmpDSK: Linux rev 1.0 ext3 filesystem data (large files)
Note:-
=====
You may also use the following comands for making ext3 file system on a file:
[root@localhost dev]#mkfs.ext3 /usr/tmpDSK
[root@localhost dev]#mke2fs /usr/tmpDSK

6)Unmount /tmp partition

[root@localhost dev]#umount /tmp

7))Mount the new /tmp filesystem with noexec

[root@localhost dev]#mount -o loop,noexec,nosuid,rw /usr/tmpDSK /tmp

8) Set the correct permission for /tmp

[root@localhost dev]# install -d –mode=1777 /tmp
[root@localhost dev]# ls -ld /tmp
drwxrwxrwt 3 root root 4096 Feb 6 08:42 /tmp
( you may use the command chmod 1777 /tmp for doing the same )
==========================

[root@localhost dev]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 28G 6.4G 20G 25% /
/dev/sda8 99M 10M 84M 11% /boot
tmpfs 500M 0 500M 0% /dev/shm
/usr/tmpDSK 2.0G 68M 1.9G 4% /tmp
==========================
7)Restore the content of old /tmp.bkp directory

[root@localhost dev]# cp -rpf /tmp.bak/* /tmp

8) Restart the mysql and tailwathchd services.

[root@localhost dev]# /etc/init.d/mysql start
[root@localhost dev]# /scripts/restartsrv_tailwatchd

9)Edit the fstab and replace /tmp entry line with :-
=========================================
/usr/tmpDSK /tmp ext3 loop,noexec,nosuid,rw 0 0=========================================
10) Mount all filesystems

[root@localhost dev]#mount -a

Check it now:-
============================
[root@localhost ~]# df -h
Filesystem Size Used Avail Use% Mounted on
/dev/sda9 28G 6.4G 20G 25% /
/dev/sda8 99M 10M 84M 11% /boot
tmpfs 500M 0 500M 0% /dev/shm
/usr/tmpDSK 2.0G 68M 1.9G 4% /tmp
============================
Done.

How to prevent the Syn flood attack?

1)Enable SYN cookies mechanism in the server.

SYN cookies mechanism can be enabled in the following way:

[root@server src]## echo 1 > /proc/sys/net/ipv4/tcp_syncookies

2)Increase the backlog queue:-

A tcp_max_backlog variable_defines how many half-open connections can be kept by the backlog queue.

change the default size of the backlog queue to 2048 by executing the the sysctl command:

[root@server src]# sysctl -w net.ipv4.tcp_max_syn_backlog="2048"

Getting custom php.ini working on php-cgi

1, Copy the servers default php.ini to your home directory

2, Make the following directory in user home directoy and chown to user:user
cgi-bin

3, Create a file php.cgi in cgi-bin with the following content
#!/bin/sh
exec /usr/local/cpanel/cgi-sys/php5 -c /home/user/public_html/

4, Chmod +x php.cgi and chown the file to user:user.

5, Add the following in the .htaccess.

Action application/x-httpd-php5 /cgi-bin/php.cgi

Installing a custom module in cpanel server

To install a custom module:

1. Download and unzip it into /var/cpanel/easy/apache/custom_opt_mods/.
2. When logged into your server as root, you can install any module listed below by running the following commands. Be sure to replace $NAME.tar.gz with the filename of the module you wish to download:

wget http://easyapache.cpanel.net/optmods/$NAME.tar.gz
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf $NAME.tar.gz

For example:
If you want to install mod_python

cd /var/cpanel/easy/apache/custom_opt_mods

wget http://twiki.cpanel.net/twiki/pub/EasyApache3/CustomMods/custom_opt_mod-mod_python.tar.gz
tar -C /var/cpanel/easy/apache/custom_opt_mods -xzf custom_opt_mod-mod_python.tar.gz

Reference : http://docs.cpanel.net/twiki/bin/view/EasyApache3/CustomMods

2009/12/17

Install Wine on CentOS 5

Trying to install wine using the usual yum command but here is what it says when giving the following command.

shell>> yum install wine
Loading “fastestmirror” plugin
Loading mirror speeds from cached hostfile
* base: centose.centos.org
* updates: centosj.centos.org
* addons: centosh3.centos.org
* extras: centose-msync-dvd.centos.org
Excluding Packages in global exclude list
Finished
Setting up Install Process
Parsing package install arguments
No package wine available.
Nothing to do

Well the reason is Wine software is not a part of standard CentOS. There is a section on 3rd party repositories called RPMForge. So we will proceed installing the Repositories.

1.) You should make sure that you have Priorities installed

yum-priorities is available in the CentOS 5 repositories:

yum install yum-priorities

Plugins are enabled in CentOS 5 by default

Make sure that yum-priorities is enabled by editing the /etc/yum/pluginconf.d/priorities.conf file, and ensuring that it contains the following lines:

[main]
enabled=1

Download the rpmforge-release package. Choose one of the two links below, depending on your architecture. If you are unsure of which one to use you can check your architecture with the command uname -i

for i386 http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

Install DAG’s GPG key

rpm –import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt
Verify the package you have downloaded

rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm

Security warning: The rpmforge-release package imports GPG keys into your RPM database. As long as you have verified the package and trust Dag then it should be safe.

Install the package

rpm -i rpmforge-release-0.3.6-1.el5.rf.*.rpm

This will add a yum repository config file and import the appropriate GPG keys. At this point, you can set the priority of the RPMForge repository, and also of the CentOS repositories if you have not done so yet.

Test with this command:

yum check-updateIt should output these two lines:

Loading “priorities” plugin

76 packages excluded due to repository priority protectionsThe number above may differ, but there should be several packages shown as being excluded.

If so then it looks like things are working so try installing something like this

yum -–enablerepo=rpmforge install wine

Thats all Wine is installed.
shell>> which wine
/usr/bin/wine

2009/12/16

Exim Commands

Check emails in mail queue

root@server [~]# exim -bp

Count number of emails in mail queue

root@server [~]# exim -bpc

Count number of frozen emails in mail queue

root@server [~]# exim -bp | grep frozen | wc -l

Delete forzen emails from the mail queue

exim -bp | awk ‘$6~”frozen” { print $3 }’ | xargs exim -Mrm

Count emails for an email account/domain

exim -bp | grep username@domain.com | wc -l

Delete emails for an email account

exim -bp | grep username@domain.com | awk ‘{print $3}’ | xargs exim -Mrm ;

Delete emails sent through scripts

exim -bp | grep “<>” | awk {’print $3}’ | xargs exim -Mrm

Count number of emails in queue for a domain/email account

exim -bp | tr ‘\n’ + | sed -e “s/++/=/g” | tr -d + | tr = ‘\n’ | awk ‘{print $5}’ | sort -n | uniq -c | sort -n

Delete emails for root

exim -bp | grep root@server.hostname.com | awk ‘{print $3}’ | xargs exim -Mrm ;

Check file and directory permissions under present working directory

Below commands can be used to check file and diretcory permissions under the present working diretcory (pwd)

* Check files with permission 755

root@master [~]# find $x -type f -perm 755

* Check files with permission 777

root@master [~]# find $x -type f -perm 777

* Check diretcory with permissions 777

root@master [~]# find $x -type d -perm 777

* Check diretcory with permissions 000

root@master [~]# find $x -type d -perm 000

You can change the permissions to the value you you want to search.

SoftException in Application.cpp:303 UID of script is small than min_uid

If you see the below error in your logs then that means that the script is owned by a user (generally root) instead of the actual user.

SoftException in Application.cpp:303: UID of script “/location/path/.php” is smaller than min_uid

You can receive similar error when you have a wrong group name, in this case instead of UID, you will have GID in the error.

To fix this issue, make sure you have correct user and group ownership for the file that you are trying to access. Ownership can be changed using the below:

chown usernmame:groupname filename.php

2009/12/15

PHP Parse error: syntax error, unexpected T_STRING

If you receive such error in the error logs or in the browser please follow the steps below.

For non suexec/suphp servers

Create a htaccess file under the diretcory and add the code below

php_flag short_open_tag X

For suexec/suphp servers

Copy the server’s php.ini file under the diretcory and find for short_open_tag. Open the php.ini file and change it to

short_open_tag = X

Note :: The solution is valid only if you find the error due to line in your php/html file.
HTML Code:

xml version=”1.0″ encoding=”iso-8859-1″
OR
xml version=”1.0″ encoding=”UTF-8″

how to disable htaccess for domain account

You can disable .htaccess for a particular domain by editing the /etc/httpd/conf/httpd.conf file & following the below mentioned steps:

Open the /etc/httpd/conf/httpd.conf file.
Search for the “AllowOverride None” string.

directory “/”
AllowOverride None
Directory

Append it by:

directory “/home/username/public_html”
AllowOverride None
Directory

Such that it looks like:

directory “/"
AllowOverride None
Directory

directory “/home/username/public_html”
AllowOverride None
Directory

Restart the httpd/apache service on the server

This would disable the .htaccess for that particular account/domain.

Encrpt a file using vi editor

If you want to encrypt a file with vi editor. You can use the option

#] vi -x filename.txt

This will ask a encryption key.

If you try to access file using vi, it will ask for key.

2009/12/13

Unabe to start mysql "MySQL manager or server PID file could not be found!"

Don’t Panic if you get this error when you start, restart or stop your mysql engine.
Try these steps, This will fix your issue.

# ps -ef |grep mysql|awk '{print $2}'|xargs kill -9
# vi /tmp/mysql.sock
# chown -R mysql:mysql mysql.sock
# which mysql

/usr/local/mysql/bin/mysql

# find / -name hostname

/usr/bin/hostname
/usr/ucb/hostname

# ln -s /usr/bin/hostname /usr/local/bin/hostname
# vi /etc/init.d/mysql

find
basedir=
datadir=

change with

basedir=/usr/local/mysql
datadir=/usr/local/mysql/var

# /etc/init.d/mysql start

Starting MySQL
SUCCESS!