can't reach default apache page trough ip

I've followed the the hosting your website guide, but I can't seem to load the default Apache screen.

Some information that might be useful

I'm on an Ubuntu 18.04

sudo service apache2 status
returns: Active (running)

sudo systemctl restart apach2
result not changed

/etc/apache2/sites-available$ ls
returns : 000-default.conf default-ssl.conf example.com.conf

inside 000-default.conf

<VirtualHost *:80>
        ServerAdmin [email protected]
        DocumentRoot /var/www/html
        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

inside the example.com.conf

<VirtualHost *:80>
        ServerAdmin [email protected]
        ServerName  example.com
        ServerAlias www.example.com

        DirectoryIndex index.html index.php
        DocumentRoot /var/www/html/example.com/public_html

        LogLevel warn
        ErrorLog  /var/www/html/example.com/log/error.log
        CustomLog /var/www/html/example.com/log/access.log combined
</VirtualHost>

I haven't configured a firewall yet as suggested in this guide. This is something I will do.

I have setup the dns values in my register (in my case: google domains) and I've also done the reverse dns. (I'll have to wait about 24 hours until the changes will take effect, but I should still be able to see my page by simply putting in the ip, right?)

I tried pinging my server using the windows cmd:

ping {myip}

Pinging {myip} with 32 bytes of data:
Reply from {myip}: bytes=32 time=23ms TTL=51
Reply from {myip}: bytes=32 time=16ms TTL=51
Reply from {myip}: bytes=32 time=18ms TTL=51
Reply from {myip}: bytes=32 time=17ms TTL=51

Ping statistics for {myip}:
    Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
    Minimum = 16ms, Maximum = 23ms, Average = 18ms

2 index.html files:
one in /var/www/html/index.html (This one is from the 000-default.conf)
and the other in /var/www/html/example.com/public_html/index.html (this one is from example.com.conf)

When going to the (with firefox): http://{myip}
it return:
The connection has timed out
The server at {myip} is taking too long to respond.

If you need more information I'll add it.

(This is my first Linode and first time working in a linux environment) any idea on how to get it working? (if you know the answer, could you also please explain what I did wrong)

2 Replies

Greetings @LinodeUser55,

Thanks for the detailed info - gives us a good picture of what the issue could be. We recommend setting up the firewall so that the ports are listening for web traffic and your Linode stays secure. UFW is typically the tool new Linux users use as it is easy to use.

$ sudo apt-get install ufw

To allow HTTP traffic on port 80:

$ sudo ufw allow http

https://www.linode.com/docs/security/firewalls/configure-firewall-with-ufw/

The issue you are experiencing may be due to a networking issue we've seen with other Ubuntu 18.04 systems. Try the following:

$ sudo systemctl enable systemd-networkd

There are some major differences in networking and how its configured between the Ubuntu versions, so we've found that the command above has done the trick in the past.

Also, you will want to check that the /var/www/html directory is owned by www-data and not root. You can run the following to check:

$ cd /var/www/html

&

$ ls -la

https://stackoverflow.com/questions/28918996/proper-owner-of-var-www-html

Hope that helps,
Preston
Linode Support Team

@pambrosky

Thank you for your help. Your instructions helped me solve the problem. I do have 1 other question. You stated the following:

Also, you will want to check that the /var/www/html directory is owned by www-data and not root. You can run the following to check:

So the directory should be like this? :

html drwxr-xr-x www-data www-data and not root root?
| - same with everything else inside this directory up until the public_html inside the example.com directory?

Will leaving it root be a problem? (I'll be changing it as you have recommended, but I'm just curious)

  • if not, then why change it?
  • if it is a problem, what would the problem be?

<edited>
Just noticed the link to the stackoverflow page… No idea how I missed it xD</edited>

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct