Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

douglasringram's avatar

Help with nginx.conf change for "pretty" URLs

Hi I've got a deployment of Laravel app via Forge > Digital Ocean. I'm using Cyberduck for common file transfer items while logged in as user: forge... not root.

I'm trialing a template and am getting an error message when trying to access site.com/admin ... I've been told that this is related to the need to do an equivalent mod_rewrite (Apache) for Nginx.

I've followed instructions here for Nginx and all is well.
http://laravel.com/docs/5.0/configuration#pretty-urls

recommended change to nginx.conf

location / {
     try_files $uri $uri/ /index.php?$query_string;
}

However, my issue is when I try to save edited Nginx.conf file back I get a permission denied error because I'm not root user but rather b/c I'm the forge user.

Can anyone recommend the appropriate steps as I've spent considerable time getting keys setup, etc. and getting the framework and my app working correctly and don't want to blow anything up by messing with root items, particularly password reset via Digital Ocean, etc.

Any thoughts would be most appreciated. I've reached out to Digital Ocean and they suggested I contact the Laravel community.

Many thx! Doug

0 likes
2 replies
layer7's avatar
layer7
Best Answer
Level 24

Hi, first off, servers deployed with Forge should already be set up for pretty url's. Take a look in the file

/etc/nginx/sites-enabled/default

and you will see this:

location / {
    try_files $uri $uri/ /index.php?$query_string;
}

The reason why you can't edit these files that are root-owned with Cyberduck is because you need root privileges as you said. You can accomplish the editing of these files (although normally not needed) by using a terminal program (Terminal.app or iTerm on a mac or Putty on a Windows PC). If you then use a command like this:

sudo vim /etc/nginx/sites-enabled/default

or perhaps easier if you've never used vim before:

sudo nano /etc/nginx/sites-enabled/default

On your first attempt, it will ask you for a password. This is the 'sudo password' that is provided in the mail sent by Forge when your server was first set up.

Hope that helps. /K

1 like
douglasringram's avatar

Thanks @layer7 - after I saw your reply I went back in and did some troubleshooting. Issue was a view was missing in what I had setup. All is well now and good to know that nginx can handle this out of the gate. Appreciate your help.

Please or to participate in this conversation.