-2

I am paying for a Virtual Private Server with Linode. I recently set it up with apache to host two different websites. Now that I've added the sites, I can no longer access my index.html file at /var/www/. For some reason, my IP address points to the last site that I configured. Is there any way that I can have my sites point to their public folders, and my IP address point to the /var/www/ folder like it was when I set it up? I tried searching for an answer, but found nothing; perhaps I'm not sure what to search for.

Update

I realize that after going through the linode steps to hosting a website I deactivated the default file which pointed to the /var/www/ directory:

sudo a2dissite default

So I enabled it with

sudo a2ensite default
sudo service apache2 restart

This made the IP address serve up the files in the desired directory, but now the first site I enabled/configured also serves up the same default files (and no longer the site's files, as specified in /etc/apache2/sites-available/).

How can I have all three virtual hosts? Two name-based, and one IP-based?

3
  • 3
    An IP address does not point to a directory structure. It is a machine address that hosts servers listening on various ports. In this case, you are wanting a web server to respond. And the last server you're setting up is responding. You need to look up setting up virtual hosting on your web server so multiple websites are served out by the same http server in addition to the original server that kept its files in /var/www/. The downvote is probably because the question makes absolutely no sense as per the above paragraph. Sep 4, 2013 at 5:47
  • 2
    The question does make sense, if you understand what is being asked.
    – Lawrence
    Sep 4, 2013 at 6:11
  • Well, I've edited the question to try to make it more clear. I realize I'm lost, and new to this. And I have no idea how to make the question more useful. I haven't found anything helpful on this site, or searching Google.
    – bozdoz
    Sep 4, 2013 at 6:52

2 Answers 2

1

You can setup 3 virtual hosts -
<VirtualHost *:80>
ServerName x.x.x.x
DocumentRoot /var/www
</VirtualHost>
 
<VirtualHost *:80>
ServerName name1
DocumentRoot /var/www/name1
</VirtualHost>
 
<VirtualHost *:80>
ServerName name2
DocumentRoot /var/www/name2
</VirtualHost>

7
  • I have that. It's still only serving up two of the three sites.
    – bozdoz
    Sep 4, 2013 at 6:50
  • Can you put the config file onto pastebin or something so we can see it ?
    – Lawrence
    Sep 4, 2013 at 7:01
  • @bozdoz It sounds like you are trying to configure name-based virtual hosting. The problem you're describing (only one configured site showing up when you have multiple <VirtualHost> definitions for a specific host/port) is usually because you are missing the NameVirtualHost directive, or because you're trying to access the site by IP (e.g. http://10.0.0.1) instead of name: Without the name Apache serves the first matching site it finds in its configuration.
    – voretaq7
    Sep 4, 2013 at 19:09
  • I am trying to access the site by IP. I also have two others I want to have accessible by domain name. @voretaq7
    – bozdoz
    Sep 4, 2013 at 19:30
  • @bozdoz Windmills do not work that way -- You must pick either Address-based virtual hosting (a separate IP for each site, and configure your server that way. You will be able to access sites by IP or Domain Name and they'll work either way), or Name-based virtual hosting (using NameVirtualHost and ServerName and accessing sites by domain name only so that an appropriate Host: header is presented to the server). See the docs I linked to previously.
    – voretaq7
    Sep 4, 2013 at 19:50
0

as far as I understood you have some kind of debian\ubuntu installed there?

sites-avalable intended to contain config for sites that can be run at your server, directory for sites that actually run at your server is sites-enabled.

You can create symlink manually or use command a2ensite mysite which will do all necessary work for you

More details here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .