Trouble adding virtual host
Posted by: Bobn (---.lightspeed.stlsmo.sbcglobal.net)
Date: October 15, 2018 07:59AM

It has been a while since I created a virutal host and I'm having problems.

I just installed the newest release of WAMP64 on a computer which has never had WAMP on it.

I am getting the following messages when I try to create a virtual host. I assume the 2nd and 3rd errors are due to the open failure.

-------------------------------
Warning: fopen(C:/Windows/system32/drivers/etc/hosts): failed to open stream: Resource temporarily unavailable in C:\wamp64\www\add_vhost.php on line 446
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 486824 fopen ( ) ...\add_vhost.php:446

( ! ) Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp64\www\add_vhost.php on line 447
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 487440 fwrite ( ) ...\add_vhost.php:447

( ! ) Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp64\www\add_vhost.php on line 484
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 487168 fclose ( ) ...\add_vhost.php:484
-------------------------------------------------

I checked and the hosts file is located at C:\Windows\System32\drivers\etc\ and I can open it in an editor

The virtual host I'm trying to create resides in: C:\wamp64\www\WP

I've tried different virtual host names with no difference in results - I followed the rule "No diacritical characters (éçëñ) - No space - No underscore(_)"

I've tried running WAMP64 normally and I also ran it As Administrator.

What am I doing wrong?

What can I do to deleted the partially defined virtual hosts?

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Otomatic (Moderator)
Date: October 15, 2018 09:17AM

Hi,

Please READ (and answer) BEFORE YOU ASK A QUESTION

------------------------------------------------------------------------------------------------------------
Wampserver 3.1.5 32 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
Wampserver 3.1.5 64 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
PhPMyadmin 4.8.3 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Bobn (---.lightspeed.stlsmo.sbcglobal.net)
Date: October 15, 2018 09:58AM

1 - Windows version used (Specify version number AND whether 32 or 64 bit)
windows 7 pro 64bit

2 - Version WampServer (Specify version number AND whether 32 or 64 bit)
WampServer Version 3.1.4 64bit - installed from file wampserver3.1.4_x64.exe downloaded from
[sourceforge.net]

It was a vanilla install, I changed nothing and specified nothing - I just let it run (in Administrator mode, of course)

3 - Apache Version
2.4.35, as delivered in the WAMP file I installed from

4 - PHP Version
7.2.10, as delivered in teh WAMP file I installed from

5 - MySQL Version
5.7.23, as delivered in WAMP file I installed from

5a - MariaDB version if applicable n/a

6 - What color is the WampServer icon (in the notification area of the taskbar)
GREEN


7 - In the file c:\Windows\System32\drivers\etc\hosts, what are the active lines? * Active means no # at the beginning of the line. --- there are no "actrive" lines, all are comments, i.e., all begin with #


If the WampServer icon is green:

8 - Do you have access to localhost (Homepage WampServer)?
YES
8a - If so, is there an error message at the bottom of the page?
NO

9 - Do you have access to phpMyAdmin?
Yes - I am able to create databases and users, and such.

10 - If you refer to an error message, please include the EXACT wording of the error in your post
As I posted in my orginal message:
-------------------------------
Warning: fopen(C:/Windows/system32/drivers/etc/hosts): failed to open stream: Resource temporarily unavailable in C:\wamp64\www\add_vhost.php on line 446
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 486824 fopen ( ) ...\add_vhost.php:446

( ! ) Warning: fwrite() expects parameter 1 to be resource, boolean given in C:\wamp64\www\add_vhost.php on line 447
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 487440 fwrite ( ) ...\add_vhost.php:447

( ! ) Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp64\www\add_vhost.php on line 484
Call Stack
# Time Memory Function Location
1 0.0000 410920 {main}( ) ...\add_vhost.php:0
2 0.0156 487168 fclose ( ) ...\add_vhost.php:484
-------------------------------------------------

11 - If you use an Antivirus and / or Firewall, please include the names of these
AVG ZoneAlarm

12 - What is the full path to the installation of WampServer (eg D:\wamp\)
c:/wamp64

13 - If you have one or more Virtual Hosts defined, please show their definition(s)
Contents of httpd-vhosts.conf (from C:\wamp64\bin\apache\apache2.4.35\conf\extra\)
-------------------------------------
# Virtual Hosts
#
<VirtualHost *:80>
ServerName localhost
ServerAlias localhost
DocumentRoot "${INSTALL_DIR}/www"
<Directory "${INSTALL_DIR}/www/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName wpdevelop
DocumentRoot "c:/wamp64/www/wp"
<Directory "c:/wamp64/www/wp/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName wpdeveloper
DocumentRoot "c:/wamp64/www/wp"
<Directory "c:/wamp64/www/wp/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName wptheme
DocumentRoot "c:/wamp64/www/wp"
<Directory "c:/wamp64/www/wp/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>


#
<VirtualHost *:80>
ServerName wordpress
DocumentRoot "c:/wamp64/www/wp"
<Directory "c:/wamp64/www/wp/">
Options +Indexes +Includes +FollowSymLinks +MultiViews
AllowOverride All
Require local
</Directory>
</VirtualHost>
------------------------------------------

If I try to load any of the virtual hosts (click on them in the virtual host list), the browser goes after the Internet domains, not local virtual hosts. Which is exactly what it should do since the virtual host configurations did not complete because the host file could not be opened and, thus, was not updated.

And, as I said before, I've run WAMP normally and also "As Administrator" and the results or the same.

In the past, when editing the host files manually for my own purposes, I've never been able to save the hosts file, even running Notepad As Administrator. When I have needed to change hosts, in the past, I had to start Windows in Safe Mode and then run Notepad As Administrator.

