Compiling Software from Source in SUSE Linux Enterprise

30 minutes
  • 5 Learning Objectives

About this Hands-on Lab

In this hands-on lab, we will be compiling software from source code and then deploying and testing that software.

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Install the GNU Compiler, Retrieve the Nginx Source Files Package, and Extract It
  1. Install the GNU compiler:

    sudo -i zypper in -y gcc
  2. From your home directory, download the Nginx package:

    wget https://nginx.org/download/nginx-1.16.1.tar.gz
  3. Extract the package, and switch to its directory:

    tar zxf nginx-1.16.1.tar.gz
    cd nginx-1.16.1
Once Inside the Package Directory, Configure the Make File, and Run the Compile and Install Commands
  1. Run the configure command and read the output:

    ./configure
  2. Correct the issue using the --without directive:

    ./configure --without-http_rewrite_module
  3. Continue until your configure runs with no issues:

    ./configure --without-http_rewrite_module --without-http_gzip_module
  4. Once this has completed, run the compile and install commands:

    make
    
    sudo make install
Run Nginx and Ensure It Loads, and Then Stop Nginx
  1. Start Nginx:

    sudo /usr/local/nginx/sbin/nginx
  2. Make sure it is working by loading the index page:

    curl 127.0.0.1
  3. Locate the master process ID:

    ps -ax | grep nginx

    Copy the ID of the master process.

  4. Stop Nginx:

    sudo kill <MASTER_PROCESS_ID>
  5. Verify Nginx is not running:

    ps -ax | grep nginx

    It should return only the grep command.

Create a `websrv` Directory, Reconfigure Nginx to Install to That Directory, and Make and Install It to the `websrv` Directory
  1. Ensure you are in the Nginx source directory:

    cd ~/nginx-1.16.1
  2. Clean up the make environment:

    make clean
  3. Configure the makefile:

    ./configure --prefix=/home/cloud_user/websrv --without-http_rewrite_module --without-http_gzip_module
  4. Make the software and install it:

    make
    sudo make install
Run and Verify That Nginx Is Working from the `websrv` Directory
  1. Start the Nginx you just installed:

    cd ~/websrv/sbin
    sudo ./nginx
  2. Verify it is working:

    curl 127.0.0.1
  3. Locate the master process ID:

    ps -ax | grep nginx
  4. Stop the process:

    sudo kill <MASTER_PROCESS_ID>

Additional Resources

You have been asked to compile Nginx from source and place one installation in the default location /usr/local/nginx and another installation in /home/cloud_user/websrv.

You will need to install the GNU Compiler Collection (GCC) using Zypper, and then ensure modules that will not load are skipped.

Nginx uses a configure utility to create its makefile and you will need to set the --prefix to relocate the installation.

Test each Nginx via curl to localhost to ensure it works correctly.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?