cPanel not starting with Internal Server Error – fix

The problem:

All websites are down with Internal Server Error 500

Symptoms:

Cpanel wasn’t loading with the following error:

Internal Server Error

500

Can’t fork: Cannot allocate memory at /usr/local/cpanel/Cpanel/SafeRun/InOut.pm line 40.
cpsrvd/11.62.0.15 Server at hostname.example.com

How I fixed it?

First of all I was trying to increase this limit by searching for “Max cPanel process memory” in:
“WHM Home » Server Configuration » Tweak Settings”

It was already over 512MB, the default value of 768MB. I increased to 1024MB. The Cpanel restart was unsuccessful.

As last resort I run the following commands:

/scripts/upcp –force

service cpanel restart

The first command will upgrade cPanel even if you got latest version of cPanel, in order to rule out any update inconsistencies.  Depending on the server configuration, this may run for about 10 minutes.

The second command will restart cPanel.

I hope that was helpful for you.

 

Blocking spambots with SCROLLOUT F1 and fail2ban

I asume that you have a fuly functional SCROLLOUT F1 instalation and you want to add spambot blocking feature.
Ad the following line to /etc/apt/sources list

deb http://ftp.debian.org/debian unstable main

Then run

apt-get update
apt-get -t unstable install fail2ban
cd /etc/fail2ban
cp jail.conf jail.local

Edit jail.local

[postfix]
enabled = true
port = smtp,ssmtp
filter = postfix
logpath = /var/log/mail.log
maxretry = 2
bantime = 7200

Edit /etc/fail2ban/filter.d/postfix.conf

failregex = reject: RCPT from (.*)\[\]: 450 4.7.1
reject: RCPT from (.*)\[\]: 554 5.7.1
reject: RCPT from (.*)\[\]: 550 5.1.1
reject: RCPT from (.*)\[\]:\d{5}: 550 5.5.1

Then run
service fail2ban restart
To check if it is working run:

fail2ban-client status postfix
iptables -L -n

You can play with following parameters:
maxretry, bantime, findtime
Do not forget:

  • always edit jail.local instead of jail.conf (this way you don not risk to stay outside if software is updated
  • put your trusted IP addresses in ignoreip

How to recover ext4 from GPT partitioned disk

Hard drive sizes had increased dramatically in last several years, but block device drivers are still outdated. For hard drives more than 1TB currently seems to be an advantage to use GPT instead of legacy MBR partition table. You can see more details at http://en.wikipedia.org/wiki/GUID_Partition_Table .

One of the inevitable disadvantage of GPT is the possibility of corruption by using outdated partition editor like cfdisk, or other disk tools, even without any intention to modify the partition.

It happened recently on one 1.5TB WD Caviar Green with GPT and one ext4 partition full of data.

I tried to repair the superblock using tools like:

  • For partition listing:

fdisk -l

  • To check the filesystem:

fsck.ext4 -v /dev/xxx

  • To list where the superblock backups are stored:

mke2fs -n /dev/xxx

  • To restore superblock from backup:

e2fsck -b block_number /dev/xxx

My story was completly different. It does not work this time. Could work fine if you have a traditional MBR partition table. In case of GPT, TestDisk was the magic software that saved my disk. Read documentation first, think carefully what do you want to do and you have a chance to recover 100% your disk. One note here. TestDisk has an “invasive mode” and a “recovery mode”. In recovery mode you can save a specific file or a disk image. This is not distructive. But you must have a spare disk to save the data. In my case I simply fixed the GPT table and I was lucky. That is why I recommend you to fully read the documentation from TestDisk.

http://www.cgsecurity.org/wiki/TestDisk