Installing suPHP on cPanel

I wrote this tutorial a while back and figured it would be good to post because suPHP is growing more popular as an alternative to phpSuExec. The instructions assume that you are on a Linux cPanel server and are familiar with how to install PHP, but do not want to use EasyApache’s suPHP installer in WHM

Note also that these instructions use suPHP 0.6.1 with a cPanel patch that makes it equivalent to 0.6.2. I personally have had issues with the actual 0.6.2 version installing, so I stuck with the patch.

Next, download suPHP and the apply the patch:

wget http://v-nessa.net/imh_files/suphp-0.6.1.tar.gz
tar -xvzf suphp-0.6.1.tar.gz
cd suphp-0.6.1

wget http://v-nessa.net/imh_files/suphp-0.6.1-cpanel.patch
patch -p1 < suphp-0.6.1-cpanel.patch

Then compile the binary:

./configure –prefix=/usr –sysconfdir=/etc –with-apxs=/usr/local/apache/bin/apxs –with-apache-user=nobody
make && make install

Now locate your PHP binaries for installation. If you previously used EasyApache, you should be able to find them somewhere in your home directory within a directory named ‘cpeasyapache’ or something similar depending on your cPanel version. Otherwise you will need to fetch the PHP sources from php.net if you do not have the original sources you used to compile.

Check the server’s phpinfo file and grab the configure path, then copy and paste it into notepad and remove all the single quotes. You’re basically compiling PHP exactly the same way as it was before, only not as an Apache module.

cd /home/cpapachebuild/buildapache/php-5.2.3
make clean

The only difference is that you need to remove the ‘–with-apxs=’ switch from the configure line. The prefix can stay the same, but it’s recommended to install this in a different directory, like /usr/cgiphp or something.

So technically your configure would look like this:

./configure –prefix=/usr/cgiphp –with-xml –with-mm ………
make
make install

Now check that the installation was successful (should say cli for this one, but cgi will work as well) :

/usr/cgiphp/bin/php -v

PHP 5.2.3 (cli) (built: Aug 3 2007 07:22:58)
Copyright (c) 1997-2007 The PHP Group
Zend Engine v2.2.0, Copyright (c) 1998-2007 Zend Technologies

Download the suphp.conf into /etc, which is the location you specified during the configuration of suphp:

cd /etc
wget http://v-nessa.net/imh_files/suphp.conf

Now you need to edit /etc/suphp.conf and change the handler paths to (lines 47/48):

x-httpd-php=php:/usr/cgiphp/bin/php-cgi
x-httpd-php5=php:/usr/cgiphp5/bin/php-cgi

Check httpd.conf to see if there is already an suphp module setup in the virtualhost entries. If not, set up the apache template to automatically add it for new accounts:

pico /usr/local/cpanel/etc/httptemplates/apache1/default

Under <IfModule mod_php4.c> (exactly as is) add these lines:

<IfModule mod_suphp.c>
suPHP_UserGroup %user% %user%
suPHP_ConfigPath /home/%user%/php
</IfModule>

suPHP_ConfigPath /home/%user%/php specifies the location of the user’s php.ini file, which will be created later. This is completely optional, as it is only necessary if you want to specify where the users’ php.ini files are going to be location (default location is public_html). Recent versions of cPanel already have an suPHP module loader, so you may only have to add the suPHP_ConfigPath line to the suPHP section.

You should do the same for SSL hosts in /usr/local/cpanel/etc/httptemplates/apache1/ssldefault.

Add the following lines to httpd.conf in their appropriate sections:

LoadModule suphp_module libexec/mod_suphp.so
AddModule mod_suphp.c

<IfModule mod_suphp.c>
suPHP_Engine On
suPHP_ConfigPath /usr/local/Zend/etc
suPHP_AddHandler x-httpd-php5
AddHandler x-httpd-php5 .php5
suPHP_AddHandler x-httpd-php
AddHandler x-httpd-php .php .php3 .php4 .phtml
suPHP_AddHandler x-httpd-php-source
AddHandler x-httpd-php-source .phps
<Files *.php5>
suPHP_ConfigPath /usr/cgiphp/lib
</Files>
</IfModule>

It’s also a good idea at this point to disable the loading of the Apache php module, so they can only run as CGI. Comment out these lines:

