How to install Nginx from the source code on Ubuntu 18.04?

0
286
Nginx
Nginx

There are many system administrators who prefer to install programs from their source code. Although it may seem strange to you, it is a very good practice, so you have total control of the program. That’s why today I’ll show you how to install Nginx from the source code on Ubuntu 18.04.

A web server can be cataloged as an essential element of the network. Therefore, you must have a program that is the best and that is Nginx. Nginx is a lightweight, open source and widely popular web server that bases its success on performance when processing websites. Along with Apache web server are the two references within Linux for that purpose.

So, let’s start.

1. Upgrade the system

The first step in this process is to keep your system up to date. Therefore, connect to your server and run.

1.- Upgrade the system
1.- Upgrade the system

With this, you will have a more stable system, robust and ready to start the installation.

2. Install required packages

To compile the Nginx source code, it is necessary to install some previous packages.

2.- Install required packages for the installation
2.- Install required packages for the installation

So, as you can see in the image, many packages related to compilation and package construction are installed.

3. Download and install Nginx

Now proceed to download the latest stable version of Ngnix from your website. Use the following command to do it

3.- Downloading Nginx source code
3.- Downloading Nginx source code

Note: At the time of writing this post the latest stable version of Ngnix is 1.15.8. First, find out which version you want to download and modify the previous command.

Now, decompress the file.

4.- Decompressing the file
4.- Decompressing the file

Now, create a new user for Nginx.

Next, enter the created directory and start the configuration.

5.- Configuring the package
5.- Configuring the package

As you can see, the command is quite extensive because it requires that you indicate which modules or options will be enabled.

When you finish the configuration, you should see something like this.

6.- End of the configure command
6.- End of the configure command

So, install it.

7.- Install Ngnix from the source code
7.- Install Ngnix from the source code

And that’s it.

4. Create a systemd service file for Nginx

To better manage Ngnix, create a file to make it a systemd service.

And add the following:

8.- Creating the systemd file for Ngnix
8.- Creating the systemd file for Ngnix

For these changes to take effect, it is necessary to reload the systemd configuration.

Now, start Ngnix.

9.- Start Nginx service
9.- Start Nginx service

Finally, open your web browser and go to http://IP_SERVER. You should see this.

10. Nginx welcome page
10. Nginx welcome page

And that’s it.

Conclusion

Nginx is a great application to set up a web server. The installation from the source code brings the advantage of being lighter. This is useful if you want to have total control over its operation.

Please share this article with your friends.

Spread the love
  • 19
    Shares

PS. If you like this post please share it with your friends on the social networks using the buttons above.Thanks.

LEAVE A REPLY

Please enter your comment!
Please enter your name here