arrow_back
Back

Nginx on Linux: installation, configuration, and virtual hosts

Andrew Dorokhov Andrew Dorokhov schedule 1 min read
menu_book Table of Contents

Installation (CentOS/RHEL 7)

Nginx packages are in the EPEL repository:

yum install nginx

Enable at boot and start:

systemctl enable nginx
systemctl start nginx

Configuration (CentOS/RHEL 7)

Main config file:

/etc/nginx/nginx.conf

Virtual hosts

Use a dedicated directory for vhost configs:

/etc/nginx/vhosts/

Include it inside the http block of nginx.conf:

include /etc/nginx/vhosts/*.conf;

Example vhost:

server {
    listen  80;
    server_name arbitrage.to;
    root  /var/www/arbitrage.to/website;

    location / {
        index  index.html index.htm;
    }
}
code

Need Help with Development?

Happy to help — reach out via the contacts or go straight to my Upwork profile.

work View Upwork Profile arrow_forward
Next Article

Linux users: creating accounts with useradd

arrow_forward