• Home
  • |
  • Blog
  • |
  • Step-By-Step Procedure To Install Apache From Source Code On Ubuntu
Install Apache From Source Code on Ubuntu

If you are into the Linux platform, you might have definitely heard about the Apache webserver. Apache was the most popular open-source web server project for few decades. Even today, Apache holds a share of around 30% in webserver. If you own a website running on an Apache web server, then it is your’s responsibility to keep the web server healthy. To keep the health, you should update, patch, configure or install the latest version of Apache. However, the problem in installing the latest Apache on the Linux system is no Linux distributions will release the compelled and built package for Apache as soon as the new package is released. To install the latest Apache either you should wait until your distribution release the latest compelled package for Apache or you should download the latest version of source code, build and install it on your Linux server. In this post, we will show you the step-by-step procedure to install the latest version of Apache from source code on Ubuntu.

How To Install Apache from Source Code On Ubuntu?

How to Install the Latest Version Apache from Source Code on Ubuntu?

  1. Check the operating system version

    Run this command to see the Operating System distribution, version, build, and architecture. Make a note of this information for your reference.

    # lsb_release -a ; getconf LONG_BIT

    Check the operating system version

  2. Download and unzip the apache package

    Download the Apache source code under the /usr/local/src/ directory. Unzip the archive file and get inside the directory.

    Change the directory to src
    # cd /usr/local/src/

    Use wget to download the Apache source code package
    # wget https://dlcdn.apache.org//httpd/httpd-2.4.50.tar.bz2

    Unzip the downloaded package. Package will be unzipped into a directory
    # tar -xf httpd-2.4.50.tar.bz2

    Change the directory
    # cd httpd-2.4.50

    Download and unzip the apache package

  3. build the installation package from the source

    Build the installation package from the source using the configuration command as shone here.

    Create a new directory for the installation. We can’t install Apache in the same directory we have the source.
    # mkdir /usr/local/apache2.4.50

    Use configure command to build the installation package. Specify the installation directory with –prefix parameter.
    # ./configure –prefix=/usr/local/apache2.4.50 –enable-shared=max

    build the installation package from source

  4. Apr error in building the package

    If you get the Apr error “checking for ARP… no”. Some packages are not installed on your server. You can fix the error by installing these packages.

    1. build-essential
    . libssl-dev
    . libexpat-dev
    . libpcre3-dev
    . libapr1-dev
    . libaprutil1-dev

    # apt install build-essential libssl-dev libexpat-dev libpcre3-dev libapr1-dev libaprutil1-dev

    ARP error in building the package

  5. Install the apache from the build

    You can install the package upon the successful build. You should see the summary of the build after the successful completion.

    Run this make and make install commands to install the Apache server on Ubuntu.

    # make && make install

    Install the apache from the build

  6. Run the Apache service

    You can start, stop, restart the Apache server with apachectl command from its bin directory.

    # /usr/local/apache2.4.50/bin/apachectl start
    # /usr/local/apache2.4.50/bin/apachectl stop
    # /usr/local/apache2.4.50/bin/apachectl restart

    Run this command to check the status of the Apache service.

    # ps -ef | grep apache2

    Run apache services

That’s it. This is how you can install the latest version of Apache from source code on Ubuntu.

See Also  How To Fix CVE-2022-27511(2), Security Bypass Vulnerability In Citrix ADM

We hope this tutorial post will help you in installing Apache from the source code. Thanks for reading this threat post. Please share this post and help to secure the digital world. Visit our social media page on FacebookLinkedInTwitterTelegramTumblr, & Medium and subscribe to receive updates like this.

Read More:

About the author

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience spanning IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

To know more about him, you can visit his profile on LinkedIn.

Leave a Reply

Your email address will not be published. Required fields are marked

  1. hello , thank you for the post . However , I got an error when installing "# apt install build-essential libssl-dev libexpat-dev libpcre3-dev libapr1-dev libaprutil1-dev" => "No packages where found" . I am using a non-debian based .

  2. Thank you very much for this article!
    Can you please suggest: hot to add this builded from sources apache to Ubuntu/Debian autostart?

      1. Thank you for you response!

        I installed Apache using your manual, it works. To start Apache I can use the "apachectl start" command.
        I can also start this Apache using the "httpd -k start" command.

        But I need this Apache (installed from source) to start when the operating system (Ubuntu) starts up. Please tell, do you know any ways to do this?

        I tried to create a service for systemctl, I used the above commands as an exextar parameter. The problem is that both of these commands start Apache and exit with code 0 (Apache continues to run), systemctl tryed to restart this process, so we can't monitor Apache status in this way.

{"email":"Email address invalid","url":"Website address invalid","required":"Required field missing"}

Learn Something New with Free Email subscription

Email is also one of the ways to be in touch with us. Our free subscription plan offers you to receive post updates straight to your inbox.