Set Default Website For Apache2 if IP address is typed

March 19, 2014 24k views
I want my one of my websites in the virtualhosts configured apache2 (LAMP) droplet. So if anyone types x.x.x.x IP in their browser this 'default' website is displayed. How can one configure this behavior?
1 comment
8 Answers
It is possible to have more than one website being hosted from one web server configured with LAMP. Basically name based virtual host is used to host multiple websites in httpd. If you want a particular website to be displayed when server is browsed via IP, than the site must be listed as a default virtual host. First determine which of the website is being listed as default virtual host. You can list the virtual host as

[root@yourwebserver ~] # apachectl -t -D DUMP_VHOSTS

Above command will give you idea about which website will be displayed as default. Now, just make some changes with your httpd.conf file. Considering /etc/httd/conf/httpd.conf as your configuration file

[root@yourwebserver ~] # vi /etc/httpd/conf/httpd.conf

Add default virtual host line in httpd.conf

DocumentRoot
# Add other required directives and configuration of virtual host.


Make it sure to add default virtual host at the of virtual host config. If you are including conf files from /etc/httpd/conf.d/ then move line
Include conf.d/*.conf
from httpd.conf to the end or after the default virtual host configuration.
Example:
#
# DocumentRoot /var/www/yourwebsite-directory
# ServerAdmin admin@yourwebserver
# ServerName
# ServerAlias
#
# Alias /example /var/www/html
#
#
#
#

In your file "/etc/httpd/conf/httpd.conf" add a virtualhost and setup a landing page in your directory "/var/www/html/defaultsite"

NameVirtualHost :80
<VirtualHost default:
>
DocumentRoot /var/www/html/defaultsite
</VirtualHost>

I have the same problem and the solution is: config your default site in 000-default.conf, and enable it, restart the apache2. Then the default site will be opened if you typed the IP address.

It is possible to have more than one website being hosted from one web server configured with LAMP. Basically, the name-based virtual host is used to host multiple websites in https. If you want a particular website to be displayed when the server is browsed via IP, Then You can be fixed it or find the Solution By Getting in touch with the Digital Ocean tech support team.
Fix Epson Printer Error Code 0xf1

This is nice post. I need my one of my sites in the virtualhosts arranged apache2 bead. Thanks for sharing this post.

payment gateway UAE

Our best team of the technician will resolve your glitch at cheap cost and give 24*7 services. So, you can resolve all your issues at one place by calling Hughesnet Contact Number which is free for you 1-833-284-2444.
https://www.contactxpert.com/hughesnet-customer-service.html

Users are supported by the service of both purposes namely home as well as offices. Tenda Has genuine interface for his customer and providing guaranteed services. The customer who needs some more different technical service contact our toll-free number and get the instant solution or visit websites which is available all type technical solutions.

https://servicenumber.org/tenda-customer-service.html

Have another answer? Share your knowledge.