How to Build and Install Custom RPMs on Red‑Hat Systems

This guide explains how to build and install custom RPMs on Red‑Hat–based systems for cPanel & WHM. It covers prerequisites, enabling the development target, installing SRPMs, modifying .spec files, rebuilding RPMs, installing custom builds, and preventing automatic updates.

SRPM rebuildRed‑Hat cPanel RPMcustom RPM build

~3 min read · Updated Feb 14, 2026

1. Introduction


cPanel & WHM ships many third‑party dependencies as RPMs. To customize these packages on Red‑Hat–based systems, you must rebuild the RPM and reinstall it. This method is commonly used for customizing applications such as Roundcube.


Note: RPMs work only on Red‑Hat systems. You must log in via SSH as root to install RPMs.


2. Before You Begin


2.1 Install the rpm-build Package

Run the following command:


yum install rpm-build

2.2 Enable the cPanel Development Target

Run these scripts to enable and update the cpanel-devel target:


/scripts/update_local_rpm_versions --edit target_settings.cpanel-devel installed
/scripts/check_cpanel_pkgs --targets cpanel-devel --fix

Some cPanel‑provided RPMs require additional packages not included by default. These must be installed before rebuilding.


2.3 Install All Prerequisites

Check the RPM’s .spec file:


  • BuildRequires: — packages needed for building
  • Requires: — packages needed for installation

Example:

BuildRequires: cpanel-mysql >= 8.0.20

2.4 Verify Required RPMs

Run:


/scripts/sysup

If all prerequisites exist, you will see: All Needed RPMS are installed.


3. Build and Install Custom RPMs


3.1 Create the .rpmmacros File

Create /root/.rpmmacros with:


%_topdir /root/rpmbuild
# enable debug RPM package by commenting this out.
%debug_package %{nil}

3.2 Create Required Directory Structure

Create the following directories if they do not exist:


/root/rpmbuild/BUILD
/root/rpmbuild/SPECS
/root/rpmbuild/SOURCES
/root/rpmbuild/BUILDROOT
/root/rpmbuild/RPMS
/root/rpmbuild/SRPMS

Or run:


mkdir -p /root/rpmbuild/BUILD /root/rpmbuild/SPECS /root/rpmbuild/SOURCES /root/rpmbuild/BUILDROOT /root/rpmbuild/RPMS /root/rpmbuild/SRPMS

Important: Directory names must be capitalized exactly as shown.


3.3 Install the Source RPM (SRPM)

Install the SRPM using:


rpm -Uvh http://httpupdate.cpanel.net/RPM/11.42/src/cpanel-php54-5.4.23-4.cp1142.src.rpm

This installs:

  • .spec file → /root/rpmbuild/SPECS/
  • sources, patches → /root/rpmbuild/SOURCES/

3.4 Edit the .spec File

Modify the .spec file to apply your customizations.


Example configuration section:

%configure --prefix=%{_prefix} \
 --with-libdir=%{_lib} \
 --verbose \
 --enable-static \
 --with-mcrypt=%{_3rdparty_prefix} \
 --with-iconv --enable-mbstring \
 --with-gd \
 --enable-soap \
 --enable-mbregex \
 --with-imap-ssl --with-imap=%{_3rdparty_libdir}/imap/

3.5 Rebuild the RPM

Run:


rpmbuild -bb /root/rpmbuild/SPECS/php.spec

The new RPM will be created in:


/root/rpmbuild/RPMS/

If dependency errors appear, install missing packages with yum.


3.6 Install the Custom RPM

Navigate to the RPMS directory and run:


rpm -Uvh cpanel-php54-5.4.23-4.cp1142.x86_64.rpm --force

4. Prevent Overwriting by cPanel Updates


Warning: This step may freeze updates for this RPM.


Add your custom RPM to the local versions list:


/scripts/update_local_rpm_versions --add srpm_versions.cpanel-php54 5.4.23-4.cp1142

Verify in:


/var/cpanel/rpm.versions.d/local.versions

5. Restore the Original cPanel RPM


To revert to the official cPanel RPM:


/scripts/update_local_rpm_versions --del srpm_versions.cpanel-php54
/scripts/check_cpanel_pkgs

Conclusion


Building and installing custom RPMs on Red‑Hat systems allows you to tailor cPanel & WHM’s third‑party components to your needs. By following these steps—preparing the environment, modifying the SRPM, rebuilding, and managing update behavior—you can safely deploy and maintain custom RPM packages.


Written & researched by Dr. Shahin Siami

Related Articles

How to Restore Your cPanel Account: A Complete Guide for New System Administrators

This guide explains how new system administrators can restore a cPanel account using WHM, transfer accounts and configurations between servers, and enable diagnostic logging for transfer and restore operations. It covers essential concepts such as WHM vs. cPanel, root access, backup handling, SFTP uploads, transfer methods, and advanced debugging tools.

Continue

آموزش کامل انتقال تمام اکانت‌های cPanel از یک سرور به سرور دیگر

این مقاله نحوه انتقال همه اکانت‌های cPanel، تنظیمات سرویس‌ها، گواهی‌های SSL و IP اصلی سرور را از یک سرور قدیمی (Source) به یک سرور جدید (Target) توضیح می‌دهد. شامل نصب سرور جدید، انتقال تنظیمات، انتقال اکانت‌ها، تغییر IP، تنظیم DNS و نصب مجدد SSL است.

Continue

How to Migrate a WordPress® Installation to a cPanel & WHM Server

This guide explains how to migrate a WordPress installation from a macOS-hosted environment to a cPanel & WHM server. It covers exporting the database, uploading WordPress files, creating and importing a MySQL database, updating URLs, configuring wp-config.php, fixing broken links, and finalizing the migration.

Continue

How to Manually Transfer an Account Between Servers in cPanel & WHM

This article explains how to manually transfer a cPanel account between servers when the account is too large for WHM’s automated transfer tools. It covers creating temporary directories, compressing public_html and log files, securely transferring data with SCP, and restoring the files on the destination server.

Continue

How to Manually Migrate Horde Calendars and Contacts to Roundcube in cPanel & WHM

This article explains how to manually migrate Horde calendars and contacts to Roundcube in cPanel & WHM version 108 through 118. It covers exporting Horde data, placing it in the correct directories, and importing it into Roundcube using built‑in plugins or manual import tools.

Continue

How to Manually Migrate Accounts to cPanel & WHM from Unsupported Control Panels

This article explains how experienced system administrators can manually migrate accounts from unsupported third‑party control panels to cPanel & WHM. It covers pre‑migration steps, installation requirements, file and directory transfers, database restoration, SSL migration, and post‑migration tasks.

Continue