Linux Tutorial

Linux File/Directory Management

Linux Packaging And Compression

Vim Text Editor

Linux Text Processing

Linux Software Installation

Linux User/User Group Management

Linux Permission Management

Linux Filesystem Management

Linux Advanced Filesystem Management

Linux System Management

Linux Backup and Recovery

Linux System Service Management

Linux System Log Management

Linux Boot Management

LAMP/LNMP Environment

SELinux Management

Linux Source Package Installation And Uninstallation (Take Apache As An Example)

In this tutorial, we'll learn how to install and uninstall a Linux source package, using Apache HTTP Server as an example. Installing from source code allows you to have the latest features and custom configuration options that may not be available in the pre-built packages.

Prerequisites

  • Update your system:

For Debian/Ubuntu-based systems:

sudo apt update && sudo apt upgrade

For CentOS/RHEL-based systems:

sudo yum update
  • Install necessary development tools:

For Debian/Ubuntu-based systems:

sudo apt install build-essential

For CentOS/RHEL-based systems:

sudo yum groupinstall "Development Tools"

Installing Apache HTTP Server from Source

  • Download the latest Apache source code from the official website (https://httpd.apache.org/download.cgi) or use wget to download it:
wget https://downloads.apache.org/httpd/httpd-2.4.51.tar.gz
  • Extract the source code:
tar xvf httpd-2.4.51.tar.gz
  • Change to the extracted directory:
cd httpd-2.4.51
  • Install the required dependencies:

For Debian/Ubuntu-based systems:

sudo apt-get install libapr1-dev libaprutil1-dev libpcre3-dev libssl-dev

For CentOS/RHEL-based systems:

sudo yum install apr-devel apr-util-devel pcre-devel openssl-devel
  • Configure the source code with the desired options. In this example, we'll use the default options and install Apache under /usr/local/apache2:
./configure --prefix=/usr/local/apache2
  • Compile the source code:
make
  • Install the compiled package:
sudo make install
  • Start Apache:
sudo /usr/local/apache2/bin/apachectl start

Apache HTTP Server is now installed and running. You can access the default page by visiting http://localhost in your browser.

Uninstalling Apache HTTP Server

To uninstall the Apache HTTP Server installed from the source, follow these steps:

  • Stop Apache:
sudo /usr/local/apache2/bin/apachectl stop
  • Remove the installation directory:
sudo rm -rf /usr/local/apache2
  • Optional: Remove the source code directory:
rm -rf httpd-2.4.51

By following this tutorial, you have learned how to install and uninstall a Linux source package using Apache HTTP Server as an example. This method can be applied to other software packages when you need the latest features or custom configuration options not available in the pre-built packages. Keep in mind that installing from source requires more time and effort compared to using package managers, and you'll need to manually manage updates and dependencies.