Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

After modifying the httpd.conf to include my virtual host configuration: Include /private/etc/apache2/extra/httpd-vhosts.conf, I added the following to my virtual host configuration file:

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.

#
# Use name-based virtual hosting.
#
NameVirtualHost *:8085

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot "/usr/docs/dummy-host.example.com"
#    ServerName dummy-host.example.com
#    ServerAlias www.dummy-host.example.com
#    ErrorLog "/private/var/log/apache2/dummy-host.example.com-error_log"
#    CustomLog "/private/var/log/apache2/dummy-host.example.com-access_log" common
#</VirtualHost>

#<VirtualHost *:80>
#    ServerAdmin webmaster@dummy-host2.example.com
#    DocumentRoot "/usr/docs/dummy-host2.example.com"
#    ServerName dummy-host2.example.com
#    ErrorLog "/private/var/log/apache2/dummy-host2.example.com-error_log"
#    CustomLog "/private/var/log/apache2/dummy-host2.example.com-access_log" common
#</VirtualHost>

<VirtualHost *:8085>
    ServerName 127.0.0.1:8085
    DocumentRoot "/Users/path/to/root/"
</VirtualHost>

Then I restarted my apache server, and it says that 127.0.0.1 cannot be found. I checked everything that I did is correct, but I could not figure what the problem is.

  • The path to the directory that I want to serve exist.
  • sudo apachectl -S returns

>

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:8085                 is a NameVirtualHost
         default server 127.0.0.1 (/private/etc/apache2/extra/httpd-vhosts.conf:44)
         port 8085 namevhost 127.0.0.1 (/private/etc/apache2/extra/httpd-vhosts.conf:44)
Syntax OK

<

Can someone point to me how I can get my virtual host running?

[EDIT]

Error Log (/var/log/apache2/error_log):

[Sat Jul 19 19:12:38 2014] [notice] SIGHUP received.  Attempting to restart
[Sat Jul 19 19:12:38 2014] [notice] Digest: generating secret for digest authentication ...
[Sat Jul 19 19:12:38 2014] [notice] Digest: done
[Sat Jul 19 19:12:38 2014] [notice] Apache/2.2.26 (Unix) DAV/2 mod_ssl/2.2.26 OpenSSL/0.9.8y configured -- resuming normal operations
share|improve this question
    
127.0.0.1 is not a name, it's an IP address. –  yoonix Jul 18 at 19:46
    
Are you trying to access http://127.0.0.1, or http://127.0.0.1:8085? What's giving you the "cannot be found" error, and what's the exact error message? –  Shane Madden Jul 18 at 20:27
    
Sorry, I meant 127.0.0.1:8085. "Cannot be found" as if the server does not exist. I put a screenshot up later. –  swtdrgn Jul 18 at 21:35
    
Can you provide Error log of apache –  Innovator Jul 19 at 2:57
    
[Sat Jul 19 19:12:38 2014] [notice] SIGHUP received. Attempting to restart [Sat Jul 19 19:12:38 2014] [notice] Digest: generating secret for digest authentication ... [Sat Jul 19 19:12:38 2014] [notice] Digest: done [Sat Jul 19 19:12:38 2014] [notice] Apache/2.2.26 (Unix) DAV/2 mod_ssl/2.2.26 OpenSSL/0.9.8y configured -- resuming normal operations –  swtdrgn Jul 19 at 23:12

1 Answer 1

In this case, I think what you want is an IP-based virtual host:

<VirtualHost 127.0.0.1:8085>
    DocumentRoot "/Users/path/to/root/"
</VirtualHost>

Can you explain more what you're trying to accomplish?

share|improve this answer
    
I have multiple projects that I want to test locally before deploying them remotely. So, I want to setup a virtual host that will serve these projects locally for testing purpose instead of testing them remotely, and I'm having some trouble with setting a virtual host that I can test my changes. –  swtdrgn Jul 18 at 21:42
    
I still can't assess 127.0.0.1:8085 with the following change. Thanks for the answer. –  swtdrgn Jul 18 at 21:43

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.