1

I'm trying to setup on ubuntu, virtualhosts on different ports, but I can get it work. My configuration in sites-available looks like

NameVirtualHost 127.0.0.1:5050
Listen 5050
<VirtualHost 127.0.0.1:5050>
ServerName localhost
DocumentRoot "/var/www/example"
<Directory />
    Options FollowSymLinks
    AllowOverride None
</Directory>
<Directory /var/www/example/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride None
    Order allow,deny
    allow from all
</Directory>
</VirtualHost>

and I added to the host file

127.0.0.1:5050 localhost
2
  • Do you know for a fact that the hosts file accepts that kind of notation? I've never seen anything like it. What happens if you open 127.0.0.1:5050?
    – Pekka
    Jun 5, 2012 at 18:31
  • Doesn't seems to work, I've been changing the hosts now to 127.0.0.1:5050. What would be great if I could run a localhost:80 and another one on port higher than 4000
    – deroccha
    Jun 5, 2012 at 18:36

1 Answer 1

1

The hosts file maps names to ip addresses. It cannot be used to do anything with ports. You may only specify ports as part of your url (such as http://localhost:5050/).

You can certainly run virtual hosts on ports other than 80, but you have to explicitly reference the port as I've indicated.

3
  • I have been removing from hosts the referenced line but without any results
    – deroccha
    Jun 5, 2012 at 18:50
  • What doesn't work? Show the actual commands that you're running and any error messages that output when not working as expected. Use curl or wget for testing things, since these are command line tools and friendlier for this sort of thing.
    – larsks
    Jun 5, 2012 at 19:33
  • okay I've been figure out that the port has to be activated in /etc/apache2/ports.conf but now is pointing to another directory root and I can not find the configuration where is this enabled?My error log shows that the webroot is on /etc/apache2/htdocs located, and the virtualhost is pointing to /var/www/example
    – deroccha
    Jun 5, 2012 at 20:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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