#LoadModule php5_module libexec/libphp5.so
#AddModule mod_php5.c

If you do the above, comment out the following lines:

#AddType application/x-httpd-php .php
#AddType application/x-httpd-php .php4
#AddType application/x-httpd-php .php3
#AddType application/x-httpd-php-source .phps
#AddType application/x-httpd-php .phtml

The users that already exist on the system should already have suphp directives in their virtualhost entries. If not, you will need to add them manually:

<IfModule mod_suphp.c>
suPHP_UserGroup user user
suPHP_ConfigPath /home/%user%/php
</IfModule>

In this one you actually need to replace ‘user’ with the username and group of the account.

Now you need to fix the first VirtualHost entry as well, which is the website that is displayed when you go to http://server.com on a shared hosting environment. This is the site that is pulled from /usr/local/apache/htdocs and PHP will not work in this directory, because your suphp.conf file defines the docroot to be /home, meaning that suPHP will not execute PHP that is outside of /home. When you find the VirtualHost container for the main IP add the following into that VirtualHost:

<IfModule mod_suphp.c>
suPHP_UserGroup <user> <user>
<Directory /usr/local/apache/htdocs>
suPHP_GlobalDocRoot /usr/local/apache/htdocs
suPHP_DontCheckVHostDocRoot Yes
</Directory>
</IfModule>

