point new domain to different directory on same droplet in centos 7 x64 using virtualhost
the domain names maindoamin.com and otherdomain.com are for information only, i am working on a real domain name, but for privacy i have used these two domain names here to explain my issue…
i am following this article:
i had just bought a droplet which has centos 7 x64 and httpd, php, mysql installed using articles and tutorials at digitalocean and everything is working perfect.
but i want to use more than one domain in my single droplet, which has above stated config, for that i had created a mysite.conf at /etc/httpd/conf.d with below lines of code::
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.maindomain.com ServerAlias maindomain.com DocumentRoot /var/www/html/ ErrorLog /var/www/html/error.log CustomLog /var/www/html/requests.log combined </VirtualHost> <VirtualHost *:80> ServerName www.otherdomain.com ServerAlias otherdomain.com DocumentRoot /var/www/html/otherdomain.com ErrorLog /var/www/html/otherdomain.com/error.log CustomLog /var/www/html/otherdomain.com/requests.log combined </VirtualHost>
but i getting below when i am restarting httpd service using putty :::
[root@muhammad ~]# sudo service httpd restart Redirecting to /bin/systemctl restart httpd.service Job for httpd.service failed. See 'systemctl status httpd.service' and 'journalctl -xn' for details.
but when i keep only one virtual host ie:
NameVirtualHost *:80 <VirtualHost *:80> ServerName www.otherdomain.com ServerAlias otherdomain.com DocumentRoot /var/www/html/otherdomain.com ErrorLog /var/www/html/otherdomain.com/error.log CustomLog /var/www/html/otherdomain.com/requests.log combined </VirtualHost>
now httpd restart works… and when i navigate to www.otherdomain.com using web browser, my index file get displayed which i had at my otherdomain.com folder but my maindomain.com also uses the index.html file , but the index.html file is at otherdomain.com folder at /var/www/html/otherdomain.com/index.html, this i understand why it doing this,
but my question is how can i setup it properly so that my maindomain.com uses /var/www/html/ and otherdomain.com uses /var/www/html/otherdomain.com/ , please help thanks in advance..
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.×