How to compile and install NGINX From source on CentOS 7
- Category : Linux Helpline (Easy Guide)
- Posted on : Feb 03, 2019
- Views : 2,213
- By : Edgardo D.

Nginx is a web server which can also be used as a reverse proxy, load balancer, mail proxy and HTTP cache.
In this tutorial we will discuss hoe to compile and install nginx in rpm based systems from source.
1. Compiling Nginx from source.
Installing dependencies using YUM:
# yum install -y zlib zlib-devel pcre prce-devel openssl openssl-develChange the directory according to your wish for downloading source file:
**Here we use /usr/local/src
# cd /usr/local/src/Download Nginx tar file:
# wget http://nginx.org/download/nginx-1.14.2.tar.gzIf you want to download latest version go toΒ http://nginx.org/en/download.html. I here used version 1.14.2
Extract tar file:
# tar xfvz nginx-1.14.2.tar.gzChange directory:
# cd nginx-1.14.2Add a user nginx:
# useradd nginxConfigure:
# ./configure --help ( You will get help regarding configure such as modules to be installed ) βprefix= for specifing the directory which we want to install nginx. Here I used /opt/nginx/
Here I used following configuration with some necessary modules.
# ./configure --user=nginx --group=nginx --prefix=/opt/nginx --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_moduleInstall the configured:
# make
# make installIf you are using apache on the same server you need to change the port number in nginx main configuration file
# vi /opt/nginx/conf/nginx.conf
server {
listen 8080;
server_name localhost;save and quit.
If you enabled firewall in your server you want to add he port in firewall.
Add the service file:
# vi /usr/lib/systemd/system/nginx.service
[Unit]
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/opt/nginx/logs/nginx.pid
ExecStartPre=/opt/nginx/sbin/nginx -t
ExecStart=/opt/nginx/sbin/nginx
ExecReload=/opt/nginx/sbin/nginx -s reload
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.targetsave and quit.
Start the service:
# systemctl start nginx
# systemctl enable nginxYou can check version by executing following command.
# /opt/nginx/sbin/nginx -vNow open your browser and ensure nginx is working http://your_ip:port_number
Categories
Subscribe Now
10,000 successful online businessmen like to have our content directly delivered to their inbox. Subscribe to our newsletter!Archive Calendar
| Sat | Sun | Mon | Tue | Wed | Thu | Fri |
|---|---|---|---|---|---|---|
| 1 | 2 | 3 | ||||
| 4 | 5 | 6 | 7 | 8 | 9 | 10 |
| 11 | 12 | 13 | 14 | 15 | 16 | 17 |
| 18 | 19 | 20 | 21 | 22 | 23 | 24 |
| 25 | 26 | 27 | 28 | 29 | 30 | 31 |
Recent Articles
-

Posted on : Jul 25
-

Posted on : Jul 07
-

Posted on : Apr 07
-

Posted on : Mar 19
Optimized my.cnf configuration for MySQL 8 (on cPanel/WHM servers)
Tags
- layer 7
- tweak
- kill
- process
- sql
- Knowledge
- vpn
- seo vpn
- wireguard
- webmail
- ddos mitigation
- attack
- ddos
- DMARC
- server load
- Development
- nginx
- php-fpm
- cheap vpn
- Hosting Security
- xampp
- Plesk
- cpulimit
- VPS Hosting
- smtp
- smtp relay
- exim
- Comparison
- cpu
- WHM
- mariadb
- encryption
- sysstat
- optimize
- Link Building
- apache
- centos
- Small Business
- VPS
- Error
- SSD Hosting
- Networking
- optimization
- DNS
- mysql
- ubuntu
- Linux