For the user, since PHP won’t execute as nobody or root, this needs to be a valid user on the system. Generally it’s best to create a neutral user on the system with no SSH access to be the owner of the htdocs folder. Whatever user you use, you will need to chown the entire htdocs directory to that user (or whatever directory you use as a default. The DontCheckVHostDocRoot part is necessary if you are running this outside of /home.

Last you should create a php folder in /root/cpanel3-skel with a copy of the server’s php.ini file, so new user accounts are created with a php.ini.

The path to the cgi php binary is /usr/local/bin/php, so you want to make sure that it is accessible when called from command line and that suPHP loads the new binary.

ln -s /usr/cgiphp/bin/php-cgi /usr/local/bin/php
ln -s /usr/cgiphp/bin/php-cgi /usr/local/bin/php5
ln -s /usr/cgiphp/bin/php /usr/bin/php
ln -s /usr/cgiphp/bin/php /usr/bin/php5

If you get an error about one already existing, simple delete it and try to link it again.

Now you have to copy the extentions:

cd /usr/cgiphp/lib/php/
mkdir -p extensions/no-debug-non-zts-20060613

pico /usr/local/lib/php.ini

Change the extension_dir value to that of the new folder you created, then copy all the files over:

cp /usr/local/lib/php/extensions/no-debug-non-zts-20060613/* extensions/no-debug-non-zts-2006061/

Depending on the server, the actual extension directory may be different!

Settings for suphp.conf

Suphp.conf lets you control the settings in place for suPHP. The following settings are the recommended in place for shared servers:

logfile=/var/log/suphp.log

The location of the logfile on the server, will be created automatically.

loglevel=warn

What information to describe in the logs. ‘info’ is very broad, but you can also use ‘warn’ to only show warnings.

webserver_user=nobody

What use Apache runs as — this basically indicates what user no php scripts can run as, even ones in htdocs.

docroot=/home

The base directory where php scripts have to be located in order to run, which prevents php scripts from executing from system folders. If a user for some reason needs to execute something from outside of home, you need to make a virtualhost directive containing:

<Directory /usr/local/apache/htdocs>
suPHP_GlobalDocRoot /<path to directory>
suPHP_DontCheckVHostDocRoot Yes
</Directory>

allow_file_group_writeable=false
allow_file_others_writeable=false
allow_directory_group_writeable=false
allow_directory_others_writeable=false

This is the most important for security, specifying the allowable permissions of files and folders by other users than the one owning the script.

If your server currently has accounts on it, you’ll need to run these followup scripts:

/scripts/postsuexecinstall
/scripts/chownpublichtmls

From /home:

find -perm 777 -exec chmod 755 {} \; -print
find -perm 666 -exec chmod 644 {} \; -print
/scripts/fixsuexeccgiscripts

For the php.ini, you’ll also need to copy it from /usr/bin/php.ini into /home/user/php for all users existing on the machine before the installation of suPHP. New user accounts will automatically have this, as long as it you followed the step of copying it to /root/cpanel3-skel/php

If the server is running Fantastico, make sure you set the config to use phpsuexec.

Individually Convert MBOX to MailDir – cPanel

When migrating user emails manually from an mbox server to a maildir server, it’s usually preferred to run a partial conversion using the convert2maildir script. However, in some cases you may want to do a mailbox individually to either do it quickly or to restore it to another location. cPanel has a built-in script for this:

/usr/local/cpanel/3rdparty/mb2md/mb2md -s /home/username/mail/domain.com/user/inbox -d /home/username/mail/domain.com/user/

The first first argument following the ‘-s’ switch will indicate the original mailbox file in mbox format. The second following the ‘-d’ switch will be the location of the folder in which to store the mail folder in it’s converted format.

Unactivated License File Error

When logging into cPanel or WHM you see the following error:

Unactivated License File

To update the license file, run this command:

/usr/local/cpanel/cpkeyclt

This is assuming that the server’s IP has a valid cPanel license.

cPanel commands run from root.

Common cPanel commands that are used in root.

Restart chkservd:

/etc/init.d/chkservd restart

Tail Apache log:

tail -f /usr/local/apache/logs/error_log

Updates the cpanel server software:

/scripts/upcp

Reinstalls exim:

/scripts/exim4

View traffic or if you think a site is being DDoS:

cd /usr/local/apache/domlogs
tail -f targetsite.com

Correct bandwidth issues

/scripts/cleanbw

To fix problem in webalizer that stop updating stats

/scripts/fixwebalizer

Fix everything

/scripts/fixcommonproblems
/scripts/fixeverything

Fixing Mail List MailMan

/usr/local/cpanel/bin/convertmailman2

Reinstall MailMan

/scripts/reinstallmailman

/scripts/fixhome

pico /etc/my.cnf

Edit php.ini (may be in a differant place if you have Zend installed)

pico /usr/local/lib/php.ini

Edit Apache Conf

pico /etc/httpd/conf/httpd.conf

Checking Real Time Top Processes Login to SSH and run

top

Run cpanel backup

/scripts/cpbackup

To try and fix domain controller

/scripts/fixndc

Quotas

/scripts/initquotas – takes a while to run
/scripts/resetquotas
/scripts/fixquotas – takes a while to run

Add a Dns Entry

/scripts/adddns

Install Frontpage Mail Exts

/scripts/addfpmail

Add JavaServlets to an account (jsp plugin required)

/scripts/addservlets

Add a User

/scripts/adduser

Run WHM Lite

/scripts/admin

Add Rlimits (cpu and mem limits) to apache

/scripts/apachelimits

Resync with a master DNS Server

/scripts/dnstransfer

Edit A User’s Quota

/scripts/editquota

Search For Trojans in /dev

/scripts/finddev

Locate Trojan Horses

/scripts/findtrojans

Suggest Usage

/scripts/findtrojans &gt; /var/log/trojans

/scripts/fixtrojans /var/log/trojans

Make Interchange work with suexec

/scripts/fixcartwithsuexec

Fix Most Problems with Interchange

/scripts/fixinterchange

Run on a trojans horse file created by findtrojans to remove them

/scripts/fixtrojans

Run this if a user’s stats stop working

/scripts/fixwebalizer

Fix a broken valias file

/scripts/fixvaliases

Turn on DMA and 32bit IDE hard drive access (once per boot)

/scripts/hdparamify

Re-scan quotas. Usually fixes Disk space display problems

/scripts/initquotas

Turn on SUEXEC (probably a bad idea)

/scripts/initsuexec

Display Ipusage Report

/scripts/ipusage

Terminate an Account

/scripts/killacct

Delete “Security Problem Infested RPMS”

/scripts/killbadrpms

Fix Various Mail Permission Problems

/scripts/mailperm

Attempt to Troubleshoot a Mail Problem

/scripts/mailtroubleshoot

Change a Mysql Password

/scripts/mysqlpasswd

Kill Potential Security Problem Services

/scripts/quicksecure

Rebuild Ip Address Pool

/scripts/rebuildippool

Delete Nasty SSL entry in apache default httpd.conf

/scripts/remdefssl

Restart a Service (valid services: httpd,proftpd,exim,sshd,cppop,bind,mysql)

/scripts/restartsrv?? (example: /scripts/restartsrv httpd)

Syncup Security Updates from RedHat/Mandrake

/scripts/rpmup

Force a webalizer/analog update

/scripts/runlogsnow

Remove non-important suid binaries

/scripts/secureit

Install Frontpage 4+ on an account

/scripts/setupfp4

Return a Simple process list. Useful for finding where cgi scripts are running from

/scripts/simpleps

Suspend an account

/scripts/suspendacct

Syncup Cpanel RPM Updates

/scripts/sysup

Unblock an IP

/scripts/unblockip

UnSuspend an account

/scripts/unsuspendacct

Update Cpanel

/scripts/upcp

Update /scripts

/scripts/updatenow

Create a New Account

/scripts/wwwacct

Awstats to run manually

/scripts/runweblogs account_username

License Not working

rdate -s rdate.darkorb.net

Sometimes such behavior of apache/httpd (taking more and more memory until it dies or crashes the server) can be caused by corrupted MySQL database. Try to do the following:
1) Kill the mysql server
/etc/rc.d/init.d/mysql stop

2) Repair all SQL databases:
myisamchk -r /var/lib/mysql/*/*.MYI

3) Start mysql again:
/etc/rc.d/init.d/mysql start

——————————————————————————-

Restarting cpanel

/etc/rc.d/init.d/cpanel restart

To run your clients stats now

/scripts/runlogsnow

Restart the background proccess that runs the stats for your clients

/usr/local/cpanel/startup

To run your clients stats now

/scripts/runstatsonce

To run one clients stats:

/scripts/runweblogsnow username

Shut down http

httpd stop

Start http with SSL

httpd startssl

Start http

httpd start

/scripts/runweblogs

cPanel FAQ for VPS

From: http://www.cpanel.net/docs/whm/FAQ.htm

Q: I’m having server problems but the problem is not listed below. What should I do?

A: There are two options:

  1. You can search the Knowledgebase in WebHost Manager. The is explained in the support part of this manual.
  2. You can search the CPanel forums – http://support.cpanel.net/

Q: How do I login to Cpanel from a non-GUI?

A: Do the following:

  1. /usr/local/cpanel startup
  2. /etc/rc.d/init.d/cpanel3 restart – This will restart CPanel.

Q: I just got another server, what do I do?

A: If you would like to make your two servers work together, you will need to establish a trust relationship with your primary nameserver – refer to Establishing a trust relationship for more information. You can also transfer your old server’s files to your new server – refer to Transfers for more information.

Q: Proftp will not start it says, ‘unable to determine the ip address of mydomainhere.com’. What do I do?

A: You need to change your hostname to a FQDN (Fully Qualified Domain Name ). A FQDN has a host name, and a domain name which includes a top-level domain, e.g. www.sub.domain.com.

  1. #pico /etc/sysconfig/network
  2. Type hostname www.sub.domain.com
  3. Save changes and quit pico.
  4. Now, add a DNS Zone for yourdomain.com in WebHost Manager.
  5. Add an entry to /etc/hosts for your hostname.

Q: I have a CPanel license but when I login it says ‘Invalid Lisc File’. What’s wrong?

A: There are a couple of possibilities. The date on your server could be improperly synced, your main IP could have changed, or your files could have been corrupted.

  1. First, try to resync your server’s date:

    #rdate -s rdate.darkorb.net

  2. If that does not work, try to update your CPanel license file:

    #/usr/local/cpanel/cpkeyclt

  3. If these do not work contact your distributor so they can update your license

Q: My install keeps saying “waiting for updated to finish”. What should I do?

A: Do the following:

  1. Open another Terminal window and run as root:

    #rsync -av rsync://ftp.cpanel.net/scripts /scripts

  2. /etc/rc.d/init.d/cpanel3 restart – This will restart CPanel.

Q: What types of traffic does the Bandwidth monitor show?

A: The bandwidth monitor watches http, ftp, and pop traffic.

Q: I’ve added accounts in WebHost Manager that aren’t showing up. What’s wrong?

A: Your domain database has not been updated, you need to run:

#/scripts/updateuserdomains

Q: What does Initial Nameserver Setup do?

