important info: 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: https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-centos-7
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,
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.
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.
Click below to sign up and get $200 of credit to try our products over 60 days!