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

lara120618's avatar

NGINX Configuration file for non-Laravel projects

I'm working on a non-laravel project (Building my own custom PHP framework). I'm following another Github repo for this and the repo consists of a nginx-configuration.txt file. I'm running Laravel Valet and since I'm still learning I'm not quite sure where and how and where to add the NGINX config file.

This would be the nginx-configuration.txt file. I have.


# nginx configuration to remove the question mark from the URL but maintain the query string

location / { 
    if (!-f $request_filename){
        set $rule_0 1$rule_0;
    }   
    if (!-d $request_filename){
        set $rule_0 2$rule_0;
    }
    if ($rule_0 = "21"){
        rewrite ^/(.*)$ /index.php? last;
    }   
}

0 likes
6 replies
midwestdev's avatar

Centos? Ubuntu? What is your server configuration

The default configuration is located /etc/nginx/conf.d/default.conf on centos

There are also configuration blocks

Make sure to study some tutorials for setting up nginx and configuring it before you start messing around, it will help you out in the long run

lara120618's avatar

@MIDWESTDEV - Can you recommend me some tutorials about this please. Having a hard time finding them cause I don't know what to search.

Please or to participate in this conversation.