LinuxLoad BalancerNginx

How to install Nginx in RHEL and CentOS

NGINX is known for its high performance, stability, rich feature set, simple configuration, and low resource consumption. In this blog, we explain how to install Nginx in RHEL and CentOS. NGINX is a free, open-source, high-performance HTTP server and reverses proxy, as well as an IMAP/POP3 proxy server. 
To add NGINX yum repository, create a file named /etc/yum.repos.d/nginx.repo and paste one of the configurations below:
Due to differences between how CentOS, RHEL, and Scientific Linux populate the $releasever variable, it is necessary to manually replace $releasever with either 5 (for 5.x) or 6 (for 6.x), depending upon your OS version.
Installing nginx through yum is just a command away. and can be done as below:
If you encounter dependency issues while installing through yum you can solve that by searching the dependency package or library file(with .so extension) in pkgs.org and then downloading and installing that package for your respective version of OS, by rpm command.

Installing Nginx from Source:

first of all download the source package from here
Now unzip the package with the following command.
Now you will have a directory named nginx-1.2.4.tar.gz in the location where you unzipped the .gz package file.

/usr/local/nginx is the default installation directory of nginx.
Now let’s get inside the directory which we unzipped.
Now, lets configure our nginx installation with ./configure command. There is any number of options available with this ./configure command, like the following.
–prefix  to override the default installation path of /usr/local/nginx
–sbin-path this option can be used to specify the nginx command path.
–pid-path    pid file path; like the files we have in /var/run/
–http-log-path      you can specify the log file path with this option.
with these above-mentioned options, I can both mention the path of the files, and also the file names.
Now we will compile our selected options. by make command.
Now let’s install it.
That’s it you have installed nginx from source package.  Now let’s start nginx with the below command.
I have installed it in /home/sshinde which is the reason am using this path to start nginx.Let‘s confirm whether our nginx is running by the following command.

and also from the below command.
Now let’s see and compare if that’s the pid written to the file we mentioned during our installation configuration option –pid-path option.
Manage the Nginx Process
Now that you have your web server up and running, we can go over some basic management commands.

Command to start/stop/restart NGINX Service in Linux

To stop your web server, you can type:
To start the web server when it is stopped, type:
To stop and then start the service again, type:

Related Articles

One Comment

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close

Adblock Detected

Please consider supporting us by disabling your ad blocker