Skip to main content

Compiling Software from Source in SUSE Linux Enterprise

Hands-On Lab

 

Photo of Ross Brunson

Ross Brunson

Linux Training Architect II

Length

00:30:00

Difficulty

Beginner

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

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Compiling Software from Source in SUSE Linux Enterprise

Introduction

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

Solution

Log in to the Server1 server using the credentials provided:

ssh cloud_user@<SERVER1_PUBLIC_IP_ADDRESS>

Remember: Instead of having to copy/paste or type out entire commands you've run before or slightly different versions of previous commands, you can hit the up arrow key to go through your history of commands. Much easier and saves a bit of time.

Install the GNU Compiler, Retrieve the Nginx Source Files Package, and Extract It

  1. Install the GNU compiler:

    sudo -i zypper in -y gcc

    Enter the cloud_user password at the prompt.

    It will take a couple minutes to complete installation.

  2. From your home directory, download the Nginx package:

    wget https://nginx.org/download/nginx-1.16.1.tar.gz
  3. Extract the package:

    tar zxf nginx-1.16.1.tar.gz
  4. Switch to its directory:

    cd nginx-1.16.1

Once Inside the Package Directory, Configure the Make File, and Install Nginx

  1. Run the configure command and read the output:

    ./configure

    We'll eventually get an error.

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

    ./configure --without-http_rewrite_module

    We'll still get an error.

  3. Continue until your configure runs with no issues:

    ./configure --without-http_rewrite_module --without-http_gzip_module
  4. Once this has completed, make the software:

    make
  5. Install the software:

    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 master process ID.

  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:

    make
  5. Install the software:

    sudo make install

Run and Verify That Nginx Is Working from the websrv Directory

  1. Change to the websrv directory:

    cd ~/websrv/sbin
  2. Start the Nginx you just installed:

    sudo ./nginx
  3. Verify it is working:

    curl 127.0.0.1
  4. Locate the master process ID:

    ps -ax | grep nginx

    Copy the master process ID.

  5. Stop the process:

    sudo kill <MASTER_PROCESS_ID>

Conclusion

Congratulations on successfully completing this hands-on lab!