/var/lib/php/session cleanup failing

We found one of our servers had exceeded the inode limit of 400,000. Upon investigation, there were about 250,000 files in /var/lib/php/session

Cause
The script plesk-php-cleanuper contains a string ! -execdir fuser {} \, which opens every file in the /var/lib/php/session directory and checks that it is not used by a working process and can be deleted. However, the maximum number of open files is set to 1024 by default.

Resolution
Clear /var/lib/php/session using this script without the checker:
~# [ -x /usr/lib64/plesk-9.0/maxlifetime ] && [ -d /var/lib/php/session ] && find /var/lib/php/session -depth -mindepth 1 -maxdepth 1 -type f -cmin +$(/usr/lib64/plesk-9.0/maxlifetime) -delete
Increase the limit for open files to the required value.
To get the maximum number of open files, run:
~# ulimit -a
open files (-n) 1024
Add ulimit -n 30480 to /etc/cron.hourly/plesk-php-cleanuper:
~#vi /etc/cron.hourly/plesk-php-cleanuper
~#!/bin/sh
~ulimit -n 30480

Re-run the required Cron Job and check that it completes successfully .

http://kb.odin.com/en/119500

sqldumpscript

Here is a good script for backing up all mysql database on a Plesk server. Add a cron entry so that it runs everyday. Change the ‘-mtime +7’ value to determine how many days of backups you will keep.

vi /usr/local/sbin/sqldumpscript
chmod 755 /usr/local/sbin/sqldumpscript


#! /bin/bash

TIMESTAMP=$(date +"%F")
BACKUP_DIR="/var/www/vhosts/mysqldumps/$TIMESTAMP"
MYSQL=/usr/bin/mysql
MYSQLDUMP=/usr/bin/mysqldump
find /var/www/vhosts/mysqldumps/ -maxdepth 1 -type d -mtime +7 -exec rm -rf {} \;

mkdir -p "$BACKUP_DIR"

databases=`$MYSQL -uadmin -p\`cat /etc/psa/.psa.shadow\` -e "SHOW DATABASES;" | grep -Ev "(Database|information_schema)"`

for db in $databases; do
$MYSQLDUMP --force --opt --skip-events --skip-lock-tables -uadmin -p`cat /etc/psa/.psa.shadow` --databases $db | gzip > "$BACKUP_DIR/$db.gz"
done

create crontab entry
39 3 * * * /usr/local/sbin/sqldumpscript

How to block IP address in Linux via ssh:

The following command will drop any packet coming from the IP address 1.2.3.4:

iptables -I INPUT -s 1.2.3.4 -j DROP

or

iptables -A INPUT -s 1.2.3.4 -j DROP

(-I inserts into config, -A appends)

Use the following syntax to block 10.0.0.0/8 on eth1 public interface:
iptables -i eth1 -A INPUT -s 10.0.0.0/8 -j DROP

Use the following command to view:
iptables -L -v

Use the following command to save:
service iptables save

Add virtuozzo to Centos 6

Create partitions as follows:

/ 10GB
/vz remaining space
swap – 2GB + total memory

Login as root, and cd
wget http://download.pvc.parallels.com/47/lin/vzinstall-linux-x86_64.bin
chmod +x vzinstall-linux-x86_64.bin
yum install vzkernel (needed for mkinitrd install – find a better way?)
cd /etc/yum.reposd/
wget ftp://ftp.muug.mb.ca/mirror/centos/6.6/os/x86_64/Packages/compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
rpm -ivh compat-libstdc++-33-3.2.3-69.el6.x86_64.rpm
./vzinstall-linux-x86_64.bin (install pva agent at end, reboot, and wait for startup (around 10 minutes)).
cd
yum update

Additional notes:

Turn off STARTTLS in postfix – 5.7.0 must issue a STARTTLS Command

To disable TLS in the master.cf file for postfix - Change this line in the /etc/postfix/master.cf:

submission inet n - n - - smtpd -o smtpd_enforce_tls=yes -o smtpd_tls_security_level=encrypt -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=rmit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unah_destination

to the following:

submission inet n - n - - smtpd -o smtpd_enforce_tls=no -o smtpd_tls_security_level=may -o smtpd_sasl_auth_enable=yes -o smtpd_client_restrictions=rmit_sasl_authenticated,reject -o smtpd_sender_restrictions= -o smtpd_recipient_restrictions=permit_mynetworks,permit_sasl_authenticated,reject_unah_destination

and then restart postfix:
service postfix stop
service postfix start

 

How to upgrade PHP to PHP 5.4 on CentOS 6 from a remi repository

Parallels Article ID: 115875

1. Install epel and remi repositories:
# wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# wget http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
# sudo rpm -Uvh remi-release-6*.rpm epel-release-6*.rpm

2. Enable remi repository:
# sudo vi /etc/yum.repos.d/remi.repo
In the [remi] section of the file, set the “enabled” option to 1.

3. Upgrade PHP with this command:
# yum install php

4. Set remi section back to 0.