• DevOps
    Case Study

    How we built a resilient multi-account, multi-cloud solution for a Health Tech service provider!

    READ CASESTUDY
    icon

    24/7 DevOps as a Service

    Round-the-clock DevOps for uninterrupted efficiency.

    icon

    Infrastructure as a Code

    Crafting infrastructure with ingenious code.

    icon

    CI/CD Pipeline

    Automated CI/CD pipeline for seamless deployments.

    icon

    DevSecOps

    Integrated security in continuous DevOps practices.

    icon

    Hire DevOps Engineers

    Level up your team with DevOps visionaries.

    icon

    Consulting Services

    Navigate success with expert DevOps consulting.

  • TechOps
    Case Study

    How we built a scalable Odoo solution for a Travel Tech service provider!

    READ CASESTUDY

    WEB HOSTING SUPPORT

    icon

    HelpDesk Support

    Highly skilled 24/7 HelpDesk Support

    icon

    Product Support

    Boost your product support with our expertise.

    MANAGED SERVICES

    icon

    Server Management

    Don’t let server issues slow you down. Let us manage them for you.

    icon

    Server Monitoring

    Safeguard your server health with our comprehensive monitoring solutions.

    STAFF AUGMENTATION

    icon

    Hire an Admin

    Transform your business operations with our expert administrative support.

    icon

    Hire a Team

    Augment your workforce with highly skilled professionals from our diverse talent pool.

  • CloudOps
    Case Study

    How we helped a Private Deemed University in India, save US $3500/m on hosting charges!

    READ CASESTUDY
    icon

    AWS Well Architected Review

    Round-the-clock for uninterrupted efficiency

    icon

    Optimize

    Efficient CloudOps mastery for seamless cloud management

    icon

    Manage

    Automated CI/CD pipeline for seamless deployments

    icon

    Migrate

    Upgrade the journey, Migrate & Modernize seamlessly

    icon

    Modernize

    Simplify compliance complexities with our dedicated services

    icon

    FinOps as a Service

    FinOps as a Service

  • SecOps
    Case Study

    How we built a scalable Odoo solution for TravelTech service provider!

    READ CASESTUDY
    icon

    VAPT

    Vulnerability Assessment and Penetration Testing

    icon

    Source Code Review

    Ensuring source code security ans safe practices to reduce risks

    icon

    Security Consultation

    On demand services for improving server security

    icon

    System Hardening

    Reduced vulnerability and proactive protection

    icon

    Managed SoC

    Monitors and maintains system security. Quick response on incidents.

    icon

    Compliance as a Service

    Regulatory compliance, reduced risk

  • Insights
    Case Study

    How we helped a Private Deemed University in India, save US $3,500/m on hosting charges!

    READ CASESTUDY
    icon

    Blog

    Explore our latest articles and insights

    icon

    Case Studies

    Read about our client success stories

    icon

    Flipbook

    Explore our latest Flipbook

    icon

    Events

    Join us at upcoming events and conferences

    icon

    Webinars

    Watch our educational webinar series

  • Our Story
  • Contact Us

Interested to collaborate?

Get in touch with us!

Ready to elevate your business with certified cloud expertise? Contact us today to learn how our team can help you leverage cloud technology to drive growth, streamline operations, and enhance security.

  • AWSAWS
  • Azure CloudAzure Cloud
  • Google CloudGoogle Cloud
  • Akamai CloudAkamai Cloud
  • OVHOVH
  • Digital OceanDigital Ocean
  • HetznerHetzner
  • Kubernetes Consultancy Services
  • K8s & Cloud native Solutions
  • 24/7 Infrastructure Monitoring
  • DevOps as a Service
  • Cloud CI/CD Solutions
  • White Labeled MSP Support
  • Our story
  • Life@SupportSages
  • Insights
  • Careers
  • Events
  • Contact Us

Connect with us!


LinkedInFacebookXInstagramYouTube

aws partneraws advanced partner
SupportSages

Copyright © 2008 – 2026 SupportSages Pvt Ltd. All Rights Reserved.
Privacy PolicyLegal TermsData ProtectionCookie Policy

OnApp enabled cPanel hosting – Creating ready-to-deploy cPanel servers

Shafeer P

  • 4 min read
OnApp enabled cPanel hosting – Creating ready-to-deploy cPanel servers

Generating audio, please wait...

Server Provisioning is one of the most routinely performed activities in Web hosting environment. cPanel is the most popular hosting control panel in the industry. Naturally there is huge demand for creation of OnApp enabled cPanel hosting servers.

It is possible to create a template for cPanel VMs and its VM instances in OnApp.  However, each VM will have its own identity elements such as IP, Hostname etc. These parameters are defined in various configuration files of each cPanel and other related services. Proper functioning of each cPanel VMs depends these unique values and hence the general values specified in the template needs modification. Changing the configuration files in accordance with the requirement of each VM is obviously a tedious task.

OnApp provides great tool for such operations on VMs, named Recipe. However, due to the security layer of cPanel architecture, Recipe cannot be executed in cPanel servers by default.

We can overcome this restriction by implementing a simple tweak, as discussed below.

1. Create an empty Virtual Server for template: See

2. Install and configure the cPanel: See

3. Install required third-party optional packages required.

For example, we can install third-party packages such as Softaculous, Percona MySQL, LiteSpeed etc.

Now, let us go deeper in to the OnApp Recipe setup.

4. Prepare the OnApp recipe script

