Showing posts from April, 2012

Parse error: syntax error, unexpected T_STRING

Sometimes your website is loading with the following error: ~~~~~ Parse error: syntax error, unexpected T_STRING ~~~~~ If you are getting the above error on your website, you need to turn off the PHP module 'short_open_tag' in your 'php.ini' file. short_open_tag = Off Note: 'short_open_tag' tells PHP whether the short form ( <? ?> ) of PHP's open tag should be allowed. If you want to use PHP in combination with XML, you can disable this option in order to use <?xml ?> inline. Otherwise, you can print it with PHP, for example: <?php echo '<?xml version="1.0"?>'; ?> . Also, if disabled, you must use the long form of the PHP open tag ( <?php ?> ). You can do it either in your custom 'php.ini' file present under "public_html" directory or in global 'php.ini' file. You can get the global 'php.ini' file location u

suPHP rules

suPHP is an alternative to phpsuexec. It is an Apache module that lets PHP scripts run as the owner of the script, instead of the web server. This offers many security and usability enhancements to the world of PHP web serving. suPHP does not allow .htaccess files to set variables for PHP. php flag must now be set in php.ini file. Mainly, when users create and modify files in their directory with PHP scripts, they don't need to make those files world-writable (777). The 4 rules for PHP to work fine on suphp enabled servers are: ================= 1. The .htaccess file should not contain any php config values.. Such php values should be specified in php.ini. 2. Permissions for all the php files must be 644. 3. Permissions for all web directories must be 755. 4. Ownership must be of the user and not nobody or any other user. ================= Thank you.

Easyapache: Not a HASH reference

Easyapache is showing following error: Not a HASH reference at /var/cpanel/perl/easy/Cpanel/ line 335 Fix: Generally this issue occurs as parts of the RPM packages like gcc and binutils is broken, which prevented /scripts/checkperlmodules from running. You need to reinstalled those packages using yum, and then run /scripts/checkperlmodules, which makes sure that all Perl modules required by cPanel are installed and up to date. I am optimistic that after installing those packages, /scripts/checkperlmodules will fix EasyApache. Thank you.

Error from park wrapper

Sometimes you are not able to add addon or parked domain in your cPanel. You may receive the following error: 'Park Wrapper Error' - Error while adding Addon or Park domain in cPanel! Error from park wrapper: is already configured." This error occurs when the domain is not added correctly and a entry is left somewhere. Verify the following files and remove the entry of domain that you are not able to add: 1. vi /var/cpanel/users/cpanelusername (remove the domain entry) 2. cd /var/named/ (delete the domain.db file) 3. vi /etc/named.conf (remove the zone entry) 4. vi /etc/httpd/conf/httpd.conf (remove virtual host entry) 5. vi /etc/localdomains (remove domain entry) 6. vi /etc/userdomains (remove domain entry) 7. cd /etc/valiases/ (remove domain alias file) 8. cd /etc/vdomainaliases (remove domain alias file) 9. cd /etc/vfilters/ (remove domain file) Any entry left in one of these files will not allow you to add the Addon domain. Afte

Error: Segmentation fault (core dumped)

Perl scripts are not working when executed as user. It is happening in many cPanel servers. Error: ======== root@server[/etc/ssh]# su - reseller reseller@server [~]# vi reseller@server [~]# perl Segmentation fault (core dumped) ======== This is a known issue when cPanel's Fork Bomb Protection is enabled. The bug is triggered by behavior in glibc (the GNU libc libraries, which are provided by Redhat / CentOS). Fix: Log into WHM as root, click "Shell Fork Bomb Protection" and disable that feature, and things should continue to work fine. However this issue has been fixed in cPanel new version (The case ID # is 52960). You can visit the fllowoing link to verify: Thank you.

Error: queueprocd failed

Issue: Sometime you are getting following cPanel mail regularly: ~~~~~~~~~~~~~~~ queueprocd failed @ Mon Apr 21 04:03:19 2012. A restart was attempted automatically. Service Check Method: [check command] Number of Restart Attempts: 26 Cmd Service Check Raw Output: queueprocd is not running Cpanel::CacheFile::FileLocker::_read_lock_file(Cpanel::CacheFile::FileLocker=HASH(0xac9b20), '/var/cpanel/taskqueue/servers_sched.yaml.lock') called at /usr/lib/perl5/site_perl/5.8.8/Cpanel/CacheFile/ line 56 ~~~~~~~~~~~~~~~ Fix: Remove or move the lock file "servers_sched.yaml.lock" at /var/cpanel/taskqueue/ location, then restart queueprocd at that point: ~~~~~~~~ /usr/local/cpanel/libexec/queueprocd ~~~~~~~~ This should fix the issue.


1] Install Fantastico with root login using WHM Run following commands to install Fantastico: $ cd /usr/local/cpanel/whostmgr/docroot/cgi $ wget -N http:// $ tar -xzpf fantastico_whm_admin.tgz $ rm -rf fantastico_whm_admin.tgz Now go to WHM, login as root and follow the link WHM -> Add-Ons -> Fantastico De Luxe WHM Admin. One need to complete the installation by following the screens. Note: If you will receive a license error and you are sure that your package includes Fantastico, then contact your server support and have them license the server IP. 2] Fantastico link disappears in cPanel: Run following commands to fix the issue: $ mkdir /usr/local/cpanel/base/frontend/x/cells $ mv /usr/local/cpanel/3rdparty/fantastico/xskin.html usr/local/cpanel/base/frontend/x/cells/fantastico.html $ ln -s /usr/local/cpanel/base/frontend/x/cells /usr/local/cpanel/base/frontend/x2/cells 3] Uninstall Fantastico on Serv

Commands to check spamming in POSTFIX mail server

1. To see the mail queue: # mailq 2. To flush the mail queue: # postfix flush  OR # postfix -f 3. To remove all mails from the queue: # postsuper -d ALL 4. To remove all mails in the deferred queue: # postsuper -d ALL deferred 5. To delete all queued messages from or to the domain called # ./ 6. To delete all queued messages that contain the word "abc" in the e-mail address: # ./ abc 7. To know the number of messages sitting in the deferred queue: # find /var/spool/postfix/deferred -type f | wc -l 8. To get a sorted list of the accounts that have the most mail in the queue. This usually means a maximum of 2 or 3 spammers at the end of the list: # mailq|grep ^[A-F0-9]|cut -c 42-80|sort |uniq -c|sort -n|tail Thank you.

How to send mails using Telnet command

Sometimes you need to check if open relay is allowed in the server or else to see if there is any issue with the mail server. You can check this to send mails using Telnet command. You need to follow the steps mentioned below to send mail through Telnet command. 1 Open the cmd prompt. (Start -> Run or press win key + R, then type cmd and press OK ) 2 Type telnet 25 (where "" is the name of the smtp (outgoing) server of your email provider, such as This can be found by checking your account info in the program you normally use for email. 3 Type HELO (Or "HELO") 4 Type MAIL 5 You may get a message saying "250 ok" 6 Type RCPT,,, etc. 7 again, You may get a message saying "250 ok" 8 To write the message, type DATA and press Enter. On the first line

Spamming through SFTP connection

Sometimes spamming is done through SFTP connection. In such case you need to check spamming using the following steps: 1. Grep the ssh process and find out the process_id as follows: ================================ # ps -aux |grep ssh xyz  17853  0.1  0.0  95048  2104 ?        S    18:08   0:08 sshd: xyz@notty root     17860  0.0  0.0   5892   700 ?        Ss   18:08   0:00 jailshell (xyz) [17870] ell -c /usr/libexec/openssh/sftp-server xyz  17870  0.0  0.0  53892  1992 ?        S    18:08   0:00 /usr/libexec/openssh/sftp-server ================================= From the above result, you can see that an account xyz has established the sftp access. 2. You now need to trace this process by: ================================= strace  -p 17853 ================================= 3. If you can see some process in this pid, execute the command given below: ================================= strace -o output_log  -p 17853 ================================= You will now get a file output_log

Database error: connection failed in roundcube

DATABASE ERROR: CONNECTION FAILED Make sure the MySQL password of Roundcube is correct as follows: root@server[~]$ grep db_dsnw /usr/local/cpanel/base/3rdparty/roundcube/config/ $rcmail_config['db_dsnw'] = 'mysql://roundcube:xyz@localhost/roundcube'; The password in this case is set in the config as: "xyz". See if the hash matches what is set for the user: root@server[~]$ mysql mysql> use mysql; mysql> select PASSWORD('xyz'); mysql> select * from user where User = 'roundcube'; mysql> update user set Password = PASSWORD('xyz') where User = 'roundcube'; If the above did not fix it, try to update. Update RoundCube. root@server[~]$ mysqldump roundcube > /path/to/backup.sql root@server[~]$ /usr/local/cpanel/bin/update-roundcube --force root@server[~]$ mysql roundcube < /path/to/backup.sql The issue should be fixed now. :-) Thank you.

