By nileshkale
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?
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!
Hi all,
In Ubuntu, if you want to make A website load when the droplet’s IP address is loaded in your browser https://XXX.XXX.XXX.XXX
there are a couple of steps that need to be followed.
The change you need to implement is to your default configuration file. This file can be found in directory - /etc/apache2/sites-enabled/
Once you are in there, open the file 000-default.conf
. In it, find the line that says
DocumentRoot /var/www/html
And change it to your domain’s root directory.
Let’s say your domain is example.com. Usually, your DocumentRoot is configured to be in /var/www/domain.com
or /var/www/html/domain.com
. Set the DocumentRoot to the path. If you are uncertain about the DocumentRoot, you can check it from your domain’s configuration file again found in /etc/apache2/sites-enabled/
.
Once the change has been done to /etc/apache2/sites-enabled/000-default.conf
don’t forget to restart apache
service apache2 restart
Regards, KFSys
Hi I had the same problem once i used Apache2 in Debian, my solution was the following steps:
Step 1: Create a directory for your default web site, change the propietary of that dircetory and enable the virtual host with the following commands.
cd /var/www
sudo mkdir mywebsite
chown $USERNAME:www-data mywebsite
sudo a2ensite 000-default.conf
Step 2: Execute this command
sudo nano /etc/apache2/sites-available/000-default.conf
verify that file contains all this
<VirtualHost *:80>
DirectoryIndex index.php index.html index.htm
ServerAdmin webmaster@localhost
DocumentRoot /var/www/mywebsite
ServerName YOUR_DOMAIN_NAME.com
ServerAlias www.YOUR_DOMAIN_NAME.com
</VirtualHost>
Step 3: create your index.php page and reload the service.
touch /var/www/mywebsite/index.php
systemctl reload apache2
Edit your index.php and add all your stuff. finally go to your web browser and type in the url localhost.
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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.