← Blog / · #nginx · 2 min read

Configuring Nginx to Start Automatically on Boot

Complete steps to configure nginx to start automatically on boot on Linux systems using systemd service configuration.
toc Table of Contents (2)
Configuring Nginx to Start Automatically on Boot

1. Background

Nginx is installed on a virtual machine and needs to start automatically on boot.

2. Steps

1. Navigate to /lib/systemd/system/ Directory

cd /lib/systemd/system/

2. Create File: nginx.service

touch nginx.service
vim nginx.service

3. Edit File Content

[Unit]
Description=nginx service
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/nginx/sbin/nginx
ExecReload=/usr/local/nginx/sbin/nginx -s reload
ExecStop=/usr/local/nginx/sbin/nginx -s quit
PrivateTmp=true

[Install]
WantedBy=multi-user.target

4. Enable Autostart on Boot

systemctl enable nginx
Frency

Frency

· @psephopaiktes

Backend engineer, building indie SaaS tools and digital gardens in public.