• Contact
  • Contact Us
  • Disclamer
  • Home 1
  • Home 2
  • Home 3
  • Privacy Policy
Tuesday, July 1, 2025
How VPS - How to use/setup VPS
  • Login
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon
No Result
View All Result
How VPS - How to use/setup VPS
No Result
View All Result
Home Operating System CentOS

How To Speed Up Nginx on CentOS

How VPS by How VPS
October 1, 2019
in CentOS
0
0
SHARES
18
VIEWS
Share on FacebookShare on Twitter

Contents

  1. Introduction
  2. Prerequisites
    1. Step 1: Backup old configuration and data
    2. Step 2: Remove Nginx
    3. Step 3: Install OpenSSL and its dependencies
  3. Compile Nginx
    1. Step 1: Use wget to retrieve the Nginx source code
    2. Step 2: Extract the tarball
    3. Step 3: Build and install Nginx
    4. Step 4: Setup Nginx as a service
    5. Step 5: Configure Nginx
  4. Conclusion
  5. Optional: Install additional modules
  6. Want to contribute?


Introduction

This tutorial will teach you how to optimize a website that is being hosted with Nginx. We’ll be doing the following:

  • Removing Nginx.
  • Recompiling Nginx with SPDY3, OpenSSL, and Gzip.
  • Installing any 3rd party modules needed.

Steps in this tutorial have been tested on both CentOS 6 and 7. In addition, both 32-bit and 64-bit architectures were tested working.

Prerequisites

Let’s get started with the removal of Nginx. Also, we’ll need to have OpenSSL and a few dependencies installed before we compile Nginx again.

Step 1: Backup old configuration and data

cd ~
mkdir nginx
cp -r /etc/nginx ~/nginx

Step 2: Remove Nginx

yum remove nginx

Step 3: Install OpenSSL and its dependencies

yum install zlib-devel pcre-devel openssl libssl-devel make gcc gcc-c++ -y

Compile Nginx

Now that we’re done with the removal of Nginx, we can compile it from source.

Step 1: Use wget to retrieve the Nginx source code

cd ~
wget https://nginx.org/download/nginx-1.8.0.tar.gz

Step 2: Extract the tarball

tar -xvf nginx-1.8.0.tar.gz

Step 3: Build and install Nginx

cd ~/nginx-1.8.0
./configure --with-http_spdy_module --with-http_ssl_module --with-http_gzip_static_module
make install

Step 4: Setup Nginx as a service

We will use a third-party script from GitHub for the init.d service.

cd /etc/init.d
wget https://gist.githubusercontent.com/sairam/5892520/raw/b8195a71e944d46271c8a49f2717f70bcd04bf1a/nginx
chmod +x nginx

Step 5: Configure Nginx

At this point, you can move your old configuration back to the /etc/nginx folder.

Start Nginx.

service nginx start

Begin editing the Nginx configuration.

vi /etc/nginx/nginx.conf

Within the “http” block, add the following:

gzip_vary on;
gzip_proxied any;
gzip_comp_level 6;
gzip_buffers 16 8k; 
gzip_http_version 1.1;  
gzip_types text/plain text/css text/JavaScript;

Exit and save the file by hitting the escape key, proceeded with typing :wq, then hitting enter.

Reload Nginx. This is known as a soft restart.

service nginx reload

Conclusion

Congratulations! You have now compiled and optimized Nginx. Going forward, you should see a performance gain in page loads on your website.

Note that adding more modules to Nginx is not possible after it has been compiled. See the bonus section below for information about adding modules.

Optional: Install additional modules

To add modules to Nginx, you will have to repeat the compile process from this tutorial. Start by removing Nginx again. When you get to the step starting with ./configure ..., you can add modules with this syntax:

--add-module=/<module location>

This argument can be repeated if you have more than one module.

Want to contribute?

You could earn up to $300 by adding new articles

Submit your article
Suggest an update
Request an article
Previous Post

How to Install Cacti 1.1 on CentOS 7

Next Post

How To Install 7 Days to Die on CentOS 7

Next Post

How To Install 7 Days to Die on CentOS 7

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

No Result
View All Result

Recent Post

Install Imagemagick on CentOS
CentOS

Install Imagemagick on CentOS

by How VPS
June 28, 2023
0

This is how I installed Imagemagick on a vanilla CentOS server Start off by installing the prerequisites yum install php-pear...

Read more
how to Check phpinfo

How to Check phpinfo of Hosting or VPS?

June 28, 2023
Failed to download metadata for repo 'appstream' on Centos 8

How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

February 25, 2022
How to Fix MySQL Error "Plugin 'InnoDB' registration as a STORAGE ENGINE failed"?

How to Fix MySQL Error “Plugin ‘InnoDB’ registration as a STORAGE ENGINE failed”?

November 17, 2020
How to optimize Mysql or MariaDB

How to optimize Mysql or MariaDB

November 3, 2020

Recent News

  • Install Imagemagick on CentOS
  • How to Check phpinfo of Hosting or VPS?
  • How to fix error: Failed to download metadata for repo ‘appstream’ on Centos 8

Category

  • Arch
  • Authentication
  • Backups
  • BSD
  • Centmin Mod
  • CentOS
  • Control Panels
  • CoreOS
  • CWP
  • Debian
  • Directadmin
  • Encryption
  • Fedora
  • Firewalls
  • Hocvps Script
  • Hosting providers
  • Kloxo-MR
  • Linux
  • Mitigations
  • Operating System
  • Plesk
  • Reviews
  • Securing VPS/Servers
  • Security Patches
  • SSL Certificates
  • Uncategorized
  • Upgrading
  • VPS/Servers management guides
  • Vulnerability Detection
  • Web servers software
  • Webhosting Control Panel
  • About
  • Advertise
  • Careers
  • Contact

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

No Result
View All Result
  • Home
  • Management guides
    • Web servers software
      • Directadmin
      • Hocvps Script
      • Centmin Mod
      • CWP
      • Kloxo-MR
      • Plesk
    • Control Panels
    • Securing VPS/Servers
      • SSL Certificates
      • Upgrading
      • Authentication
  • Operating System
    • CentOS
    • Fedora
    • Debian
    • Linux
    • Arch
    • BSD
    • CoreOS
  • Reviews
  • Coupon
    • Domain Coupon
    • Hosting Coupon

© 2025 JNews - Premium WordPress news & magazine theme by Jegtheme.

Welcome Back!

Login to your account below

Forgotten Password?

Retrieve your password

Please enter your username or email address to reset your password.

Log In