Facebook Pixel

How do I install Nginx on Ubuntu?

Run sudo apt update and sudo apt install -y nginx. Start with sudo systemctl start nginx, enable with sudo systemctl enable nginx. Verify by visiting http://your-ip in a browser to see the welcome page.

Verify This Answer

Cross-check this information using these trusted sources:

More FAQs in Installing and Configuring Nginx on Ubuntu for Node.js Deployment

nginx.conf is the main config. sites-available/ contains all site configs. sites-enabled/ contains symlinks to enabled sites. conf.d/ has additional configs. Create configs in sites-available, symlink to sites-enabled, remove the default, test, and restart.

Create a server block with listen 80, server_name your domain, and a location / block with proxy_pass http://localhost:3000. Add proxy_set_header directives for Host, X-Real-IP, X-Forwarded-For, X-Forwarded-Proto, and Upgrade/Connection headers for WebSocket support.

Create the config in /etc/nginx/sites-available/, create a symlink to /etc/nginx/sites-enabled/ with ln -s, remove the default site, test with sudo nginx -t, and restart with sudo systemctl restart nginx.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.
Please Login.