The problem I'm having with WAMP is that, for whatever reason, it can't open the hosts file - I don't know if it could update it if the hosts file could be opened - haven't gotten that far yet.

What other information do you want?

If I delete the entries in the httpd-vhosts.conf file for the virutal hosts which failed to be configured completely, will that remove all traces of them?

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: RiggsFolly (Moderator)
Date: October 15, 2018 10:30AM

Hi,

7 - In the file c:\Windows\System32\drivers\etc\hosts, what are the active lines? * Active means no # at the beginning of the line. --- there are no "actrive" lines, all are comments, i.e., all begin with #

The hosts file should contain a minimum of
127.0.0.1 localhost
::1 localhost

Then for each Virtual Host it should also contain


127.0.0.1 wpdeveloper
::1 wpdeveloper

So yours should look like

127.0.0.1 localhost
::1 localhost

127.0.0.1 wpdeveloper
::1 wpdeveloper

It is ok to edit this file manually.

---------------------------------------------------------------------------------------------
(Windows 10 Pro 64bit) (Wampserver 3.1.3 32bit & 64bit)
<Apache 2.4.29/2.2.31> <PHP 7.2/7.1/7.0/5.6/5.5/5.4> <MySQL 5.7.19/5.6.39/5.5.28>
<MariaDB 10.2.14> <phpMyAdmin4.8.1> <MySQL Workbench 6.3.10>

Read The Manuals Apache -- MySQL -- PHP -- phpMyAdmin
Get your Apache/MySQL/mariaDB/PHP ADDONs here from the WAMPServer alternate Repo
-X-X-X- Backup your MySQL databases regularly Here is How dont regret it later! Yes even when developing -X-X-X-

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Otomatic (Moderator)
Date: October 15, 2018 11:16AM

Hi,

Very often, the hosts file is locked for writing, and sometimes for access, by the antivirus or by another anti-machine.
You have to see in the anti-virus settings to put the hosts file in exception.

See also (Note 2) of TROUBLESHOOTING TIPS

------------------------------------------------------------------------------------------------------------
Wampserver 3.1.5 32 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
Wampserver 3.1.5 64 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
PhPMyadmin 4.8.3 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Otomatic (Moderator)
Date: October 15, 2018 02:01PM

Hi,

Quote

Warning: fopen(C:/Windows/system32/drivers/etc/hosts): failed to open stream: Resource temporarily unavailable in C:\wamp64\www\add_vhost.php on line 446

This error is - for me - very strange!
Indeed, if the hosts file cannot be opened or is not writable there should be an error message BEFORE trying to create a VirtualHost :
	elseif($c_hostsFile_writable !== true) {
		$message[] = '<p class="warning">'.sprintf($langues['FileNotWritable'],$c_hostsFile).'</p>';
		$errors = true;
	}
The variable $c_hostsFile_writable is filled when Wampserver is launched by tests on:
- the presence of the hosts file
- the possibility of opening it
- the possibility of writing on it
If everything is possible then the variable is "true". If only one of the possibilities does not exist, then the variable is "false".
In addition, if this variable is "false", there is an error message at the bottom of the Wampmanager icon menu plus an error message une php_error.log file : The file C:/Windows/system32/drivers/etc/hosts is not writable


------------------------------------------------------------------------------------------------------------
Wampserver 3.1.5 32 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
Wampserver 3.1.5 64 bit - Apache 2.4.37 - PHP 7.2.12/7.1.24/7.0.32/5.6.38 - MySQL 5.7.23 - MariaDB 10.3.10
PhPMyadmin 4.8.3 - MysqlDumper 1.24.5
on W10 and W7 Pro 64 bit
Documentation Apache - Documentation PHP - Documentation MySQL - Wampserver install files & addons
« Ce n'est pas parce qu'ils sont nombreux à avoir tort, qu'ils ont forcément raison. Coluche »
« It's not because they are many to be wrong, they are necessarily right. Coluche »

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Bobn (---.lightspeed.stlsmo.sbcglobal.net)
Date: October 16, 2018 10:38PM

Here's the contents of C:\Windows\System32\drivers\etc\hosts

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost


I disabled my anti-virus (AVG) and tried again, same errors.

I then added C:/Windows/system32/drivers/etc/hosts as an exception in AVG protection and tried again - same errors.

There is no error message at the bottom of the WAMP icon list (shown by left clicking WAMP icon in system tray)

I'm going to start Windows in Safe mode, edit the hosts file, save it, and restart normally - I'll post the results.

Options: ReplyQuote
Re: Trouble adding virtual host
Posted by: Bobn (---.lightspeed.stlsmo.sbcglobal.net)
Date: October 17, 2018 06:20AM

I did the following:

I deleted the exception I had created in AVG - don't like exceptions and I'd not had to add any execptions on other comptuers where I've installed and used WAMP.

Copied the hosts file example you showed to the clipboard, pasted it into a new Notepad file, and saved it.

I shutdown Windows and restarted in Safe Mode.

I then used Notepad, running as Administrator, to edit hosts file and put in the example you provided. aved the file and restarted Windows in normal mode.

I tried the virtual host wepdeveloper (the example you provided and that I put in the hosts file) and I was able to pull the site up.

I tried to create another virtual host and got the same messages I've reported earlier.[/list]

So, I have a work-around to create new virtual hosts but the automated method is still failing.

One more thing - everytime I start WAMP (using the Programs Menu item created during installation) I get the "do you want to run this program from an unknown author" sort of message and I have to click Yes to start WAMP.

I don't remember ever seeing that on other computers running WAMP. Is there a way to get rid of that message?

Options: ReplyQuote


Sorry, only registered users may post in this forum.