Skip to content

Instantly share code, notes, and snippets.

@monkishtypist
Last active July 8, 2024 11:02
Show Gist options
  • Save monkishtypist/c16f3f7fb0c689641e1a156cd839cecf to your computer and use it in GitHub Desktop.
Save monkishtypist/c16f3f7fb0c689641e1a156cd839cecf to your computer and use it in GitHub Desktop.
Nginx virtual host example for Windows Subsystem for Linux (WSL)
# Location: /mnt/c/windows/system32/drivers/etc/hosts
127.0.0.1 virtualhost.local www.virtualhost.local
<?php
// Location: /mnt/c/server/www/virtualhost.local/html/index.php
phpinfo();
# Location: /etc/nginx/sites-available/virtualhost.local.conf
server {
listen 80;
listen [::]:80;
root /mnt/c/server/www/virtualhost.local/html;
index index.php index.html index.htm index.nginx-debian.html;
server_name virtualhost.local www.virtualhost.local;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
}
location ~ /\.ht {
deny all;
}
}
@monkishtypist
Copy link
Author

@z1haze every instance is different but double check your hosts file. Make sure your symlink is correct. And triple check for typos. ¯\_(ツ)_/¯

@logan-shakya
Copy link

Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment