RHEL/CentOS – How to install NGINX

Pre-requisites:

make sure EPEL is enabled – see here.

Once that is done just issue:

yum install nginx

and when installed enable the service so it starts with they OS:

[root]# chkconfig nginx
Note: Forwarding request to 'systemctl is-enabled nginx.service'.
disabled
[root]# chkconfig nginx on
Note: Forwarding request to 'systemctl enable nginx.service'.
Created symlink from /etc/systemd/system/multi-user.target.wants/nginx.service to /usr/lib/systemd/system/nginx.service.
[root]# chkconfig nginx
Note: Forwarding request to 'systemctl is-enabled nginx.service'.
enabled

RHEL/CentOS – How to enable EPEL Repository

What is EPEL?

EPEL (Extra Packages for Enterprise Linux) is a volunteer-based community effort from the Fedora project to create a repository of high-quality add-on packages that complement the Fedora-based Red Hat Enterprise Linux (RHEL) and its compatible spinoffs, such as CentOS and Scientific Linux.

Why?

  1. it provides tons of open source packages that can be installed via YUM
  2. maintained by Fedora – therefore trusted

How?

## RHEL/CentOS 7 64-Bit ##
# wget http://dl.fedoraproject.org/pub/epel/7/x86_64/e/epel-release-7-5.noarch.rpm
# rpm -Uvh epel-release-7-5.noarch.rpm
## RHEL/CentOS 6 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm

## RHEL/CentOS 6 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm
# rpm -Uvh epel-release-6-8.noarch.rpm
## RHEL/CentOS 5 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm

# wget http://download.fedoraproject.org/pub/epel/5/x86_64/epel-release-5-4.noarch.rpm
# rpm -Uvh epel-release-5-4.noarch.rpm
## RHEL/CentOS 4 32-Bit ##
# wget http://download.fedoraproject.org/pub/epel/4/i386/epel-release-4-10.noarch.rpm
# rpm -Uvh epel-release-4-10.noarch.rpm

## RHEL/CentOS 4 64-Bit ##
# wget http://download.fedoraproject.org/pub/epel/4/x86_64/epel-release-4-10.noarch.rpm
# rpm -Uvh epel-release-4-10.noarch.rpm

once the package is installed update yum and verify that epel is in on our repo list:

[root]# yum update
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.strencom.net
 * epel: epel.check-update.co.uk
 * extras: mirror.strencom.net
 * updates: mirror.strencom.net
No packages marked for update
[root]# yum repolist
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base: mirror.strencom.net
 * epel: epel.check-update.co.uk
 * extras: mirror.strencom.net
 * updates: mirror.strencom.net
repo id                                 repo name              status
base/7/x86_64                           CentOS-7 - Base        9,007
epel/x86_64                             Extra Packages for Enterprise Linux 7 - x86_64        9,111
extras/7/x86_64                         CentOS-7 - Extras        191
updates/7/x86_64                        CentOS-7 - Updates       369
repolist: 18,678

 

LINUX – IP aliasing

To quote mighty Wikipedia: “IP aliasing is associating more than one IP address to a network interface. With this, one node on a network can have multiple connections to a network, each serving a different purpose”

Debian, Ubuntu

To perform IP aliasing in Debian based system (assuming you’re using eth0), edit /etc/network/interfaces as follows:

auto eth0:1
iface eth0:1 inet static
address 10.0.0.10
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

auto eth0:2
iface eth0:2 inet static
address 10.0.0.11
netmask 255.255.255.0
network 10.0.0.0
broadcast 10.0.0.255
gateway 10.0.0.1

In the above example we create two virtual NICs out of eth0: eth0:1 10.0.0.10) and eth0:2 (10.0.0.11).

CentOS, RHEL, Fedora and similar

In CentOS, rename /etc/sysconfig/network-scripts/ifcfg-enp0s3 as ifcfg-enp0s3:1 and make a copy as ifcfg-enp0s3:2, and then just change the following lines, respectively:

DEVICE="enp0s3:1"
IPADDR=10.0.0.10

and

DEVICE="enp0s3:2"
IPADDR=10.0.0.11

Once done, restart the network service:

systemctl restart networking

NGINX – client intended to send too large body

Going through syslogs I’ve noticed few errors like the one below:

2015/03/03 17:32:27 [error] 11622#0: *2047 client intended to send too large 
body: 1049196 bytes, client: 1.2.3.4, server: subdomain.example.com, request: 
"POST /?/Upload/&s=/_lRQBXpfsulxyH8IKKNAkjcKy5NSC./ HTTP/1.1", host: 
"subdomain.example.com", referrer: "https://subdomain.example.com/"

The error is presented because a request being sent to the server contains more data than Nginx allows by default. You can increase the allowed maximum with the client_max_body_size attribute.

You can add the client_max_body_size attribute to your configuration files in multiple places to control what sites or locations the attribute affects. For example, you can add it to your main config file to ensure than any site can upload the value you set.

/etc/nginx/nginx.conf

http {
 ....
 client_max_body_size 100M;
 ....
 }

You could also add it inside the server { tags of an individual site, or even the location { tags of a specific location.

then:

service nginx reload

How to forward root mail to another account

An alias allows to redirect mail sent to a given address.

Mail alias database is usually kept in flat-text format in the file /etc/aliases

# /etc/aliases
mailer-daemon: postmaster
postmaster: root

This aliases postmaster to root, so that any mail sent to postmaster will instead be delivered to root.

So to redirect root mail to a real email account just add this line:

# /etc/aliases
mailer-daemon: postmaster
postmaster: root
root: real@email.com

or if you do not want to see any of that mail change it to:

root          : /dev/null

Every time you make changes to /etc/aliases, you must run newaliases to update the database.