Install NGINX on CentOS 6/7

Image for post
Image for post

CentOS is pretty comfortable OS which gives extra support to developers, especially such as brew yum etc, over Ubuntu.

Step 1: Installing NGINX on OS

sudo amazon-linux-extras install epel

note: If you are experiencing any issues follow this link

sudo yum -y install nginx
sudo systemctl start nginx.service

Step 2: Create a new user for the webspace

Before doing anything, we need to create a UNIX user for your web space.

sudo useradd phoenix
sudo passwd phoenix

Step 3: Create a new user for the webspace

Now it’s time to get it working for your domain. We need to create the directory that will act as the DocumentRoot for this website. It is a good idea to follow a standard naming convention if you are hosting multiple websites

sudo mkdir -p /var/www/
sudo vim /var/www/
sudo chown -R phoenix:phoenix /var/www/
sudo chmod 755 /var/www/
sudo mkdir /etc/nginx/sites-available 
sudo mkdir /etc/nginx/sites-enabled
vim /etc/nginx/nginx.conf 
vim /etc/nginx/sites-available/
vim /etc/nginx/sites-enabled/
ls -s /etc/nginx/sites-available/ /etc/nginx/sites-enabled/> cd sites-enabled
> sudo ln -s ../sites-available/nginxsite.conf .
> ls -l

Step 4: Hurray! It’s time to start your NGINX server

sudo systemctl restart nginx.service
vim /etc/nginx/nginx.conf
sudo systemctl start nginx.service

#hack 1: It is highly recommended to turn of Apache on your OS, before proceeding to install NGINX.

#hack 2: It’s good practise to test your NGINX server on every change that you make in *.conf file with this command,

sudo service nginx -t

#hack 3: To see the running process(on respective ports) run the below command

sudo netstat -lntup

#hack 4: Check logs

sudo tail -f /var/log/nginx/error.logsudo tail -f /var/log/nginx/access.log

Happy exploration.
Learn — Grow — Glow
Reach me at LinkedIn

Written by

CTO || Cloud and Distributed Systems Specialist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store