How do I enable using custom DNS on my local Ubuntu using Nginx?

I've used Laragon for many months now, and I would like to use a more hands-on approach on creating local websites to test out Laravel and WordPress.

I am using WSL 2 (windows Subsystem for Linux), and using Ubuntu as my "OS". I've installed all the requirement components such as Nginx, PHP 7.4 (along with PHP7.4-fpm), MySQL (Really MariaDB), and WordPress.

I can easily use the localhost to check out my created WordPress site, but I would like to be able to use address like "website.test" or "website.dev", like how it is with Laragon when you create a new site.

I believe it should be something in the Nginx Configuration file but I can't seem to find a proper guide online. Most of them are just actually for creating live sites and not hosted on local servers.

Currently, I have on my

/etc/nginx/sites-available/example.com

server {
    listen 80;
    listen [::]:80;

    root /var/www/example.com/public_html;

    index index.html;

    server_name example.com www.example.com;

    access_log /var/log/nginx/example.com.access.log;
    error_log /var/log/nginx/example.com.error.log;

    location / {
        try_files $uri $uri/ =404;
    }
}

and I do have it symlinked to

/etc/nginx/sites-enabled/

Any proper guides to being able to use custom DNS on just my local environment?



Read more here: https://stackoverflow.com/questions/64902110/how-do-i-enable-using-custom-dns-on-my-local-ubuntu-using-nginx

Content Attribution

This content was originally published by Steve at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: