Skip to content

Commit 1fad917

Browse files
committed
Add support for WSL to Nginx version
1 parent f7dff35 commit 1fad917

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

virtualhost-nginx.sh

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,17 @@ if [ "$action" == 'create' ]
123123
echo -e $"Host added to /etc/hosts file \n"
124124
fi
125125

126+
### Add domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux)
127+
if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ]
128+
then
129+
if ! echo "127.0.0.1 $domain" >> /mnt/c/Windows/System32/drivers/etc/hosts
130+
then
131+
echo $"ERROR: Not able to write in /mnt/c/Windows/System32/drivers/etc/hosts (Hint: Try running Bash as administrator)"
132+
else
133+
echo -e $"Host added to /mnt/c/Windows/System32/drivers/etc/hosts file \n"
134+
fi
135+
fi
136+
126137
if [ "$owner" == "" ]; then
127138
chown -R $(whoami):www-data $userDir$rootDir
128139
else
@@ -148,6 +159,13 @@ if [ "$action" == 'create' ]
148159
newhost=${domain//./\\.}
149160
sed -i "/$newhost/d" /etc/hosts
150161

162+
### Delete domain in /mnt/c/Windows/System32/drivers/etc/hosts (Windows Subsytem for Linux)
163+
if [ -e /mnt/c/Windows/System32/drivers/etc/hosts ]
164+
then
165+
newhost=${domain//./\\.}
166+
sed -i "/$newhost/d" /mnt/c/Windows/System32/drivers/etc/hosts
167+
fi
168+
151169
### disable website
152170
rm $sitesEnable$domain
153171

0 commit comments

Comments
 (0)