4a. Recipe prerequisties and preperations

  • OnApp recipe will executes via the native Linux SSH environment. So the SSH service should listen on the default port 22 with direct Root login.

Ref 1#: https://docs.onapp.com/display/31AG/Recipes
Ref 2#: https://docs.onapp.com/display/40AG/Recipes

  • The commands specified in the Recipe will be copied into the /tmp of VM with an arbitrary filename.
  • The /tmp partition should be mounted with exec option.
    Add the following command to /root/.bashrc to mount the /tmp with exec option when the Root user logins:
 mount -o remount exec /tmp 

This mount option will be removed automatically during Recipe execution.

  • The Linux filesystem table (/etc/fstab) will be overwritten by the OnApp during VM deployment. So, we have to keep the backup of fstab and recipe will restore during VM creation.
 /bin/cp -p /etc/fstab /etc/fstab.cpanel 

4b. The shell scripts

#!/bin/bash

## Script to update IP/Hostname after OnApp VM deployment.

WWW_CONF=/etc/wwwacct.conf
RDNS_CONF=/etc/mail_reverse_dns
HTTP_CONF=/usr/local/apache/conf/httpd.conf
LOG_FILE=/var/log/recipe.log
:> $LOG_FILE

OLD_IP= # Input the IP address of the Template server here
NEW_IP=$IP_ADDRESS

OLD_HOST= # Input the hostname of the Template server here
NEW_HOST=$HOSTNAME

echo "Old IP address: $OLD_IP"
echo "New IP address: $NEW_IP"
echo "Old hostname: $OLD_HOST"
echo "New hostname: $NEW_HOST"

if [ "$OLD_HOST" == "$NEW_HOST" ]
then
 echo "Error: This script won't run on this server!"
 exit 1
fi
 echo -e "\nStopping cPanel and Apache..."
 /etc/init.d/cpanel stop &>> $LOG_FILE
 /etc/init.d/httpd stop &>> $LOG_FILE

 echo -e "Updating IP in wwwacct.conf..."
 replace $OLD_IP $NEW_IP -- $WWW_CONF &>> $LOG_FILE

 echo -e "Updating Main IP for cPanel..."
 /scripts/mainipcheck &>> $LOG_FILE

 echo -e "Updating Exim RDNS..."
 replace $OLD_IP $NEW_IP -- $RDNS_CONF &>> $LOG_FILE
 replace $OLD_HOST $NEW_HOST -- $RDNS_CONF &>> $LOG_FILE

 echo -e "Updating Apache configuration..."
 /scripts/rebuildhttpdconf &>> $LOG_FILE
 replace $OLD_IP $NEW_IP -- $HTTP_CONF &>> $LOG_FILE
 replace $OLD_HOST $NEW_HOST -- $HTTP_CONF &>> $LOG_FILE
 /usr/local/cpanel/bin/apache_conf_distiller --update &>> $LOG_FILE
 
 echo -e "Staring Apache..."
 /etc/init.d/httpd start &>> $LOG_FILE
 
 echo -e "Updating cPanel license..."
 /usr/local/cpanel/cpkeyclt &>> $LOG_FILE
 
 echo -e "Staring cPanel..."
 /etc/init.d/cpanel start &>> $LOG_FILE

 echo -e "Updating Hostname via WHM..."
 curl --insecure --user root:$ROOT_PASSWORD https://$NEW_IP:2087/scripts2/dochangehostname?hostname=$NEW_HOST &>> $LOG_FILE

## FSTAB hardening

 echo -e "\nHardening fstab..."
 mv -f /etc/fstab /etc/fstab.onapp &>> $LOG_FILE
 /bin/cp /etc/fstab.cpanel /etc/fstab &>> $LOG_FILE
 mount -a &>> $LOG_FILE
 mount -o remount / &>> $LOG_FILE
 replace "`grep mount /root/.bashrc `" "" -- /root/.bashrc &>> $LOG_FILE
 echo -e "\nUpdating file system quota..."
 /scripts/fixquotas &>> $LOG_FILE

Note: You need to enter the values for the variables OLD_HOST and OLD_IP with the IP and hostname of the Template server.

5. Create OnApp Recipe

Refer this article for creating the OnApp Recipe. In the script field, enter the following command.


/bin/sh /path/to/the/script.sh

onapp_edit_recipe

6. Create the Virtual Server template in OnApp

7. Assign the Recipe into the Template

Get 24/7 expert server management

  • cPanel
  • Howtos
  • Linux
OnApp enabled cPanel hosting – Creating ready-to-deploy cPanel servers

AWS LightSail Automatic Snapshots

AWS LightSail Automatic Snapshots
  • AWS
logo

Configure SSL on Tomcat 6/7/8/9

Configure SSL on Tomcat 6/7/8/9
  • Linux
logo

Enable TNEF on Linux Servers

Enable TNEF on Linux Servers
  • Howtos
  • Linux
  • Windows
logo

Fixing zPanel blank-screen error

Fixing zPanel blank-screen error
  • Apache
  • Linux
  • Troubleshooting
logo

Posts by Shafeer P

Shafeer is currently working as Senior System Engineer at SupportSages. He is capable of tackling time-consuming issues quickly with his advanced scripting abilities. His unchallenged expertise in solving complex issues in a cut-and-dried way makes him a dependable man in the team. The attitude and philosophy he shows on his workplace make his colleagues call him 'Mr. Perfectionist'. Furthermore, he is a travel and photography enthusiast, and loves to spend his leisure times on music and DIY arts.