How do I customize the nginx configuration for homestead improved?

I am using Php MYsql Novice to Ninja. I have set up homestead _improved and the control structure for an application works by routing URL requests to index.php located in the public directory. This works fine.

However, I want to move the application to a subdirectory /dms if I do so the routing doesn’t work. I need to tell nginx to serve /dms/index.php if a URL such as /dms/index/joke/edit ( which does not exit) or /dms/index/joke/edit (which does not exist) is requested .

I think I need to alter the nginx configuration somehow and amend it to something like . Do you think this will work ?

    location / {
        try_files $uri $uri/  /index.php;
    }
  location /dms
 {
        try_files $uri $uri/ /index.php;
    }

I cant see how to go about finding and altering the configuration. How do I go about doing this ? Note: I am using homestead-improved . Your help would be greatly appreciated, as I am stuck.

Awww, you were almost there :slight_smile:

location /dms {
    try_files $uri $uri/ /dms/index.php;
}

Note that you may need to alter the framework too to take the leading /dms/ into account (ignore it).

Hi rpkamp
Thank you for your reply … have you any idea how I edit the nginx configuration on a homestead-improved box ?
It was downloaded from …
git clone https://github.com/swader/homestead_improved my_project

Nginx configuration is normally inside /etc/nginx/. Since this homestead, you’d need to SSH into the machine first using vagrant ssh. You can then use command line editors to edit the configuration files.
The easiest to get started is probably nano, which you can get by running sudo apt-get install nano.
After that you can edit files by typing nano <filename>.

Once you’ve edited the file you need to restart nginx by running sudo systemctl restart nginx.

1 Like

This is brilliant. I done vagrant ssh and have found the .conf files. A whole new world has opened ! Hopefully I can now sort it out. Your help is so appreciated.I shall let you know how I get on.

Awesome, glad to hear it :slight_smile:

Yes … its all working now. Took some time getting used to nano but got there. Thanks again.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.