virtualHost: the file "C:/Windows/Systehosts" is NOT savable

Problems with the Windows version of XAMPP, questions, comments, and anything related.

virtualHost: the file "C:/Windows/Systehosts" is NOT savable

Postby dotKer » 06. July 2021 05:51

I like to virtualHost in my XAMPP for the first time.

In order to stuy about virtualHost, I found the following.

Although I am not using wordpress, the url above is good for vertualHost.

I try to follow the above and I almost follow most of them.
However, on the last part of the url above, I failed in saving the file "C:/Windows/System32/drivers/etc/hosts" after I modified it.

When I try to save it, it says like the following.
C:/Window/System32/drivers/etc/hosts
이 파일을 열 수 있는 권한이 없습니다.
사용 권한에 대해서는 파일의 소유자나 관리자에게 문의하십시오.

The following is the translation of the above in English by myself.
C:/Window/System32/drivers/etc/hosts
You don't have the authorities for opening this file.
You should ask to the owner of the file or administator about authorities of using it


Why is it NOT savable?
How can I save the file?


if I enter "localhost" in the address bar of my browser, it says the following at the moment.
Forbidden
You don't have permission to access this resource.

Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/8.0.0 Server at localhost Port 80

How can I make the index.php readible when I open the page by entering "localhost" in the address bar of my browser?
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 06. July 2021 06:27

Hi,

The HOSTS file is not saveable for normal users, just for enhanced administrators.
So to save it you need to open your editor with enhanced administratoir rights first (rightclick -> run as administrator)
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 06. July 2021 07:37

So to save it you need to open your editor with enhanced administratoir rights first (rightclick -> run as administrator)


Thanks to the quote above, I could save the file ""C:/Windows/System32/drivers/etc/hosts".
But a problem is remained.

When I enter "localhost" in the address bar of my browser, it still says the following.
Forbidden
You don't have permission to access this resource.

Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/8.0.0 Server at localhost Port 80

Before I created virtualhost, the localhost normally opened without any "Forbidden">
But now, after I create virtualhost, opening the localhost is Forbidden.

How can I fix it?
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 06. July 2021 08:31

two things:

if you are using vhosts, each domain needs a vhost, even localhost.
because localhost does not have a vhost, it uses the default vhost which is always the very first vhost in the file.

your vhost definition is lacking access rules in the directory section. you need at least a Require all granted rule.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 06. July 2021 11:10

I think I should tell all what I did.


I installed XAMPP at (F:) xampp210706

if I enter "localhost" in the address bar of my browser,
index.php which is at "htdocs/" is shown.

I thought what about putting images in another driver (G:).
That will be, I think, fantastic for managing images.
That's why I want to make a virtualhost.

The following is my target.
php files are at "(F:) xampp210706/htdocs/" and images at (G:) images/
Php files can be shown with "http://myDomain.com" and images/image1.jpg will be shown with "http://images.myDoman.com/image1.jpg".



- I open "(F:) xampp210708/apache/conf/extra/httpd-vhost.conf"
- I add the following at the end of the page "httpd-vhost.conf".
<VirtualHost *:80>
DocumentRoot "G:images"
ServerName images.myDomain.com
<Directory "G:images">
</Directory>
</VirtualHost>


- I open "C:/Windows/System32/drivers/etc/hosts"
- I add "127.0.0.1 image.myDomain.com" at the end of the page "hosts" like the following.
# Copyright (c) 1993-2009 Microsoft Corp

# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.

: :
: :

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

127.0.0.1 adobeereg.com
127.0.0.1 http://www.adobeereg.com
127.0.0.1 activate.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com

127.0.0.1 image.myDomain.com


I restart the server and face the following.
Forbidden
You don't have permission to access this resource.

Apache/2.4.46 (Win64) OpenSSL/1.1.1h PHP/8.0.0 Server at localhost Port 80


What is wrong in my doing above?
Do you see any wrong thinkings or doings of mine?
Do you see how to solve my problems?
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 06. July 2021 11:29

If you just want to have access a different path for images you don't need a virtualhost.
Simply define an Alias and place the Access Rule for it, like so:
Code: Select all
Alias /images "G:/images"
<Directory "G:/images">
    Require all granted
