Monday 26 November 2012

Cpanel account Migration using Scripts


First you have to create a file containing the usernames of the accounts in the old server(users.txt).
================================
Take Backup(script.sh)

for i in `cat /home/users.txt`;
do /scripts/pkgacct $i;
done
================================
To move backup

scp cpmove-*.tar.gz root@IP(New server):/home/

passwd:
================================
rm -rf cpmove-*

=================================
In new Server:

restore Backup

for i in `cat /home/user.txt`;
do /scripts/restorepkg $i;
done

-================================
rm -rf cpmove-*

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

Install APC on CentOS 5


APC (Alternative PHP Cache) is a free and open cache for PHP. It’s a free framework for caching and optimizing PHP intermediate code.
In other words, it could improve your php website performance

Here are some instructions on how install APC on CentOS 5 :

yum install php-pear php-devel httpd-devel pcre-devel apr-devel

pecl install apc

Create the file : /etc/php.d/apc.ini

extension = apc.so
apc.enabled=1
apc.shm_segments=3
apc.optimization=0
apc.shm_size=128
apc.ttl=7200
apc.user_ttl=7200
apc.num_files_hint=1024
apc.mmap_file_mask=/tmp/apc.XXXXXX
apc.enable_cli=1
apc.slam_defense=Off
apc.cache_by_default=1

Then restart Apache:
service httpd restart


Upon receving errors :
====================================
/usr/local/src/APC-3.1.5/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:419: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c:420: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c: In function 'apc_regex_match_array':
/usr/local/src/APC-3.1.5/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:452: error: 'apc_regex' has no member named 'preg'
/usr/local/src/APC-3.1.5/apc.c:453: error: 'apc_regex' has no member named 'nreg'
/usr/local/src/APC-3.1.5/apc.c:453: error: 'apc_regex' has no member named 'nreg'
make: *** [apc.lo] Error 1
======================================

Fix : yum install pcre-devel


Now to see if it is really working, create a file info.php in your DocumentRoot.

<?php
phpinfo();
?>

Start your browser and go to your.server.xx/info.php.
You’ll see something like this:

Now to see if it is really working, create a file info.php in your DocumentRoot.

<?php
phpinfo();
?>

Start your browser and go to your.server.xx/info.php.
You’ll see something like this :


Upon receiving the error :
================================
pecl/apc is already installed and is the same as the released version 3.1.9
install failed
==================================

Try : pecl install -f apc
             or
You can do a manual installation
==================
cd /usr/local/src
wget http://pecl.php.net/get/APC-3.1.12.tgz
tar -zxvf APC-3.1.12.tgz
cd APC-3.1.12
phpize
./configure
make && make install
 
 
 







Softaculous Installation


Before starting the installation make sure ionCube Loaders are enabled.
Please make sure that the Ioncube loader is selected for the backend copy of PHP

Enabling Ioncube
===============

 Login to WHM (root)
 Go to Server Configuration -> Tweak Settings -> PHP
 Select ioncube from the radio-button for cPanel PHP loader.
 Click on Save button.
 That's it. This will enable Ioncube for you in 3rd party PHP binary
 

 Now SSH to your server and enter following commands : 
 wget -N http://files.softaculous.com/install.sh
 chmod 755 install.sh
  ./install.sh
 
Now go to : WHM > Plugins (Add-Ons on older versions than 11) 
> Softaculous - Instant Installs
 
 
 



Friday 9 November 2012

Installing Modules using /scripts/easyapache



Inorder to activate the modules such as GD Library,Ironcube loader,modsecurity,curl,zendcube loader,etc.
You can use /scripts/easyapache on the servers in which Cpanel is installed

Login to your server and type :

/scripts/easyapache

Select a profile to load and click "Start customizing based on profile"

Select the Apache version and click next step.

Select the Major PHP Version and click next step.

Select the PHP Minor Version and click next step.

