Keep Server Online
If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.
or
A donation makes a contribution towards the costs, the time and effort that's going in this site and building.
Thank You! Steffen
Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
| |
|
Topic: Win 10 WSL 2 - Ubuntu:20.04 - Apache/2.4.41 |
|
Author |
|
jsabarese
Joined: 19 May 2006 Posts: 10 Location: USA, State College
|
Posted: Wed 17 Nov '21 12:49 Post subject: Win 10 WSL 2 - Ubuntu:20.04 - Apache/2.4.41 |
|
|
Greetings. Having taken some hiatus from web dev etc., I've returned to find myself pleasantly surprised with the (so far) ease of use of the WSL for web dev/ Linux-like server practice under Windows 10. That said...
I'm encountering something I've never seen before, and I didn't find anything when I Googled it.
Attempting to load http://localhost/subdir/ (no index.file), the browser is redirected to http://localhost/subdir/undefined
I don't know if I have something configured incorrectly. I am also having difficulty configuring the "sites-enabled" to my satisfaction. I thought I knew how to use the Code: | <VirtualHost *:80>... | , but the results are not as I expected. Please advise.
DETAIL:
This is a "new" Win 10 installation as well, but I have an old HDD with years of development work on it.
WSL2 is out-of-the- box simple, in terms of mounting drives. I have my old dev drive as /mnt/h/apahce2/htdocs (where /mnt/h would be == H:\ , H:\Apache2, etc)
I want to serve files from the /mnt/h/apache2/htdocs/ directory on that slave HDD, but I can't seem to get my .conf file configured correctly. Or, perhaps it's a folder permissions issue. I've had issues configuring Apache under Ubuntu in the past, so I think my syntax is off. I need to do more research, obviously, but maybe someone here can spot what's not right straight away.
Code: |
#
# term:$ ln -s /mnt/h/Apache2/htdocs /var/www/htdocs
#
# sites-enabled filename: 000-default.conf
# aka the default Ubnuntu config
#
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>
#
# sites-enabled filename: 001-htdocs.conf
# where /var/www/htdocs is a symlink to /mnt/h/Apache2/htdocs
#
<VirtualHost *:80>
DocumentRoot "/var/www/htdocs"
ServerAlias htdocs
<Directory /var/www/htdocs/>
AllowOverride All
Options FollowSymLinks Includes Indexes
Require local
</Directory>
ErrorLog ${APACHE_LOG_DIR}/hdrive-error.log
CustomLog ${APACHE_LOG_DIR}/hdrive-access.log combined
</VirtualHost> |
In the past, the code format was more like this, which i also tried without success:
Code: |
<VirtualHost *:80>
DocumentRoot "/var/www/htdocs"
Alias "/htdocs/" "/var/www/htdocs/"
Alias "/htdocs" "/var/www/htdocs/"
<Directory "/var/www/htdocs">
AllowOverride All
Options FollowSymLinks Includes Indexes
Require local
</Directory>
</VirtualHost>
|
Any insight will be appreciated. I did create the /var/www/htdocs directory with ${USER} permissions. Thanks for reading!
My intended function / result here is to be able to access my different development directories mapping them as virtual hosts. is this not the correct way to map different directories on a local server?
e.g.
localhost/htdocs (as intended in the .conf example above)
localhost/some_experiment
localhost/something_else
it works as i want per directory if i modify the 000-default.conf file, but... that seems to be missing the point of what i'm trying to configure. Thanks for reading! |
|
Back to top |
|
jsabarese
Joined: 19 May 2006 Posts: 10 Location: USA, State College
|
Posted: Fri 19 Nov '21 17:42 Post subject: WSL User forums |
|
|
I seek help with the WSL on Win 10 for web dev. I am disappointed that I can't find much about it specifically, aside from a few mentions here and there about the basics, and mostly more about Linux admin Vs running Apache etc.
Are you aware of any LAMP on WSL users' forum?
Thanks for reading! |
|
Back to top |
|
tangent Moderator
Joined: 16 Aug 2020 Posts: 348 Location: UK
|
Posted: Sat 20 Nov '21 19:31 Post subject: |
|
|
WSL is a curious beast, and as you rightly point out, one for which there's not yet much detail on application hosting, versus functionality from a Linux admin perspective.
Presume you've confirmed there are no permission issues following the symbolic link to /mnt/h/Apache2/htdocs, specifically under WSL as the user running Apache?
Moreover, you don't say specifically why you want to host these development directories (mapped as virtual hosts) using Apache under WSL, rather than natively under Windows.
From an Apache perspective, apart from known configuration differences between Windows and Linux hosts (MPMs aside), functionality is similar, so why would one choose to run Apache under WSL rather than the host OS?
All WSL does is add another layer of abstraction, and performance overhead.
I too have had limited success with WSL to date, not least of which I can't run it on VM's running under VirtualBox (my chosen hypervisor), since SLAT pass-through (needed for WSL) is not yet supported by VirtualBox. |
|
Back to top |
|
James Blond Moderator
Joined: 19 Jan 2006 Posts: 7373 Location: Germany, Next to Hamburg
|
Posted: Sun 21 Nov '21 22:19 Post subject: |
|
|
I'm not sure if the symlink is working like you think. Did you try to use the /mnt/h/apache2/htdocs/ as DocumenRoot and Directory settings? |
|
Back to top |
|
|
|
|
|
|