#16
  1. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    your virtualhost
    Code:
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/htdocs/z"
            ServerName zend.loc
            ErrorLog "/Applications/XAMPP/htdocs/z/local-error.log"
            <Directory "/Applications/XAMPP/htdocs/z">
                    Allow from all
                    AllowOverride All
                    Order Allow,Deny
                    Allow from all
                    Require all granted
            </Directory>
    </VirtualHost>
    has nothing setup to point to "http://z" ....it is setup to point to "http://zend.loc" [which is what the ServerName statement is for].
    So, to access your "z" folder, you would use http://zend.loc and make sure, in your hosts file, that you have a statement like this
    Code:
     127.0.0.1    zend.loc
    [in this case, I am not talking about the XAMPP hosts file...I am talking about the hosts file in /etc or /private/etc...or the SYSTEMS's host file].


    To access "z" using http://localhost/z should work "out-of-the-box" assuming your "default" DocumentRoot [in httpd.conf or apache2.conf for XAMPP] points to /Applications/XAMPP/htdocs.
    If it is not, then, you may need to insert a "default" VirtualHost statement before your other VirtualHost statements [but after your NameVirtualHost statement] that points to /Applications/XAMPP/htdocs .
    Last edited by DonR; October 29th, 2013 at 10:23 PM. Reason: added more info about hosts file
  2. #17
  3. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Hey thanks for not giving up man
    Originally Posted by DonR
    your virtualhost
    Code:
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/htdocs/z"
            ServerName zend.loc
            ErrorLog "/Applications/XAMPP/htdocs/z/local-error.log"
            <Directory "/Applications/XAMPP/htdocs/z">
                    Allow from all
                    AllowOverride All
                    Order Allow,Deny
                    Allow from all
                    Require all granted
            </Directory>
    </VirtualHost>
    has nothing setup to point to "http://z" ....it is setup to point to "http://zend.loc" [which is what the ServerName statement is for].
    So, to access your "z" folder, you would use http://zend.loc and make sure, in your hosts file, that you have a statement like this
    Code:
     127.0.0.1    zend.loc
    [in this case, I am not talking about the XAMPP hosts file...I am talking about the hosts file in /etc or /private/etc...or the SYSTEMS's host file]..
    A bit confused since you also said:
    Originally Posted by DonR
    since you are using Xampp, that is the only Apache conf you need to worry about or even mess with [as long as you never enabled the "web sharing" feature in MacOSX].
    I thought we stay away from /etc (/private/etc) and only works with XAMPP! No? What happened? Can you clarify like this:

    Files you need to change in order to have the vhost set up and running:

    1 - /Applications/XAMPP/etc/extra/httpd-vhosts.conf
    2 - /Applications/XAMPP/etc/hosts
    3 - /Applications/XAMPP/etc/httpd.conf

    Thank you
  4. #18
  5. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    I don't believe changing XAMPP's hosts will make "zend.loc" be accessible, just using its hosts file under /Applications/XAMPP/etc.
    You can try it and see if it works for you...but, if it doesn't then you will need to edit the OS's /etc/hosts file [not XAMPP's hosts file] in order for your zend.loc "local domain" to be accessible.
  6. #19
  7. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Well;

    I can now say with confident that we are back to square one. Really trying to get some conclusion here


    Last try:

    I want to have virtual host set up on http://z (so when I type http://z in browser I see the content of /Applications/XAMPP/htdocs/z). I take these steps:
    1 - Add this code to BOTH /Applications/XAMPP/etc/httpd.conf and /Applications/XAMPP/etc/extra/httpd-vhosts.conf
    Code:
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/htdocs/z"
            ServerName z
            ErrorLog "/Applications/XAMPP/htdocs/z/local-error.log"
            <Directory "/Applications/XAMPP/htdocs/z">
                    Allow from all
            </Directory>
    </VirtualHost>
    2 - /Applications/XAMPP/etc/hosts
    Code:
    127.0.0.1 z
    3 - Make the directory in /Applications/XAMPP/htdocs/z and copy all files in there.
    4 - Restart Apache

    Am I missing any steps?
    Thank you
  8. #20
  9. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    you only add the VirtualHost directives to your /Applications/XAMPP/etc/extra/httpd-vhosts.conf file...not your /Applications/XAMPP/etc/httpd.conf file.

    ALL VIRTUALHOSTS GO IN httpd-vhosts.conf ONLY!!!!

    IF the hosts in /Applications/XAMPP/etc isn't working to translate "z" as 127.0.0.1, then, you need to add
    Code:
    127.0.0.1 z
    to your System/OS's hosts file and reboot for it to take effect.
  10. #21
  11. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Hey we got something working!

    Now when I go to http://z it shows the content of /Applications/XAMPP/htdocs/


    What's left is to get it to z directory.

    /etc
    Code:
    127.0.0.1 z
    /Applications/XAMPP/etc/extra/httpd-vhosts.conf
    Code:
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/htdocs/z"
            ServerName z
            ErrorLog "/Applications/XAMPP/htdocs/z/local-error.log"
            <Directory "/Applications/XAMPP/htdocs/z">
                    Allow from all
                    AllowOverride All
                    Order Allow,Deny
                    Allow from all
                    Require all granted
            </Directory>
    </VirtualHost>
  12. #22
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    your VirtualHosts really shouldnt be under your htdocs folder.

    I suggest creating a folder under /Applications/XAMPP called vhosts and move your "z" folder and its contents to this new "vhosts" folder.
    Change the DocumentRoot in your "z" VirtualHost directive from
    Code:
     /Applications/XAMPP/htdocs/z
    to
    Code:
     /Applications/XAMPP/vhosts/z
    and change the path in <Directory /Applications/XAMPP/htdocs/z> to point to " /Applications/XAMPP/vhosts/z".

    restart xampp-apache2 and see if that works.
  14. #23
  15. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    HAH

    Got it working!

    The only thing that I did different from what you said was this:
    you only add the VirtualHost directives to your /Applications/XAMPP/etc/extra/httpd-vhosts.conf file...not your /Applications/XAMPP/etc/httpd.conf file.
    That didnt work for me! What worked was to add the directives to /etc/apache2/extra/httpd-vhosts.conf


    Thank you
  16. #24
  17. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    Thats messed up....that would mean that XAMPP apache isn't the one running, but, MacOSX's apache is.


    To fix that you would need to add the statement "/Applications/XAMPP" to your PATH before the system's other PATH statements.
    If I remember correctly, the PATH is setup in the .profile file in the HOME/<user>'s folder [not 100% on that location]
  18. #25
  19. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Originally Posted by DonR
    Thats messed up....that would mean that XAMPP apache isn't the one running, but, MacOSX's apache is.


    To fix that you would need to add the statement "/Applications/XAMPP" to your PATH before the system's other PATH statements.
    If I remember correctly, the PATH is setup in the .profile file in the HOME/<user>'s folder [not 100% on that location]
    Hi DonR;

    The problem is becuase there is no clarity between the 2 hosts. There is a lot of confusion on:

    1 - Which server is running right now?
    2 - Which server am I targeting when I run a service command?
    3 - What is the relaiton between "anything" in XAMPP and Mac's server.
    Last edited by English Breakfast Tea; November 2nd, 2013 at 09:18 PM.
  20. #26
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    re-read post #6 .

    you CANNOT use "sudo /usr/sbin/apachectl start|stop" to control the XAMPP Apache web server.

    you MUST use the XAMPP commands that are listed on the link I gave to you in post #6 to control XAMPP Apache.
  22. #27
  23. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Hi DonR


    Review...still wondering!

    When I go to http://z I see the content of /Applications/XAMPP/htdocs while it is supposed to show the content of /Applications/XAMPP/vhosts/z.

    What I have done so far:
    - Stop MAc server
    - Restart XAMPP
    - Edit /Application/XAMPP/etc/httpd.conf (for document root and incuding /Applications/XAMPP/etc/extra/httpd-vhosts.conf file

    - Edit /etc/hosts
    - Edit httpd-vhosts.conf

    ===================


    Code:
    bash-3.2# sudo apachectl stop
    Code:
    bash-3.2# /Applications/XAMPP/xamppfiles/xampp restart
    Restarting XAMPP for Mac OS X 1.7.3...
    XAMPP: Stopping Apache...ok.
    XAMPP: Stopping MySQL...not running.
    XAMPP: Stopping ProFTPD...not running.
    XAMPP: Starting Apache...already running.
    XAMPP: Starting MySQL...ok.
    XAMPP: Starting ProFTPD...ok.
    /Applications/XAMPP/etc/extra
    Code:
    bash-3.2# cat httpd-vhosts.conf 
    #
    # Virtual Hosts
    
    NameVirtualHost *:80
    <VirtualHost _default_:80>
            DocumentRoot "/Applications/XAMPP/htdocs/"
    </VirtualHost>
    
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/vhosts/z"
            ServerName z
            ErrorLog "/Applications/XAMPP/vhosts/z/local-error.log"
            <Directory "/Applications/XAMPP/vhosts/z">
                    Allow from all
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    /etc/hosts
    Code:
    bash-3.2# cat hosts
    ##
    # Host Database
    #
    # localhost is used to configure the loopback interface
    # when the system is booting.  Do not change this entry.
    ##
    127.0.0.1	localhost
    255.255.255.255	broadcasthost
    ::1             localhost 
    fe80::1%lo0	localhost
    
    127.0.0.1	activate.adobe.com
    220.244.223.153 	au.yahoo.com www.yahoo.com yahoo.com yahoo.com.au
    #Added by XAMPP Control
    127.0.0.1 192-168-1-6.tpgi.com.au
    
    
    192.168.1.1	pocket.wifi
    127.0.0.1 192-168-1-3.tpgi.com.au
    
    #Added by XAMPP Control
    127.0.0.1 192-168-1-3.tpgi.com.au
    
    127.0.0.1 z
    
    
    #Added by XAMPP Control
    127.0.0.1 192-168-1-4.tpgi.com.au
    
    bash-3.2#
    /Applications/XAMPP/etc/httpd.conf/
    Code:
    DocumentRoot "/Applications/XAMPP/xamppfiles/vhosts"
    
    # Virtual hosts
    Include /Applications/XAMPP/etc/extra/httpd-vhosts.conf
    A few points:
    1 - It is using with the /etc/hosts file (not /Applications/XAMPP/etc/hosts).
    2 - When I go to http://z I see the content of /Applications/XAMPP/htdocs. This means the only thing that is working is the /etc/hosts file and virtual host set up is being ignored!
    3 -http://localhost shows the content of /Applications/XAMPP/htdocs
    4 - http://vhosts goes to Google.com
    5 - Also why did you ask me to use /etc/hosts and not /Applications/XAMPP/etc/hosts?






    Any thoughts?
    Last edited by English Breakfast Tea; November 7th, 2013 at 03:15 PM.
  24. #28
  25. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    anytime you edit any of the *.conf files you will need to restart xampp-apache for those changes to take effect.

    What is that DocumentRoot change in your httpd.conf supposed to be for?
    the Default DocumentRoot directive should still be pointing to htdocs.
    the Include for the VirtualHosts httpd-vhosts.conf should be placed at the bottom of your httpd.conf file, so, none of it gets overridden by anything that would come after it.

    You will also need to create a "default" VirtualHost directive in your httpd-vhosts.conf file, just above your "z" directive, that points to your "default" DocumentRoot and with a ServerName that is the same as the ServerName used in your httpd.conf file.

    Originally Posted by taken from apache website
    If you are adding virtual hosts to an existing web server, you must also create a <VirtualHost> block for the existing host. The ServerName and DocumentRoot included in this virtual host should be the same as the global ServerName and DocumentRoot. List this virtual host first in the configuration file so that it will act as the default host.
    HERE is link to the virtualhosts help file from apache web site, if you want more indepth info on setting up the VirtualHost directives.
  26. #29
  27. A Change of Season
    Devshed Frequenter (2500 - 2999 posts)

    Join Date
    Mar 2004
    Location
    Next Door
    Posts
    2,671
    Rep Power
    171
    Still http://z shows the content og /Application/XAMPP/htdocs !!!
    Originally Posted by DonR
    anytime you edit any of the *.conf files you will need to restart xampp-apache for those changes to take effect.
    Which one do you mean?
    Code:
    /Applications/XAMPP/xamppfiles/xampp restart
    Code:
    /Applications/XAMPP/xamppfiles/xampp stopapache
    /Applications/XAMPP/xamppfiles/xampp startapache
    Originally Posted by DonR
    What is that DocumentRoot change in your httpd.conf supposed to be for?
    the Default DocumentRoot directive should still be pointing to htdocs.
    Since you mentioned I store files in /Applications/XAMPP/vhosts. I thought I should change the DocumentRoot to vhosts instead of htdocs.
    Originally Posted by DonR
    the Include for the VirtualHosts httpd-vhosts.conf should be placed at the bottom of your httpd.conf file, so, none of it gets overridden by anything that would come after it.
    It is
    Originally Posted by DonR
    You will also need to create a "default" VirtualHost directive in your httpd-vhosts.conf file, just above your "z" directive, that points to your "default" DocumentRoot and with a ServerName that is the same as the ServerName used in your httpd.conf file.
    Please see the updated httpd-vhosts.conf on post 27. I have added the default host.
  28. #30
  29. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    275
    Code:
    bash-3.2# cat httpd-vhosts.conf 
    #
    # Virtual Hosts
    
    NameVirtualHost *:80
    <VirtualHost _default_:80>
            DocumentRoot "/Applications/XAMPP/htdocs/"
    </VirtualHost>
    
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/vhosts/z"
            ServerName z
            ErrorLog "/Applications/XAMPP/vhosts/z/local-error.log"
            <Directory "/Applications/XAMPP/vhosts/z">
                    Allow from all
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>
    _default_ won't work, you need to use * ....like so:
    Code:
    bash-3.2# cat httpd-vhosts.conf 
    #
    # Virtual Hosts
    
    NameVirtualHost *:80
    
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/htdocs/"
    </VirtualHost>
    
    <VirtualHost *:80>
            DocumentRoot "/Applications/XAMPP/vhosts/z"
            ServerName z
            ErrorLog "/Applications/XAMPP/vhosts/z/local-error.log"
            <Directory "/Applications/XAMPP/vhosts/z">
                    Allow from all
                    AllowOverride All
                    Require all granted
            </Directory>
    </VirtualHost>


    could you plz post your httpd.conf from /Application/XAMPP/etc ?

    As for restarting after making changes, you only need to restart the Apache part, so, this would be correct:
    Code:
    /Applications/XAMPP/xamppfiles/xampp stopapache 
    /Applications/XAMPP/xamppfiles/xampp startapache

    Also, did you end up trying to put "127.0.0.1 z" in your /Application/XAMPP/etc/hosts file?..Or did you only put that in the OS's host file [/private/etc/hosts]?

IMN logo majestic logo threadwatch logo seochat tools logo