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.

I managed to run one website on my apache2 virtualserver using port 80. now I want to have another site running on the same server, but I can't manage it. either I corrupt my old page or my folder of the new page is displayed. For the new page i use port 81.

Here are my steps :

copied all items to /data/website2 and made a link to /var/www/website2

I put my configuration to /etc/apache2/sites-available/website2

<VirtualHost *:81>
        ServerAdmin me@localhost.de
        DocumentRoot /var/www/website2

        <Directory /var/www/website2>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

now I enable this page using : a2ensite website2 and then reload apache2 : sudo service apache2 reload

when I now enter the website from local using my ip adress :

192.168.xxx.xx/website2  my www folder is displayed. Did I link something incorrect maybe?

Do I have to configurate my /etc/apache2/hosts config?

in my hosts file I have this :

127.0.0.1       localhost

Of course I enabled my port 81 in etc/apache2/ports.conf

Thank you in Advance. If any Information is missing, let me know.

share|improve this question

1 Answer 1

I guess your are running local server :

You can run both website on port 80 and use ServerName directive in your virtualhost (but this involve to edit your host file to fit the vhost directive)

VirtualHost for your first website :

<VirtualHost *:80>
        ServerName www.example.com
        ServerAdmin me@localhost.de
        DocumentRoot /var/www/website

        <Directory /var/www/website>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

VirtualHost for your second website :

<VirtualHost *:80>
        ServerName www.example2.com
        ServerAdmin me@localhost.de
        DocumentRoot /var/www/website2

        <Directory /var/www/website2>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                Allow from all
        </Directory>
</VirtualHost>

You need to edit your host file with www.example.com and www.example2.com entries.

share|improve this answer
    
Maybe you could try Alias directive in you vhost too : here –  mterrasson Aug 13 '13 at 12:28
    
Am I allowed to use localhost as ServerName for both? and just have different directories for the sites? Or does this cause problems? –  RayofCommand Aug 13 '13 at 12:46
    
This is possible but I prefer not to use localhost. You can have only one vhost (For your first website) and add an Alias directive (Alias /website2 /path/to/site) that point to your second website directory wich have to be inside your DocumentRoot –  mterrasson Aug 13 '13 at 14:23

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.