Error: exim: [535 Incorrect authentication data !=2]

In every 5 minutes, this e-mail is generated the report that Exim has restarted with the following error: exim: ** [535 Incorrect authentication data != 2] Cmd Service Check Raw Output: Here is the fix. 1. Go to the directory "/var/cpanel/serviceauth/". # cd /var/cpanel/serviceauth/ 2. Remove the directory exim # rm -rf exim 3. Restart Cpanel. # /etc/rc.d/init.d/cpanel restart Done. The folder exim will be recreated. That should fix the issue. :-) Thank you.

HowTo: Enable extended logging for exim

When troubleshooting mail or attempting to discover the source of spam originating from your server, it is often useful to enable extended Exim logging. You can enable extended logging for exim though your shell prompt as well as through WHM interface. I am giving the steps for both ways one by one: 1. Through shell prompt: 1. Open exim.conf 2) Find this: hostlist auth_relay_hosts = * 3) After hostlist auth_relay_hosts = * add the following: log_selector = +address_rewrite +all_parents +arguments +connection_reject +delay_delivery +delivery_size +dnslist_defer +incoming_interface +incoming_port +lost_incoming_connection +queue_run +received_sender +received_recipients +retry_defer +sender_on_delivery +size_reject +skip_delivery +smtp_confirmation +smtp_connection +smtp_protocol_error +smtp_syntax_error +subject +tls_cipher +tls_peerdn 4) The final result should look like this hostlist auth_relay_hosts = * log_selector = +address_rewrite +all_parents +arguments +connecti

Disabling open relay on cPanel server

Sometimes your server might face mail problems as the server is configured for open relay. Open Relay allows SMTP server to be configured in such a way that it allows anyone on the Internet to send e-mail through it. This can blacklist the server's IP address. To disable Open Relay on the cpanel server you can follow following simple steps: 1. Login to WHM. 2. Navigate to WHM >> Main >> Tweak Settings >> Initial default/catch-all forwarder destination. 3. Set this setting to "Bounce/Fail". This should turn off the open relay on the server. Enabling "Bounce”/"Fail" module is usually the best choice if you are getting mail attacks. Thank you.

Sample PHP script to send emails

Sometimes you need to check if your server is able to send emails through PHP. Here is a sample PHP script to send emails: <?php $to = ","; $subject = "Test mail"; $message = "Hello! This is a test email message."; $from = ""; $headers = "From:" . $from; mail($to,$subject,$message,$headers); echo "Mail Sent."; ?> Thank you.

Limit maximum number of emails per user

You can limit maximum number of emails that can send by a web site in cpanel. This is useful when some of your users send large number of mails. Here, we will limit number of emails send by a domain name. 1. Login to server as root using SSH utility. 2. Go to the directory '/var/cpanel/users' using the 'cd' command as follows: root@server[~]# cd /var/cpanel/users 3. Open the file 'username' and edit "MAX_EMAIL_PER_HOUR" and "" as per your need: root@server[/var/cpanel/users]# vi username MAX_EMAIL_PER_HOUR=150 4. Save and quit the file. 5. Now we need to run the following command to update our changing: root@server[~]# /scripts/update_email_limits username Done. :)

Scripts to check spamming in Exim mail server

1. To check the number of emails present in the queue: # exim -bpc 2. To check the emails present in the queue with the mail id and sender ID: # exim -bp # exim -bp | less 3. To view the header of a particular email using mail ID: # exim -MvH mail_id 4.  To view the body of a particular email using mail ID: # exim -Mvb mail_id 5. To view a message's logs: # exim -Mvl mail_id 6. To trace path: # exim -d -bt 7. To get sorted list of email sender in exim queue: # exim -bpr | grep "<" | awk {'print $4'} |cut -d "<" -f 2 | cut -d ">" -f 1 | sort -n | uniq -c| sort -n 8. To check the script that will originate spam mails: # grep "cwd=" /var/log/exim_mainlog|awk '{for(i=1;i<=10;i++){print $i}}'|sort| uniq -c|grep cwd|sort -n 9. If we need to find out exact spamming script. To do this, run following command: # ps auxwwwe | grep user | grep --color=always "/home/user/

Error: pcfg_openfile: unable to check htaccess file, ensure it is readable

