uusa35
By:
uusa35

Virtual Hosts : multi domains on same server ?

June 13, 2014 1.4k views
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 load the projects-usama-ahmed.tk and vise verse i also edited /etc/apache2/apache.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 plz ? !
1 Answer
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
127.0.0.1 domain.com
127.0.0.1 domain2.com
3- in the apache2.conf
NameVirtualHost *:80
4- sites-available
<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/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Allow from all
        </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>
5- enable yourdomain
a2ensite yourdomain.com
6-
service apache2 restart
Have another answer? Share your knowledge.