How to restore a crashed directadmin server

Please follow the procedure to restore a crashed directadmin server. It is based on Centos.

1) Install direactadmin and configure apache, php, mysql with same version/settings as in old server

2) Mount the old HDD under /old . If you have /home or any other partition in old server , please mount it under /old/

#!/bin/bash
cp -avprf  /old/etc/passwd  /etc/
cp -avprf  /old/etc/group /etc/
cp -avprf  /old/etc/shadow /etc/
cp -avprf  /old/etc/gshadow /etc/
cp -avprf  /old/etc/my.cnf /etc/
cp -avprf  /old/etc/exim*  /etc/
cp -avprf  /old/etc/hosts  /etc/
cp -avprf  /old/etc/httpd/conf/* /etc/httpd/conf/
cp -avprf  /old/etc/named.conf /etc/
cp -avprf  /old/etc/proftpd.conf /etc/
cp -avprf  /old/etc/proftpd.passwd /etc/
cp -avprf  /old/etc/proftpd.vhosts.conf /etc/
cp -avprf  /old/etc/resolv.conf /etc/
cp -avprf  /old/etc/system_filter.exim  /etc/

cp -avprf  /old/usr/local/directadmin/conf  /usr/local/directadmin/
cp -avprf /old/usr/local/directadmin/plugins /usr/local/directadmin/
cp -avprf /old/etc/mail  /etc/
cp -avprf /old/etc/virtual /etc/
cp -avprf  /old/var/named /var/
cp -avprf  /old/var/spool/cron /var/spool/
cp -avprf  /old/var/spool/virtual /var/spool/
cp -avprf  /old/var/www /var/
cp -avprf  /old/usr/local/directadmin/data /usr/local/directadmin/

cp -avprf /old/var/lib/mysql  /var/lib/
cp -avprf /old/home/*  /home/

3) Now compile apache and php using the directadmin custom build script

4) Test your websites

How to install Cloud Linux In Centos cPanel Server

How to Convet Centos to Cloud Linux In cPanel Servers

Options 1 : IP address-based CloudLinux license

If your server have an IP based Licenses. Then you need to run the following script .

# /usr/local/cpanel/scripts/upcp -- force

This will automatically convert your Centos to Cloud Linux

Now reboot your server into Cloud liunx

# reboot

Option 2 : CloudLinux license key

If you own a key based license from Cloud linux then you need to do it as follows,

# wget http://repo.cloudlinux.com/cloudlinux/sources/cln/cldeploy
# sh cldeploy -k $key     #Replace $key with your license key. 
# /usr/local/cpanel/scripts/upcp -- force
# reboot

Memcached Server Installation for Vbulletin and wordpress

Memcached is a memory caching system. This will help to increase speed of your vbulletin or wordpress wesites. You can install it easily as follows,

Download the memcached server from http://memcached.org/

 wget -c  http://memcached.googlecode.com/files/memcached-1.4.15.tar.gz
 tar -xzf  memcached-1.4.15.tar.gz
 cd memcached-1.4.15/
 yum -y install libevent libevent-devel
 ./configure --prefix=/opt/memcached
 make
 make install

Now install init script . I wrote an init script for redhat and centos servers , you can use it to start/stop memcached.

 wget -c http://files.syslint.com/conf/memcached.redhar.rc.txt
 mv -f memcached.redhar.rc.txt /etc/init.d/memcached
 chmod 750 /etc/init.d/memcached
 mkdir /var/run/memcached
 /etc/init.d/memcached start
 chkconfig --add memcached
 chkconfig memcached on

Install php-pecl memcache

Download the latest stable memcached from http://pecl.php.net/package/memcache

wget -c http://pecl.php.net/get/memcache-2.2.7.tgz
 tar -xzf  memcache-2.2.7.tgz
 cd memcache-2.2.7/
 phpize
 ./configure
 make
 make install

Now restart apache and create a phpinfo page and test whether the memcache options is showing or not. If it is there then you installed php module . If not you need to check your php.ini settings and enable memcache module

Vbulletin Configuration

Edit the Vb configuration file includes/config.php and uncomment the following lines

$config['Datastore']['class'] = 'vB_Datastore_Memcached';
$i = 0;
// First Server
$i++;
$config['Misc']['memcacheserver'][$i]           = '127.0.0.1';
$config['Misc']['memcacheport'][$i]                     = 11211;
$config['Misc']['memcachepersistent'][$i]       = true;
$config['Misc']['memcacheweight'][$i]           = 1;
$config['Misc']['memcachetimeout'][$i]          = 1;
$config['Misc']['memcacheretry_interval'][$i] = 15;

Now restart apache server . Your vbulletin now works with memcached. You can see the performance difference within 1 to 2 hours.

WordPress Configuration

You may just install the wordpress memcached plugin and configure it from wordpress admin panel

how to disable open_basedir protection in plesk control panel

This small article tell you how to disable open_basedir protection in your plesk server. For example you own a domain say foo.com in your plesk server. Then do the following steps,

1) Create a vhost.conf as follows,

 touch  /var/www/vhosts/foo.com/conf/vhost.conf

2) Now edit this vhost.conf and add the following lines.

 
php_admin_value open_basedir none

3) Now tell psa to reconfigure httpd settings and restart httpd

   /usr/local/psa/admin/sbin/websrvmng -v -a

Now you can create a phpinfo page and test it .

How to upgrade php in plesk

It is easy to upgrade php in plesk as follows,

wget -q -O - http://www.atomicorp.com/installers/atomic |sh
yum upgrade php-cli -y
yum upgrade php-devel -y
/etc/init.d/psa stop
/etc/init.d/psa start
/etc/init.d/httpd restart

Thats it 😀

PHP Warning: PHP Startup: apc.shm_size now uses M/G suffixes, please update your ini files

You may see this error after the installation of APC . To fix this please the following changes in apc.ini .

change it from:

apc.shm_size=512

To:

apc.shm_size=512M

You may need to specify “M” for MB or “G” for GB to solve this issue.

cPanel + ERROR: This RRD was created on another architecture

Your will get this error during cpanel account transfer time  or with cpanel package account script. To fix this issue do the following bash script

#!/bin/bash
cd /var/cpanel/bandwidth
for i in `/bin/ls ./*.rrd`
do

/usr/local/cpanel/3rdparty/bin/rrdtool dump $i > $i.xml

if [ -s "$i.xml" ]
then
        echo "$i.xml have valid  data."
        /usr/local/cpanel/3rdparty/bin/rrdtool restore -f $i.xml $i

else
        echo "$i.xml is empty. So not possible to restore"    
        rm -vf $i $i.xml
fi

done