Hero Image

Install Nginx on Gentoo Linux

Install Nginx on Gentoo Linux

This guide walks through installing and starting Nginx on Gentoo Linux.

Step 1 – Sync the Portage tree

emerge --sync

Step 2 – Install Nginx

Nginx USE flags can be set in /etc/portage/package.use/nginx:

www-servers/nginx http http-cache http2 pcre ssl

Then install:

emerge --ask www-servers/nginx

Step 3 – Start and enable Nginx (OpenRC)

rc-update add nginx default
rc-service nginx start

Step 4 – Configure iptables (example)

iptables -A INPUT -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -p tcp --dport 443 -j ACCEPT

Step 5 – Verify

nginx -v
curl -I http://localhost

Gentoo installs the main config to /etc/nginx/nginx.conf.

Next steps