Rubixy.com

Back

NginX

Installing NginX Step by step. The simple way. 

NOTE: This is how you do it on Debian 9. Other linux distributions may do it differently

 

First off, make sure you got an updated machine to work on, don't want none of them holes creeping up from the past.

 

apt-get update
apt-get install nginx


That should install NginX for you just fine.


Now just to make sure, you should also do

systemctl status nginx

And if all's good, you'll see something like this.

* nginx.service - A high performance web server and a reverse proxy server
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2017-12-22 14:59:25 UTC; 38s ago
Docs: man:nginx(8)
Process: 1078 ExecStart=/usr/sbin/nginx -g daemon on; master_process on; (code=exited, status=0/SU
Process: 1077 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process on; (code=exited, st
Main PID: 1079 (nginx)
Tasks: 5 (limit: 4915)
CGroup: /system.slice/nginx.service
|-1079 nginx: master process /usr/sbin/nginx -g daemon on; master_process on;
|-1080 nginx: worker process
|-1081 nginx: worker process
|-1082 nginx: worker process
`-1083 nginx: worker process

You may find yourself unable to do anything in the ssh/console, just press ctrl+c and you should be fine. 

If you don't know your servers ip, just do ifconfig if it's supported or use this famous peice of code

ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's//.*$//'

Alternatively just use

ip addr show eth0

Now thake the inet ip, or ipv4 ip, wich should be the same thing unless something is weird with the universe

You should be able to put that into your favorite internet browser, and with any luck you'll be greeted with the all mighty welcome page that looks something like this.

NginxWelcomePage

 


Debugging

If you din't get that, make sure you did this correctly, example the IP i got on my server is 192.168.1.45.
Wich means that if i want to see the welcome page, i'd have to go to http://192.168.1.45/ in my own broser.

And if that din't work, then check if you're on the same subnet https://en.wikipedia.org/wiki/Subnetwork

On the right network? Try restarting Nginx

systemctl restart nginx

Still no? Are you trying from the server itself? If so, try http://localhost and you might have some luck.

Nada? Well check if Nginx is running with 

systemctl status nginx

Running? Take a Tea/Coffee break, and think about your setup, as i can't really tell you the solution to the potential problem from this unpredictable event. Check logs, firewall rules (see below), google/stackoverflow, port forwarding? 


Incase you got ufw wich is an Ubuntu firewall i'll suggest running:

ufw allow 'Nginx HTTP'

and check if it allows the traffic with

ufw status

 

Posted on 22nd Dec 2017