Report this

What is the reason for this report?

Virtual Hosts : multi domains on same server ?

Posted on June 13, 2014

My /etc/hosts:

107.170.137.119 www.usama-ahmed.tk usama-ahmed.tk 
107.170.137.119 www.projects-usama-ahmed.tk projects-usama-ahmed.tk

When I comment the first line, it properly loads the projects-usama-ahmed.tk and vice versa. I also edited /etc/apache2/apache2.conf:

HostnameLookups On
  • usama.conf:
<VirtualHost www.usama-ahmed.tk:80> 
    ServerAdmin webmaster@localhost 
    DocumentRoot /var/www/html/usama 
    ServerName www.usama-ahmed.tk 
    ServerAlias usama-ahmed.tk 
    ErrorLog /var/www/html/usama/logs/error.log 
    LogLevel warn 
    CustomLog /var/www/html/usama/logs/access.log combined 
    <Directory /var/www/html/usama> 
        Options FollowSymLinks 
        AllowOverride All 
    </Directory> 
</VirtualHost>
  • projects.conf:
<VirtualHost www.projects-usama-ahmed.tk:80> 
    ServerAdmin webmaster@localhost 
    DocumentRoot /var/www/html/projects 
    ServerName www.projects-usama-ahmed.tk 
    ServerAlias projects-usama-ahmed.tk 
    ErrorLog /var/www/html/projects/logs/error.log 
    LogLevel warn 
    CustomLog /var/www/html/projects/logs/access.log combined 
    <Directory /var/www/html/projects> 
        Options FollowSymLinks 
        AllowOverride All 
    </Directory> 
</VirtualHost>

Can anyone give any solution please?



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

i found a solution after so many days first you make sure the you direction the domain to the NS of digital ocean.

2- in etc/hosts <pre> 127.0.0.1 domain.com 127.0.0.1 domain2.com </pre>

3- in the apache2.conf <pre> NameVirtualHost *:80 </pre> 4- sites-available <pre> <VirtualHost *:80> ServerAdmin webmaster@localhost DocumentRoot /var/www/yourdomain ServerName http://www.yourdomain.com ServerAlias yourdomain.com <Directory /> Options FollowSymLinks AllowOverride All </Directory> <Directory /var/www/yourdomain> Options Indexes FollowSymLinks MultiViews AllowOverride None Order allow,deny allow from all </Directory>

    ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
    &lt;Directory "/usr/lib/cgi-bin">
            AllowOverride None
            Allow from all
    &lt;/Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost> </pre> 5- enable yourdomain <pre> a2ensite yourdomain.com </pre> 6- <pre> service apache2 restart </pre>

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.