Skip to content

Instantly share code, notes, and snippets.

@taufiqibrahim
Last active January 10, 2024 11:03
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save taufiqibrahim/d7f697de6bb8b93ca348a5b94d6adbfc to your computer and use it in GitHub Desktop.
Save taufiqibrahim/d7f697de6bb8b93ca348a5b94d6adbfc to your computer and use it in GitHub Desktop.
Install NGINX on Centos 7 Without Internet Connection

Get NGINX source code

wget https://nginx.org/download/nginx-1.12.2.tar.gz

Extract the source

tar xvzf nginx-1.12.2.tar.gz

CD

cd ~/nginx-1.12.2

Create nginx user

useradd nginx
usermod -s /sbin/nologin nginx

Configure

./configure --user=nginx --group=nginx

....


Configuration summary
  + using system PCRE library
  + OpenSSL library is not used
  + using system zlib library

  nginx path prefix: "/usr/local/nginx"
  nginx binary file: "/usr/local/nginx/sbin/nginx"
  nginx modules path: "/usr/local/nginx/modules"
  nginx configuration prefix: "/usr/local/nginx/conf"
  nginx configuration file: "/usr/local/nginx/conf/nginx.conf"
  nginx pid file: "/usr/local/nginx/logs/nginx.pid"
  nginx error log file: "/usr/local/nginx/logs/error.log"
  nginx http access log file: "/usr/local/nginx/logs/access.log"
  nginx http client request body temporary files: "client_body_temp"
  nginx http proxy temporary files: "proxy_temp"
  nginx http fastcgi temporary files: "fastcgi_temp"
  nginx http uwsgi temporary files: "uwsgi_temp"
  nginx http scgi temporary files: "scgi_temp"

Continue with MAKE

make
make install

Starting and stopping NGINX

./nginx             ## To start nginx
./nginx -s stop     ## To stop nginx

Supposed we had 3 web apps which up and running on their own ports.

  • app1 : BASE_URL:7000
  • app2 : BASE_URL:7001
  • app3 : BASE_URL:7002

Now we already have our NGINX serving on port 80. So, opening a web browser and typing our server's URL will show us Welcome to nginx! page.

Now we want to have our apps to be accessed via URL, like:

  • app1 : BASE_URL/app1
  • app2 : BASE_URL/app2
  • app3 : BASE_URL/app3

Instead of using port numbers. We can use NGINX for these requirements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment