0

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?

Steve
  • 97
  • 1
  • 10
  • 1
    As a guess, you need to modify both Ubuntu guest `/etc/hosts` and `C:\Windows\system32\drivers\etc\hosts` files adding the following records: `127.0.0.1 website.dev`, `127.0.0.1 website2.dev` etc. The old way to force Windows DNS resolver to re-read the `hosts` file was `ipconfig /flushdns` (not sure that one still works, but worth to give it a try). – Ivan Shatsky Nov 18 '20 at 22:15
  • That's what I didn't want to end up doing, but I guess if there is no solution to my question by just using Ubuntu and Nginx, I'll have to use that solution. – Steve Nov 18 '20 at 22:55
  • 1
    Well, if you don't want to touch the `hosts` file (why?), you definitely can use any custom DNS server where you can define whatever you want. For UNIX one of the most popular tools for that kind of tasks is dnsmasq, see [this](https://stackoverflow.com/a/9695861/7121513) answer for the Windows alternative. – Ivan Shatsky Nov 18 '20 at 23:01
  • I misunderstood the whole thing. I thought I had to use the host file in Windows and not in Ubuntu. I will change the ones in Ubuntu, I had totally forgotten about that. – Steve Nov 19 '20 at 00:31

1 Answers1

1

I'm not that familiar with wordpress, but modifying /etc/hosts doesn't work?

  • I'm just trying to see if I can use Ubuntu and Nginx without having to manually add it on my Windows host file. But if there is no solution to my question, that might be the only thing I can do – Steve Nov 18 '20 at 22:56
  • Brainfart, yes, you are correct. I keep thinking that the host file only exists in the Windows directory and not in Ubuntu. – Steve Nov 19 '20 at 00:32