A: This starts the name and adds it to the list of daemons to be checked.

Q: What should I do about partitioning my drive? What sizes do I need?

A: Refer to Installation for more information.

Q: How do I upgrade using buildapache.sea?

A: Do the following:

  1. SSH into your server.
  2. SU and log in as root.
  3. #wget http://layer1.cpanel.net/buildapache.sea
  4. #chmod 755 buildapache.sea
  5. #./buildapache.sea
  6. Wait for the installer to complete.
  7. Cleanup after the install with:

    #rm -Rf buildapache/

    #rm buildapache.sea

Q: How can I use Cpanel in a non-graphical environment?

A: Do the following:

  1. #/sbin/chkconfig –add xfs
  2. #/sbin/service xfs start

Q: Neomail keeps returning no MD5.so in @INC. What do I do?

A: #/scripts/cleanmd5

Q: How can I fix problems with mail that result from incorrect permissions?

A: #/scripts/mailperm

Q: I’m trying to add FrontPage extensions, or a new account, and I get sd(8,10) write failure, user limit block reached. What do I do?

A: #/scripts/fixquotas

Q: What can fix many common problems?

A: #/scripts/fixcommonproblems

Q: I keep getting a 500 error when trying to use Mailman. What is wrong?

A: Your hostname is not being sent with your e-mail. Do the following:

  1. #/scripts/fixoldlistswithsuexec
  2. If that doesn’t work, try:

    #/scripts/fixmailmanwithsuexec

    #pico /usr/local/apache/conf/httpd.conf – move the last vhost to the first vhost in the file.

Q: What do I do when Mailman wants UID 99 but is getting -1?

A: #/scripts/upcp

Q: My subdomain logs are not being processed. What do I do?

A: Do the following:

  1. #rm -f ~username/tmp/lastrun
  2. #killall -9 cpanellogd
  3. #/usr/local/cpanel/cpanellogd

Q: How do I enable FrontPage on port 443 with ssl?

A: Do the following:

  1. /usr/local/frontpage/version5.0/bin/owsadm.exe -o install -p 443 -m
  2. $domain -t apache-fp -xuser $user -xgroup $group -servconf
  3. “/etc/httpd/conf/httpd.conf”

Q: Neomail complains of no MD5.so in @INC – what do I do?

A: Do the following:

  1. Rebuild Perl using installer from http://cpanel.net/
  2. Just running /scripst/cleanmd5 should do it.

Q: When adding FrontPage, I get sd(8,10) write failure, user limit block reached. What do I do?

A: Run /scripts/fixquotas

Q: How do I fix general mail problems related to permissions?

A: /scripts/mailperm

Q: How do I fix the most common problems?

A: /scripts/fixcommonproblems

Q: How do I fix cgi scripts that are returning a 500 error because of permissions?

A: Do the following:

  1. /scripts/fixsuexeccgiscripts
  2. Read /usr/local/apache/logs/suexec_log for Mailman 500 Error.
  3. /scripts/fixmailmanwithsuexec
  4. Edit /usr/local/apache/conf/htpd.conf and move the vhost it creates (almost always the last one in the file) to be the first vhost.
  5. Restart Apache: /etc/rc.d/init.d/httpd restart
  6. Run /scripts/fixoldlistswithsuexec

Q: What do I do when Mailman wants UID 99 when getting -1?

A: Do the following:

  1. Edit httpd.conf
  2. Make sure Group is set to nobody.
  3. Run /scripts/upcp – that should rebuild mailman with the correct UID/GID.

/scripts/upcp should now detect this and fix it for you automatically.

  1. Turn on SYN Cookies if built into the kernel.
  2. echo 1 >/proc/sys/net/ipv4/tcp_syncookies – at boot time after the /proc file system has been mounted.

Q: How do I troubleshoot Perl scripts?

A: Do the following:

  1. Edit Perl / cgi script – at top of file #!/usr/bin/perl
  2. Use CGI::Carp qw(fatalsToBrowser); – errors should be redirected to browser rather then getting a 500 error.
  3. Also, check if the script runs on the command line – perl -w ./scriptname.cgi – and see if it gives you errors.

Q: What do I do if subdomain logs are not getting processed?