Error message: Following error message appears in apache error logs while accessing the domain in browser: ~~~~~~~~ Permission denied: /home/user/public_html/.htaccess pcfg_openfile: unable to check htaccess file, ensure it is readable   ~~~~~~~~ The issue is not with the permission of .htaccess file. The issue is with Frontpage extension. Steps to fix the issue: 1. Login to cPanel of the domain having issue. 2. Click on "FrontPageExtensions" under "Advanced". 3. Click on Reinstall extensions button beside domain you are having issue. Now the issue should be fixed. :)

Disable Mod-Security only for the perticular file or directory

You can disable mod-security by using two ways: 1) You can add following rules in .htaccess file ~~~~~~~~~~~~~~ #For mod secuity 2 <IfModule mod_security2.c> <LocationMatch “/index.php“> SecRuleRemoveById 12345 </LocationMatch> </IfModule> ~~~~~~~~~~~~~~ #For mod secuity 1 <IfModule mod_security.c> <Location /index.php> SecFilterRemove12345 </Location> </IfModule> ~~~~~~~~~~~~~~ or 2) You can disable it by using http.conf file. open the httpd.conf file and search the and remove the conment from below line # Include “/usr/local/apache/conf/userdata/username/*.conf” to Include “/usr/local/apache/conf/userdata/username/*.conf” then create the directory '/usr/local/apache/conf/userdata/username/' using the following command: mkdir -p /usr/local/apache/conf/userdata/username/ vi /usr/local/apache/conf/userdata/username/ and edit the mod-securit

How to block certain IP address from accessing your website

To block certain IP address from accessing your website, just create a file with name ".htaccess" at your root directory with the content below:- order allow,deny deny from allow from all If you want to block multiple IP address using ".htaccess" simply add one IP address per line as below:- order allow,deny deny from deny from deny from allow from all You can even block a network range IP using ".htaccess":- order allow,deny deny from 129.0.0 allow from all Thank you.

How to enable temporary URL in cPanel

You may need to enable temporary URL while the actual domain resolves. To enable temporary URL do the following steps. Log in into WHM Navigate to ' Security Center' >> "A pache mod_userdir Tweak" Uncheck “ Enable mod_userdir Protection ” if you want to enable temporary URL. You can enable by user account. also. In that case you need to check the checkbox near the user account in below list.  Thank you.

How to set up URL Frame in cPanel server?

URL frame forwarding is not provided in cPanel. But you can set up this for your domain on your own. For that you will need to create a simple html page with the following code:  <HTML> <HEAD> <TITLE> Type here anything you want </title> <!-- This text will be shown as name of the page --> </HEAD> <FRAMESET SIZE="100%,*"> <FRAME SRC=" /folder/"> </FRAME> </FRAMESET> <BODY> </BODY> </HTML>   Save changes to the file and you are done. :) Please note that you need to name this page index.html if it is the first (or the only) page for your website. Thank you.

How to add a wildcard DNS record?

Wildcard subdomains are useful when you wish to redirect all visitors to your main website regardless of what subdomain they access your website through. W ith wildcard subdomains it won't matter whether someone accesses your site through or . Here are three ways to enable wildcard subdomains for your website: 1) The easiest way to enable wildcard subdomains is to create a subdomain * . You can do this from their cPanel > Subdomains. You should make sure that the subdomain's Document Root is public_html . 2) If you are using cPanel and you have access to WHM, you can log in to WHM and go to Edit DNS Zone . Select the domain you wish to modify from the list of available websites. Under Add New Entries Below this Line you should fill in the fields so that they look like: *                       14400            IN                     A      where is the IP address of t

How to install APC for PHP on Linux

APC is the Alternative PHP Cache which is a free, open, and robust framework for caching and optimizing PHP intermediate code. It can be installed by the following steps. Step1. Download the latest stable version of APC. #wget Step2. Untar the file #tar -xvf APC-3.1.9.tgz #cd APC-3.1.9 Step3. Run the following command: #phpize Step4: You then configure APC, telling it where the executable file 'php-config' is. If you don't know where this is, then do this: #whereis php-config Step5. The above command will show 'php-config' path. Now configure APC using the command like so: #./configure --enable-apc --enable-apc-mmap --with-apxs --with-php-config=/usr/bin/php-config Step6: You need to compile it using the following commands: #make #make install Step7: Restart Apache #/etc/init.d/httpd restart APC has been installed now. :-) You can check using the following command: #php -m | grep -i apc Thank you.

How to change cpanel theme from RVSkin to x3

1. Goto your cPanel running RVSkin. 2. Now paste this in the same address bar of cPanel: P.S:- Change "" to the actual domain name. Done. :)