Scroll down to the bottom and click "Exhaustive Options List". (If the module you are needing isn't listed)

Select the modules you wish to add then scroll to the bottom and click "Save and Build".

Installation of ZendOptimizer


If you wanted to install Zend Optimizer use the below command.


Inorder to check the module is available :
/scripts/phpextensionmgr list
Available Extensions:
EAccelerator
IonCubeLoader
Zendopt
SourceGuardian
PHPSuHosin

Installing the module :
/scripts/phpextensionmgr install Zendopt
Installing Zendopt
Determining PHP version
Installing Zend Optimizer binary
Activating Zend Optimizer in /usr/local/lib/php.ini
Zend Optimizer activated
Skipping install to /usr/local/php4, missing php.ini

Installation of Cpremote



cPremote is a remote incremental backup and it will use cPanel modules itself for taking backups to your remote backup server over ssh.

A growing number of clients are choosing to use CP Remote backup script as a ‘low load’ alternative to the standard Cpanel FTP backups. CP Remote is much more cost effective than the other backup solution we offer (R1 Soft) although it is a ‘time stamped’ solution and not a continuous data protection solution.

If you are happy to have off server backups taken nightly at a pre-defined time (usually 1am) then this backup solution could be for you. Quickly have your data restored to any cpanel server in the event of data loss.

It uses Rsync which means it is a very efficient way of working. Your first backup will take the longest as it copies all files from your server to the backup space you buy from us. The second backup only backs up what has changed so it is a very efficient solution in terms of bandwidth. All your data is backed up with this solution including Public_html folder, My SQL databases as well as email folders.

The Cpanel plug in works perfectly and allows you to check your backups and also restore quickly and easily from within an easy to use web based interface.

» Requirements:
You need a Linux cPanel server running latest stable release of cPanel(11.32 or higher) .

Need cpphp /var/cpanel/3rdparty/bin/php

» Install cPremote
Download the tar file cpremote.X.Y.tar.gz from https://portal.syslint.com/downloads.php where X.Y is the latest version.
tar -xzf cpremote.X.Y.tar.gz
# cd cpremote/
# ./install.sh

» Configure Backup
Go to WHM->Plugins -> cPanel Remote Backup -> Configure Backup . Here you can configure backup settings.

» Configure Backup Public Key in remote ssh account
Go to WHM->Plugins -> cPanel Remote Backup -> Your Backup Public Key and follow the procedure mentioned in that website to setup public key for backup ssh account.

» How to run a manual backup update
You may need to run the following script.
/scripts/cpremotebackup

» How to change the backup time
You may change the following cron time
0 1 * * * /scripts/cpremotebackup

» How to enable backup for Multiple Home folder
You may need to add your home folders mount point names n to the file /etc/cpremote/userhomes.txt. See an example below, It is the default settings.
/home
/home1
/home2
/home3
This option will enable multiple home folder feature.

» How to restore a cPremote Backup
1. A full account from daily , weekly, monthly and 7 days backups
2. Restore email fodler , home fodler , document root , individual files and fodlers, individual databases
3. cPanel end user interface for restoring backups
4. /scripts/cpremoterestore feature rich command line utility

» Restore Backups from Plugin Page
You may need to goo WHM -> Plugins -> cPanel Remote Backups -> Restore A backup , then select the cpanel accounts and backup option for restore.

» Restore Backups from server shell
If you need to restore a cPanel account say CPUSER from the backups see , the example commands below,

Restore email folder of cpanel user CPUSER from the daily backups
/scripts/cpremoterestore --user=CPUSER --from=daily --type=mail

Restore Document root from weekly backup for CPUSER
/scripts/cpremoterestore --user=CPUSER --from=weekly --type=www

Restore the complete home folder of CPUSER from monthly backup
/scripts/cpremoterestore --user=CPUSER --from=monthly --type=homefolder

Restore a full account from daily backup
/scripts/cpremoterestore --user=CPUSER --from=daily --type=full


Installing Ngnix on Cpanel



Nginx can be used to serve static pages on a server running cPanel with Apache. Apache will handle the dynamic content for PHP and cgi scripts, while nginx will handle the static pages such as .htm and .html

Install nginx
 1. Make a copy of your httpd.conf file 
     cp /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.bak

 2. Go to WHM > Tweak Settings and change the Apache port:
    The port on which Apache listens for HTTP connections. Specifying a specific IP will prevent   Apache from listening on all other IPs. (default: 0.0.0.0:80)  To:  0.0.0.0:8081 
     Do not change the https port listed.
     Click the “Save” button.

3. Grab a copy of the nginx installation script:
     mkdir /root/cpacct && cd /root/cpacct
     cd /usr/local/src
     wget http://nginxcp.com/latest/nginxadmin.tar 
     tar xf nginxadmin.tar
     cd publicnginx
    ./nginxinstaller install

 If you receive this error when trying to install:
  access key doesn't exist create it in WHM
  Then go to WHM > Cluster/Remote Access > Setup Remote Access Key and click on the “Generate      New Key” button.
  At that point, then re-run “./nginxinstaller install” command.

4. Rebuild Apache and then restart nginx and Apache
    /scripts/rebuildhttpdconf
    /etc/init.d/nginx restart
    /etc/init.d/httpd restart

Now, your static pages should be serving from nginx, while PHP and cgi ones should be serving from Apache. Both httpd and nginx processes will be running on the machine.

Please note that sites will still show up on port 80 in a browser (so you don’t have to worry that pages in a browser will require a different port). nginx works as a proxy on port 80, so it handles the incoming requests on that port to see if they are dynamic or static, then it hands off the dynamic pages to Apache (running on port 8081). Your site visitors will have no idea that Apache is running on a different port due to the proxying nginx performs on the machine for it.

Uninstall nginx

If you decide you want to uninstall nginx at any point, simply run this command: 
/root/cpacct/publicnginx/nginxinstaller uninstall
You would also need to go to WHM > Tweak Settings and change the Apache port back to 80:
The port on which Apache listens for HTTP connections. Specifying a specific IP will prevent Apache from listening on all other IPs. (default: 0.0.0.0:80)  To: 0.0.0.0:80
Then “Save” that area. Finally, rebuild and restart Apache:
  /scripts/rebuildhttpdconf
  /etc/init.d/httpd restart
======================================================================

Changing Litespeed webserver password


Login to the server
/usr/local/lsws/admin/misc/admpass.sh 

Enter the user name:
New Password:
Retype New Password: 

The password have been changed
============================================