logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

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.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: Win 10 Apache 2.4.23 simple virtual hosts setup
Author
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Thu 13 Oct '16 2:54    Post subject: Win 10 Apache 2.4.23 simple virtual hosts setup Reply with quote

I have searched the web quite a bit and have not found an answer to my virtual host problem:

I am running Win 10 Pro 64x. XAMPP 7.0.9 is installed at g:/xampp. I have two directories which I need to access as local hosts: g:/8081dmreed and g:/8082devsite.

Can someone please provide me exact coding regarding the Windows hosts file and the Apache files httpd.conf, httpd-vhosts.conf, and any additional files.
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 13 Oct '16 6:55    Post subject: Reply with quote

Hello Poway,

Start your favorite text editor as administrator (right click on icon and choose "Run as Administrator").

Open C:\Windows\System32\drivers\etc\hosts (the file has no extension).
Add to the file the lines below and save:
Code:
127.0.0.1       dmreed
127.0.0.1       devsite
-----------------------------------------
Rename G:\xampp\apache\conf\extra\httpd-vhosts.conf to something like httpd-vhosts.xampp to preserve it.

Create a new one with the stuff below:
Code:
######################################################################
# G:\xampp\apache\conf\extra\httpd-vhosts.conf
#
#    Location       hostname         url
# g:/xampp/htdocs   localhost    http://localhost/
# g:/8081dmreed     dmreed       http://dmreed/
# g:/8082devsite    devsite      http://devsite/
######################################################################

# Preserve localhost
<VirtualHost _default_:80>
    DocumentRoot "g:/xampp/htdocs"
    ServerName localhost
</VirtualHost>

# Site: dmreed
<VirtualHost *:80>
    DocumentRoot "g:/8081dmreed"
    ServerName dmreed
    CustomLog "g:/8081dmreed/dmreed.access.log" combined
    <Directory "g:/8081dmreed">
       Options All
       AllowOverride All
       Require all granted
    </Directory>
</VirtualHost>

# Site: devsite
<VirtualHost *:80>
    DocumentRoot "g:/8082devsite"
    ServerName devsite
    CustomLog "g:/8082devsite/devsite.access.log" combined
    <Directory "g:/8081dmreed">
       Options All
       AllowOverride All
       Require all granted
    </Directory>
</VirtualHost>


Restart Apache and give the URLs a try.

Note: It looks like Xampp has the vhosts file already included in httpd.conf so you should not need to do anything to it.

Note 2: It has been my experience in the past that some anti-virus will quarantine the hosts file if it has been tampered with. In that case you will have to unquarantine it and add an exception in your AV for it.

Enjoy neighbor,

-Santee-
Back to top
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Thu 13 Oct '16 7:26    Post subject: Reply with quote

I have seen many "solutions" which say port 80 is a problem for Apache under Win 10.

Applied your code. I get the following when running XAMPP Control Panel as Administrator:


Moderator Edit: Only the part that pertains to the subject remains:

10:21:11 PM [Apache] Press the Logs button to view error logs and check
10:21:11 PM [Apache] the Windows Event Viewer for more clues
Back to top
glsmith
Moderator


Joined: 16 Oct 2007
Posts: 2268
Location: Sun Diego, USA

PostPosted: Thu 13 Oct '16 7:50    Post subject: Reply with quote

Well yes it is, but did your xampp work after install and is it running on post 80 or something else? It's usually PID 4 in the message however.

Change the 80 to whatever it is your running it on. 80 is the default that Apache is usually set to.
Back to top
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Thu 13 Oct '16 9:03    Post subject: Reply with quote

cannot find anything in logs.

80 is a problem in Win 10.

Changing it to 8080....I get the same error as last time.
Back to top
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Fri 14 Oct '16 8:43    Post subject: Reply with quote

Maybe I can get an answer from someone who is actually running Win 10 with local hosts similar to my initial question.
Back to top
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Mon 17 Oct '16 14:40    Post subject: Reply with quote

thanks glsmith...that solved the local hosts problem for me...much appreciated.
Back to top
dmreed



Joined: 09 Oct 2016
Posts: 6
Location: Poway, CA

PostPosted: Tue 18 Oct '16 1:01    Post subject: Reply with quote

thanks glsmith, finally worked!
Back to top


Reply to topic   Topic: Win 10 Apache 2.4.23 simple virtual hosts setup View previous topic :: View next topic
Post new topic   Forum Index -> Apache