Nginx Systemd Service File for CentOS 7.x

At my web hosting company, in the past months we’ve started using CentOS 7 for brand new dedicated servers, and we also started migrating old CentOS 6.x machines to the latest version of CentOS.

One of the big changes introduced in CentOS 7 is systemd, this changes everything we all knew about system services inside Linux as stated in my previous post CentOS 7 vs CentOS 6.

This Nginx Systemd Service file should work on Fedora, CentOS and  RHEL withut any problems.

Create the Nginx systemd service file:

nano -w /lib/systemd/system/nginx.service

Copy and paste this text inside:

Description=The NGINX HTTP and reverse proxy server

ExecStartPre=/usr/sbin/nginx -t
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID


This nginx systemd service file is useful when you compile Nginx manually without using any binary RPMs.

About the Author: Santiago Borges

Experienced Sr. Linux SysAdmin and Web Technologist, passionate about building tools, automating processes, fixing server issues, troubleshooting, securing and optimizing high traffic websites.

Leave a Reply

Your email address will not be published. Required fields are marked *