Re: conditionally create a Virtual Host?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



A new file was created on Z: for the sole purpose of having a designated file for Apache to seek.
The file is  called Z:\files\development\ApacheSmokeSignal.txt.

The httpd-vhosts.conf file was modified as follows:
<If "-d Z:/files/development/ApacheSmokeSignal.txt">
<VirtualHost *:8080>    
 DocumentRoot "Z:/files/xampp/htdocs"
 <Directory "Z:/files/xampp/htdocs">
  Options Indexes
  Require all granted
 </Directory>
</VirtualHost>
</If>

With this update, Apache starts so long as Z: is attached to the PC.  However, when Z: is not attached Apache does not start and these lines appear in the XAMPP Control Panel console:
9:54:20 PM  [Apache]  Error: Apache shutdown unexpectedly.
9:54:20 PM  [Apache]  This may be due to a blocked port, missing dependencies,
9:54:20 PM  [Apache]  improper privileges, a crash, or a shutdown by another method.
9:54:20 PM  [Apache]  Press the Logs button to view error logs and check
9:54:20 PM  [Apache]  the Windows Event Viewer for more clues
9:54:20 PM  [Apache]  If you need more help, copy and post this
9:54:20 PM  [Apache]  entire log window on the forums

There are no entries in error.log with a Wed Aug 21 21:54 or later timestamp.

Is the syntax for the If tag incorrect or was the wrong unary operator selected?


From: Nigel B. Peck <nigelbpeck@xxxxxxxxx>
Sent: Wednesday, August 21, 2019 9:45 PM
To: users@xxxxxxxxxxxxxxxx <users@xxxxxxxxxxxxxxxx>
Subject: Re: conditionally create a Virtual Host?
 
On Wed, 21 Aug 2019 at 7:21 pm, Heather Lotz <knot22@xxxxxxxxxxx> wrote:
Greetings,

In my development environment on a Windows 10 PC I have added the following to Apache's configuration files -

To httpd.conf:
Listen 8080

To httpd-vhosts.conf:
<VirtualHost *:8080>    
    DocumentRoot "Z:/files/xampp/htdocs"
<Directory "Z:/files/xampp/htdocs">
 Options Indexes
 Require all granted
</Directory>
</VirtualHost>

Note that Z: is mapped to an external storage device.

With this setup, Apache successfully accesses C: on port 80 and Z: on port 8080.  However, if the external storage device is not attached to the computer, Apache will not start.  Is there a way to check if Z: is present, and only create the virtual host if that device is plugged in so that Apache always starts?  If so, how can this be achieved?
I reckon you could wrap the <VirtualHost> in an<If> that checks for the existence of z:/ using an appropriate operator from:
Nigel B. Peck
Web Technologies and Linux Admin Mentor



[Index of Archives]     [Open SSH Users]     [Linux ACPI]     [Linux Kernel]     [Linux Laptop]     [Kernel Newbies]     [Security]     [Netfilter]     [Bugtraq]     [Squid]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Samba]     [Video 4 Linux]     [Device Mapper]

  Powered by Linux