Home > Cpanel/WHM, Linux Command Line, Scripts > WHMCS Autoinstaller for Cpanel/WHM

WHMCS Autoinstaller for Cpanel/WHM

A script for automated installation of WHMCS in a linux cpanel server is documented below. This has been tested in a cpanel server and the version of WHMCS used is v4.4.2 .

WHMCS requires php modules such as curl,mysql and ioncubeloader for its working. So, make sure that these modules are installed. Replace the variable section in code(such as license,username,password,etc) as per your requirement.

If you want to install WHMCS under a particular domain, replace the variables DOCUMENTROOT with your websites documentroot and also replace the IP address mentioned in variable URL with website name.

#!/bin/bash

#Variables
DOWNLOADURL='http://webservices.domain.com/whmcs_v442.zip'
DOCUMENTROOT='/usr/local/apache/htdocs'

URL='http://162.24.12.23/whmcs/install/install.php?step=3'
LICKEY='Leased-adv14eu2345678901323'
DBHOST='localhost'
DBNAME='whmcs'
DBUSER='whmcs'
DBPASS='whmcs'

FIRSTNAME='MyName'
LASTNAME='Lastname'
EMAIL='myemail@domain.com'
USERNAME='whmcs'
PASSWORD='whmcsadmin'

#php curl and mysql module is enabled by default so skipping it
#Enable ioncube loader 
/scripts/phpextensionmgr install Ioncubeloader
/etc/init.d/httpd restart


wget -O ${DOCUMENTROOT}/whmcs_v442.zip ${DOWNLOADURL}
cd ${DOCUMENTROOT}
unzip whmcs_v442.zip
rm -rf whmcs_v442.zip
chown -R nobody:nobody whmcs/
mv whmcs/configuration.php.new whmcs/configuration.php
chmod 777 whmcs/configuration.php



#Installing twill(if it's not already installed) for web-browsing 
if [ ! -f /usr/bin/twill-sh ];then
	wget -O /tmp/twill-0.9.tar.gz http://darcs.idyll.org/~t/projects/twill-0.9.tar.gz
	cd  /tmp
	tar xzf twill-0.9.tar.gz
	cd twill-0.9
	python setup.py install
	python setup.py install_scripts
	cp -p twill-sh /usr/bin/
	chmod 755 /usr/bin/twill-sh
fi


# Create database and accept mysql password via commandline
#
echo "create database whmcs;"|mysql
echo "grant all on whmcs.* to 'whmcs'@'localhost' identified by '${DBPASS}'"|mysql
echo "flush privileges;"|mysql

#AutomatedForm submitter
cat > "/tmp/whmcs_twill.sh" << EEOF
go ${URL}
fv 1 licensekey '${LICKEY}'
fv 1 dbhost '${DBHOST}'
fv 1 dbname '${DBNAME}'
fv 1 dbusername '${DBUSER}'
fv 1 dbpassword '${DBPASS}'
submit
fv 1 firstname '${FIRSTNAME}'
fv 1 lastname '${LASTNAME}'
fv 1 email '${EMAIL}'
fv 1 username '${USERNAME}'
fv 1 password '${PASSWORD}'
submit
exit
EEOF

cat /tmp/whmcs_twill.sh|/usr/bin/twill-sh >>/tmp/whmcsinstalllog.txt`date +%F`
if [ $? -ne 0 ];then
	#In case of error to retry drop the whmcs database and then try again
	echo "Installation failed. Check /tmp/whmcsinstalllog.txt`date +%F` for more details"
	exit 1
else
	echo "Installation successful"
fi


#Add crontab
crontab -l > /tmp/cronwhmcs
grep "/whmcs/admin/cron.php" /tmp/cronwhmcs >/dev/null
if [ $? -ne 0 ];then
	echo "01 1 * * * php -q ${DOCUMENTROOT}/whmcs/admin/cron.php" >> /tmp/cronwhmcs
	crontab /tmp/cronwhmcs
fi
rm -f /tmp/cronwhmcs


#Disable Installation folder
chmod 000 ${DOCUMENTROOT}/whmcs/install

#Remove twill-sh
rm -rf /tmp/twill-0.9.tar.gz /tmp/twill-0.9 /usr/bin/twill-fork /usr/bin/twill-sh

Hope this will be helpful:)

Advertisements
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: