DEV Community

Cover image for Register a Linux user to the nginx group
Rusydy
Rusydy

Posted on

2

Register a Linux user to the nginx group

Case

Upon completing the setup of the GCP instance, NGINX, and cloning the repository, I was unable to pull the repository and received the following error message:



[username@instance-1 landing-page]$ git pull

fatal: detected dubious ownership in repository at '/var /www/landing-page'
To add an exception for this directory, call:
git config --global --add safe.directory /var /www/landing-page


Enter fullscreen mode Exit fullscreen mode

Solution

I then realized that I had forgotten to add my user to the NGINX group and change the ownership of the directory, which have caused the issue.

To register a Linux user to the nginx group, follow these steps:

  • Check the current groups that the user belongs to by running the following command:


groups username


Enter fullscreen mode Exit fullscreen mode
  • If the user does not belong to the nginx group, add the user to the group using the usermod command:


sudo usermod -a -G nginx username


Enter fullscreen mode Exit fullscreen mode
  • To verify that the user has been added to the nginx group, run the groups command again:


groups username


Enter fullscreen mode Exit fullscreen mode

The output should show the user as a member of the nginx group.

To change the ownership of the directory, run the following command:



[username@instance-1 www]$ chown -R username:nginx landing-page/


Enter fullscreen mode Exit fullscreen mode

Note: The above steps assume that the nginx group already exists on your system. If it does not, you can create the group using the following command:



sudo groupadd nginx


Enter fullscreen mode Exit fullscreen mode

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay