RHEL / Fedora /CentOS Linux: Set RPM Build Environment

How do I set an rpm build environment on CentOS / RHEL / Red Hat Enterprise Linux version 6.x? How can I set rpm build environment on latest version of Fedora Linux?

You can setup a basic development environment. This includes the following tools:


Tutorial details
Difficulty Intermediate (rss)
Root privileges Yes
Requirements RHEL/CentOS/Fedora
Time N/A
=> Compilers such as GNU gcc compiler collection, bison, flex and others.Build tools such as make, autoconf, automake and others.

=> redhat-rpm-config – Red Hat specific rpm configuration files.

=> rpm-build – The rpm-build package contains the scripts and executable programs that are used to build packages using the RPM Package Manager.

You can install these tools with a single command. Open a terminal or login over the ssh session and type the following command as root user:
# yum groupinstall "Development tools"
$ sudo yum groupinstall "Development tools"
Sample outputs:


Create directories

You need to create directories for RPM building under your home directory such as /home/nixcraft. Open a terminal and type the following command:

 ## cd to $HOME, just in case ##
##  create dirs ##
mkdir -p ~/rpmbuild/{BUILD,RPMS,SOURCES,SPECS,SRPMS}
## add macros (site specific) ##
echo '%_topdir %(echo $HOME)/rpmbuild' >> ~/.rpmmacros
echo '%debug_package %{nil}' >> ~/.rpmmacros

A note about Fedora Linux users

You can create directories in your home directory is using fedora-rpmdevtools. This package is not avilable on CentOS / RHEL / SL version <= 6.x. If you are Fedora Linux user, enter: # yum -y install fedora-rpmdevtools
$ sudo yum -y install fedora-rpmdevtools
Login as a non-root user, and type the following command create rpmbuild directory:
$ fedora-buildrpmtree

🐧 Get the latest tutorials on SysAdmin, Linux/Unix, Open Source/DevOps topics:
CategoryList of Unix and Linux commands
File Managementcat
FirewallAlpine Awall CentOS 8 OpenSUSE RHEL 8 Ubuntu 16.04 Ubuntu 18.04 Ubuntu 20.04
Network Utilitiesdig host ip nmap
OpenVPNCentOS 7 CentOS 8 Debian 10 Debian 8/9 Ubuntu 18.04 Ubuntu 20.04
Package Managerapk apt
Processes Managementbg chroot cron disown fg jobs killall kill pidof pstree pwdx time
Searchinggrep whereis which
User Informationgroups id lastcomm last lid/libuser-lid logname members users whoami who w
WireGuard VPNAlpine CentOS 8 Debian 10 Firewall Ubuntu 20.04

3 comments… add one

Leave a Reply

Your email address will not be published.

Use HTML <pre>...</pre>, <code>...</code> and <kbd>...</kbd> for code samples.