A: Do the following:

  1. rm -f ~username/tmp/lastrun
  2. killall -9 cpanellogd
  3. /usr/local/cpanel/cpanellogd

Q: How do I stop a crontab?

A: Add – >/dev/null 2>&1 – after the entry in the crontab.

Q: What do I do when MySQL gives error of access denied for root@localhost?

A: Make sure root pass is in /root/.my.cnf, this is usually the first root password the box was given when CPanel was installed.

Q: How do I set the /etc/my.cnf file for sites with vbb forums that don’t close connections, thus spawning 500 mysqld’s and hogging all the RAM?

A: Do the following to mysqld:

  • set-variable = max_connections=1500
  • set-variable = max_user_connections=200
  • set-variable = wait_timeout=200
  • set-variable = interactive_timeout=800

Q: What do I do if SpamAssassin is taking up a lot of memory and CPU?

A: The chances are the dbm database has gotten corrupted. Try this:

  1. Find out what user it’s running as with ‘top’.
  2. cd /home/user/
  3. rm -rf .spamassasin
  4. Then mail them a couple of times to see if it fixes the problem.

Q: What do I do if buildapache.sea bombs out with a lot of nasty looking errors?

A: Do the following:

  1. Find out the version (cat /etc/redhat-release).
  2. Find a server running the same version that works.
  3. tar xzvf bits.tgz /usr/include/bits
  4. Copy that to the broken server.
  5. Backup /usr/include/bits somewhere.
  6. tar xzvf bits.tgz from /

Q: What do I do when a Guestbook is not showing anything, I get a blank page when trying to view, and no errors when submitting?

A: Do the following:

chown nobody /home/username/.guestbook

Make sure ‘nobody’ can write to it.

Q: What do I do when all the Perl/CGI scripts that are not running as root (including Interchange) get the error “getgrgid: invalid groupid XXXXX”? From Apache’s error_log …

[Tue Mar 26 09:13:16 2002] [error] [client x.x.x.x] (2)No such file or directory: getgrgid: invalid groupid 32015

[Tue Mar 26 09:13:16 2002] [error] (2)No such file or directory: exec of /home/username/public_html/utility.cgi failed

[Tue Mar 26 09:13:16 2002] [error] [client x.x.x.x] Premature end of script headers: /home/username/public_html/script.cgi

A: Do the following:

chmod 644 /etc/group

If that doesn’t fix it, check permissions on the passwd file and shadow file as well just for good measure.

Q: What are the default locations for Mailman, exim config, exim log, or the exim reject log?

A: The locations are:

  • Mailman lists = /usr/local/cpanel/3rdparty/mailman/lists/
  • Exim Config = /etc/exim.conf
  • Exim Log = /var/log/exim_mainlog
  • Exim Reject Log = /var/log/exim_rejectlog

Q: What do I do when setting up a trust relationship and I get errors about possible security threats and stuff about SSH/known_hosts?

A: Most likely the master server has changed it’s ssl info. The easiest way to remedy this is:

  1. cd /etc/
  2. rm -rf .ssh

Then try setting up the trust relationship again.

Cpanel disk used incorrect showing unlimited or 0MB

You can fix this by running the script  /scripts/fixquotas

is this doesn’t work and you are using Virtuozzo or OpenVZ you will need to set the QUOTAUGIDLIMIT perimeter – this allows the system to allocate user IDs (UID)

e.g (openvz)

vzctl set 101 –quotaugidlimit 1000 –save

then run the scrip “/scripts/fixquotas”

and it should all work.

Troubleshooting

If you’ve done the above and it still doesn’t work (or the value still says 0MB) this may be due to cPanel caching the disk usage results. to disable this:

Select the following in your WHM.

WHM >> Tweak Settings >> System >> “Disable Disk Quota display caching (WHM will cache disk usage which may result in the display of disk quotas being up to 15 minutes behind the actual disk usage. Disabling this may result in a large performance degradation.)”

Easy apache error on a VPS – You are only only allowed to use xx Megabytes of ram! xxx Megabytes is required

Sometimes, you can get the following error on VPS while running easy apache. You can fix by simple following steps.

Login in to main VPS and edit the variable PRIVVMPAGES accordingly

