• Home
  • About Us
  • Contact
  • Privacy Policy

LinuxAdmin.io

  • Home
  • Tutorials
    • System Administration
    • Linux Tutorials
    • Web Hosting
    • WordPress
    • Virtualization
    • Troubleshooting
    • OpenStack

Nginx Compile From Source On CentOS

Nginx Compile From Source

Nginx (pronounced (“Engine X”) is a high performance web server. It  can be used as a web server, proxy server, load balancer, media streaming and more. It can serve static content and supports SSL. Compiling from source does not take long at all and compiling from source allows you to be in control the configuration options if they need to change later on. Also making upgrades and downgrades easier.  You can read more here

Install dependencies from yum:

yum install -y zlib zlib-devel pcre prce-devel openssl openssl-devel

the zlib packages are required for gzip, the pcre packages are required for regex, and openssl are required for SSL support.

Get the Nginx packages to install:

cd /usr/src;wget http://nginx.org/download/nginx-1.11.13.tar.gz

Un-compress the package

tar xfvz nginx-1.11.13.tar.gz

Change to the  directory:

cd nginx-1.11.13

Configure:

./configure --user=nginx --group=nginx --prefix=/etc/nginx --sbin-path=/usr/sbin/nginx --conf-path=/etc/nginx/nginx.conf --pid-path=/var/run/nginx.pid --lock-path=/var/run/nginx.lock --error-log-path=/var/log/nginx/error.log --http-log-path=/var/log/nginx/access.log --with-http_gzip_static_module --with-http_stub_status_module --with-http_ssl_module --with-pcre --with-file-aio --with-http_realip_module --without-http_scgi_module --without-http_uwsgi_module --with-http_realip_module
--with-http_gzip_static_module - Compresses responses using gzip  
--with-http_stub_status_module - Provides access to status information
--with-http_ssl_module - Allows for SSL support
--with-pcre - enables regex(Regular expressions) similar to mod_rewrite in apache
--with-file-aio - enables file AIO support
--with-http_realip_module - Changes the client address to the one sent in the specified header field. 
--without-http_scgi_module - Passes requiests to an SCGI server(not typically needed)
--without-http_uwsgi_module - Passes requests to a uwsqgi server(not typically needed)

To get more details on the configure options do

./configure --help

Install:

make && make install

The configuration files are located in /etc/nginx/ with a default sample configuration located at

/etc/nginx/nginx.conf

In the server section of the configuration, you will see where the default listen port is set

  server {
        listen       80;
        server_name  localhost;

 

This will bind the server to the default web port, if you want it to change to another port, you can update the listen line.

Start the server:

Centos 6:

Start the service:

/etc/init.d/nginx start

Ensure it starts on boot:

chkconfig --add nginx
chkconfig nginx on

Centos 7:

Start the service:

systemctl start nginx

Ensure it starts on boot:

systemctl enable nginx

This is the first part of a series on setting up and configuring nginx.

Apr 27, 2017LinuxAdmin.io
0 0 vote
Article Rating
Creating A New Virtual Machine with KVMPHP-FPM With PHP7 From Source
You Might Also Like
 
PHP-FPM With PHP7 From Source
 
mod_auth_token Installation In Apache
Subscribe
Notify of
guest
guest
0 Comments
Inline Feedbacks
View all comments
5 years ago Linux Tutorials, Nginx, Web Hosting linux1,326
Recent Posts
  • Laravel Installation Guide For CentOS
  • Openstack Services Explanation And Overview
  • OSSEC Intrusion Detection Installation On Centos 7
  • Configure ProFTPd for SFTP on CentOS
  • How To Check And Repair MyISAM Tables In MySQL
Most Commented
Hot Clone Linux Server with Rsync
Hot Clone A CentOS Server With Rsync
14 Comments
ngx_cache_purge module
Install The ngx_cache_purge Module In Nginx
8 Comments
piwik-nginx
Piwik Analytics on Nginx
8 Comments
Tags
linuxcentosLinux Performance Tuningsysadminkvmnetworkingmemcachedanalyticssystemd
About

We love Linux and are dedicated to creating Linux administration tutorials for System Administrators since 2016.

Most Viewed
Default Gateway
How To Configure A Default Gateway on CentOS
63,003 views
Zend Opcache
Setup and Optimize Zend OpCache
46,714 views
Install ffmpeg
FFMpeg Install On CentOS 7
20,912 views
Archives
Email subscription

Sign up for our newsletter to receive the latest news and event postings.

2018 © LinuxAdmin.io
wpDiscuz