Wednesday, October 19, 2016

Setting up Nginx

PaidVerts




Nginx is tool to provide a web server. It can act as a reverse proxy server for TCP, UDP, HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer and an HTTP cache

Nginx is tool to provide a web server. It can act as a reverse proxy server for TCP, UDP, HTTP, HTTPS, SMTP, POP3, and IMAP protocols, as well as a load balancer and an HTTP cache

Installing and Getting Nginx
------------------------------
For CentOS Linux v6.x user type the following command:
# wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-centos-6-0.el6.ngx.noarch.rpm

For RHEL v6.x user type the following command:
# wget http://nginx.org/packages/rhel/6/noarch/RPMS/nginx-release-rhel-6-0.el6.ngx.noarch.rpm
# rpm -ivh nginx-release-rhel-6-0.el6.ngx.noarch.rpm

Installation
------------
yum install nginx

Turn Nginx service ON
----------------------
chkconfig nginx on


Command to start/stop services
------------------------------
# service nginx start
# service nginx stop
# service nginx restart
# service nginx status
# service nginx reload

Below are the useful links for configuration
-------------------------------------------
Default configuration directory: /etc/nginx/
Default SSL and vhost config directory: /etc/nginx/conf.d/
Default log file directory: /var/log/nginx/
Default document root directory: /usr/share/nginx/html
Default configuration file: /etc/nginx/nginx.conf
Default server access log file: /var/log/nginx/access.log
Default server access log file: /var/log/nginx/error.log


vi /etc/nginx/nginx.conf



Verify that everything is working:
# netstat -tulpn | grep :80
# ps aux | grep nginx



Firewall configuration: Open TCP port # 80

Edit the file /etc/sysconfig/iptables, enter:
# vi /etc/sysconfig/iptables

Add the following lines, ensuring that they appear before the final LOG and DROP lines for the INPUT chain to open port 80:

-A INPUT -m state --state NEW -p tcp --dport 80 -j ACCEPT
Save and close the file. Finally, restart the firewall:
# service iptables restart

No comments:

Post a Comment