/scripts/easyapache
Use of uninitialized value in pattern match (m//) at /var/cpanel/perl/easy/Cpanel/Easy/Utils.pm line 436.
!! Critical Error (VZ): You are only only allowed to use 90 Megabytes of ram! 512 Megabytes is required. !!

You can also modify the privvmpages values from shell as required. (For OpenVZ users) :

vzctl set 101 --privvmpages 850M:900M --save

WHM : Spamassassin / spamd not working

Spamassassin / spamd not working — solution

1. When restarting exim it will show

[root@server ~]# /scripts/restartsrv_exim
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Starting spamd: Can’t locate Cpanel/SpamAssassinSandBox.pm in @INC (@INC contains: /usr/lib/perl5/5.8.8/i686-linux /usr/lib/perl5/5.8.8 /usr/lib/perl5/site_perl/5.8.8/i686-linux /usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl/5.8.5 /usr/lib/perl5/site_perl/5.8.4 /usr/lib/perl5/site_perl/5.8.3 /usr/lib/perl5/site_perl/5.8.2 /usr/lib/perl5/site_perl/5.8.1 /usr/lib/perl5/site_perl/5.8.0 /usr/lib/perl5/site_perl/5.6.2 /usr/lib/perl5/site_perl) at /usr/bin/spamd line 27.
BEGIN failed–compilation aborted at /usr/bin/spamd line 27.
[FAILED]
Starting antirelayd: [ OK ]

Fix :

/scripts/perlinstaller –force Mail::SpamAssassin
/etc/rc.d/init.d/exim restart

2. When restarting exim it will show

Shutting down spamd: [FAILED] and when starting it will NOT show Starting spamd:

You may have disabled spamd whm > service manager .

so whm will create a file /etc/spamdisable

when you re-eanable spamd through whm > service manager this file may not be deleted.

so delete /etc/spamdisable and restart exim , spamd will function again.

[root@server ~]# service exim restart
Shutting down exim: [ OK ]
Shutting down antirelayd: [ OK ]
Shutting down spamd: [FAILED]
Starting exim: [ OK ]
Starting exim-smtps: [ OK ]
Starting antirelayd: [ OK ]
Starting spamd: [ OK ]
[root@server ~]#

3. Given below is the error when restarting exim.

” Starting spamd: [9128] error: spamd: spamd script is v3.001000, but using modules v3.001001 “

When cpanel update updates spamassassin the updates (executables) will be installed at

/usr/share/scripts/ NOT AT working directory /usr/bin and /etc/rc.d/init.d/ .

solution:

Remove these files from /usr/bin/ and /etc/rc.d/init.d/

rm -f /usr/bin/spamc
rm -f /usr/bin/sa-learn
rm -f /usr/bin/spamassassin
rm -f /usr/bin/spamd
rm -f /usr/bin/sa-update
rm -f /etc/rc.d/init.d/spamassassin

Now copy the updated files from /usr/share/scripts/

cp /usr/share/scripts/spamc /usr/bin/
cp /usr/share/scripts/sa-learn /usr/bin/
cp /usr/share/scripts/spamassassin /usr/bin/
cp /usr/share/scripts/spamd /usr/bin/
cp /usr/share/scripts/sa-update /usr/bin/
cp /usr/share/scripts/spamassassin /etc/rc.d/init.d/

Now restart exim. Done

==========================================================================
OR
================

WRT spamd, have you tried:

/etc/init.d/chkservd restart

If that doesn’t work, try:

/scripts/fixspamassassinfailedupdate

__________________

======================================================

WHM :: Access Denied

When you login to the WHM, you get the following error:

    Access Denied
    Functions in cPanel / WHM are available only directly through the cPanel and WHM interfaces or through our XML API. It appears that this request is coming from a referring site and might be malicious.

When XSRF attacks is enabled in the WHM, the cPanel will validate the referrer for every page. If the referrer matches one of the domains, the server ‘s hostname , or any of the server’s IPs, then the request is allowed through. If the referrer does not match, then the user is shown the “Access Denied” page with the request information and given the option to proceed.

To get rid of that page:

  1. 1. Login to the WHM >> Server Configuration >> Tweak Settings
  2. Scroll down the page (about half way down) and find “Security”, un-check the checkbox to deactivate “XSRF attacks”
  3. Click on the button Save at the bottom of the page.
    DONE