</Directory>

After that you can address images from every domain like so http://localhost/images/filename.png


But okay, lets see what you defined in your vhost:

<VirtualHost *:80>
DocumentRoot "G:images"
ServerName images.myDomain.com
<Directory "G:images">
</Directory>
</VirtualHost>

Your paths are missing the directory separator /
It should be G:/images, not G:images
And you are still missing the Access rule "Require all granted"
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 06. July 2021 12:41

<VirtualHost *:80>
DocumentRoot "G:/images"
ServerName images.myDomain.com
<Directory "G:/images">
Require all granted
</Directory>
</VirtualHost>

As I change like the above, I can see a image at http://images.myDomain.com/images/filename.png.
It's good.
And so far so good.

As I enter http://myDomain.com/ in the address bar of my browser, I can see at G:/images/index.php instead of (F:)xampp210706/htdocs/.

What I want is the following.
"http://imges.myDomain.com/img1.jpg" opens G:/images/img1.jpg.
"http://imges.myDomain.com/img2.png" opens G:/images/img2.png.
"http://imges.myDomain.com/img3.gif" opens G:/images/img3.gif.

"http://myDomain.com/index.php" opens F:/xampp210706/htdocs/index.php
"http://www.myDomain.com/index2.php" opens F:/xampp210706/htdocs/index2.php
"http://anySubDomains_except_images.myDomain.com/index3.php" opens F:/xampp210706/htdocs/index3.php

What work do I need more for what I want above?
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 06. July 2021 13:38

As I change like the above, I can see a image at http://images.myDomain.com/images/filename.png.


The above is typo of the below.
As I change like the above, by entering "http://images.myDomain.com/images/filename.png", I can see a image of G:/images/filename.png.
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 06. July 2021 14:32

dotKer wrote:As I enter http://myDomain.com/ in the address bar of my browser, I can see at G:/images/index.php instead of (F:)xampp210706/htdocs/.

did you create a vhost for myDomain.com as well?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 06. July 2021 20:38

did you create a vhost for myDomain.com as well?

No, I didn't.
As you ask wheter I did create a vhost for myDomain.com as well, I try to add the following at the end of "(F:) xampp210708/apache/conf/extra/httpd-vhost.conf".
<VirtualHost *:80>
DocumentRoot "G:/images"
ServerName load.dot.kr
<Directory "G:/images">
Require all granted
</Directory>
</VirtualHost>

<VirtualHost *:80>
DocumentRoot "F:/xampp210706/htdocs"
ServerName *.dot.kr
<Directory "F:/xampp210706/htdocs">
Require all granted
</Directory>
</VirtualHost>


And I add the following at the end of "C:/Windows/System32/drivers/etc/hosts".
127.0.0.1 load.dot.kr
127.0.0.1 *.dot.kr


Then, I faced the following problem.

when I click the Apache start button of the control pannel, It says like the following.
오전 4:18:08 [Apache] Error: Apache shutdown unexpectedly.
오전 4:18:08 [Apache] This may be due to a blocked port, missing dependencies,
오전 4:18:08 [Apache] improper privileges, a crash, or a shutdown by another method.
오전 4:18:08 [Apache] Press the Logs button to view error logs and check
오전 4:18:08 [Apache] the Windows Event Viewer for more clues
오전 4:18:08 [Apache] If you need more help, copy and post this
오전 4:18:08 [Apache] entire log window on the forums
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 06. July 2021 21:32

ServerName cannot have any wildcards.
If you need wildcards, so must add them in ServerAlias, like so:

Code: Select all
<VirtualHost *:80>
    DocumentRoot "F:/xampp210706/htdocs"
    ServerName dot.kr
    ServerAlias *.dot.kr
    <Directory "F:/xampp210706/htdocs">
        Require all granted
    </Directory>
</VirtualHost>


ANd the windows hosts file does not support wild cards at all.
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 07. July 2021 02:15

If you need wildcards, so must add them in ServerAlias, like so:

