Question

Virtual Hosts : multi domains on same server ?

  • Posted on June 13, 2014
  • uusa35Asked by uusa35

my etc/hosts <pre> 107.170.137.119 www.usama-ahmed.tk usama-ahmed.tk 107.170.137.119 www.projects-usama-ahmed.tk projects-usama-ahmed.tk </pre>

when i comment the first line it properly load the projects-usama-ahmed.tk and vise verse i also edited /etc/apache2/apache.conf <pre> HostnameLookups On </pre>

usama.conf <pre> <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> </pre>

projects.conf <pre> <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> </pre>

can anyone give any solution plz ? !


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

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>