I have changed "(F:) xampp210706/apache/conf/extra/httpd-vhost.conf" like the below.
Code: Select all
<VirtualHost *:80>
DocumentRoot "G:images"
ServerName images.myDomain.com
<Directory "G:images">
</Directory>
</VirtualHost>
<VirtualHost *:80>
DocumentRoot "F:/xampp210706/htdocs"
ServerName myDomain.kr
ServerAlias *.myDomain.kr
<Directory "F:/xampp210708/htdocs">
Require all granted
</Directory>
</VirtualHost>

ANd the windows hosts file does not support wild cards at all.

Since the windows hosts files does not support wild cards at all, I just remove "127.0.0.1 *.myDomain.com" from the old file below.
Code: Select all
127.0.0.1 images.myDomain.com
127.0.0.1 *.myDomain.com

127.0.0.1 adobeereg.com
127.0.0.1 www.adobeereg.com
127.0.0.1 activate.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com

The code above is before modified and the code below is after modified.
Code: Select all
127.0.0.1 load.dot.kr

127.0.0.1 adobeereg.com
127.0.0.1 www.adobeereg.com
127.0.0.1 activate.adobe.com
127.0.0.1 activate-sea.adobe.com
127.0.0.1 activate-sjc0.adobe.com
127.0.0.1 wwis-dubc1-vip60.adobe.com


Now I click Apache stop button and MySQL stop button in XAMPP Contorl Panel at "F:/xampp210620".
And I click Apache start button and mySQL Start button in XAMPP Contorl Panel at "F:/xampp210706".
As I open index.php at "F:/xampp210706/htdocs", it is well opened.
However, as I open index.php at "G:/images/index.php", it says like the following.
개인정보 보호 오류

연결이 비공개로 설정되어 있지 않습니다.

The below quote is the translation of the above quote to English by myself.
Personal information protection error

Connection is not set as non-open

"Personal information protection error" is actually browser title.

How can I read "G:/images/index.php", by entering "http://images.myDomain.com"?
Do you see any wrong doings of mime?
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Altrea » 07. July 2021 02:56

dotKer wrote:I have changed "(F:) xampp210706/apache/conf/extra/httpd-vhost.conf" like the below.
Code: Select all
<VirtualHost *:80>
DocumentRoot "G:images"
ServerName images.myDomain.com
<Directory "G:images">
</Directory>
</VirtualHost>
<VirtualHost *:80>


Didn't we already talk about missing directory separators?

dotKer wrote:However, as I open index.php at "G:/images/index.php", it says like the following.
개인정보 보호 오류

연결이 비공개로 설정되어 있지 않습니다.

The below quote is the translation of the above quote to English by myself.
Personal information protection error

Connection is not set as non-open

"Personal information protection error" is actually browser title.

Are you trying to access the images with https instead of http?
We don't provide any support via personal channels like PM, email, Skype, TeamViewer!

It's like porn for programmers 8)
User avatar
Altrea
AF Moderator
 
Posts: 11934
Joined: 17. August 2009 13:05
XAMPP version: several
Operating System: Windows 11 Pro x64

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby dotKer » 07. July 2021 03:49

Are you trying to access the images with https instead of http?

No, I don't use https://.
I use just http:// in accessing images/myDomain.com or *.myDomain.com.
dotKer
 
Posts: 40
Joined: 09. November 2020 13:28
XAMPP version: 7.4.11
Operating System: windows

Re: virtualHost: the file "C:/Windows/Systehosts" is NOT sav

Postby Nobbie » 07. July 2021 10:26

Now you dont have any entry for mydomain.com (myDomain.kr) in hosts file? That cannot work at all.

Actually you should take some time and read tutorials and documentation about VirtualHosts, its obvious that you have no idea of what you are doing there. We can help on technical issues, but this forum is not a replacement for basic knowledge, you must read plenty of documentation on yourself. This is a never ending thread with repeating errors.

P.S.: Its not a good idea to show in public your changes in the hosts file which you did in order to run a cracked version of Adobe Produucts.
Nobbie
 
Posts: 13176
Joined: 09. March 2008 13:04

Next

Return to XAMPP for Windows

Who is online

Users browsing this forum: No registered users and 182 guests