3

When I try to reach the site with my IP it works fine but when I try to use my domain name to connect I get "404 Not Found".
I am on Ubuntu Server 16.04.1 LTS

/etc/hosts/

127.0.0.1       localhost
127.0.0.1       zbytki.cz
127.0.1.1       zbytki.cz
192.168.123.106 zbytki.cz

/etc/apache2/sites-available/zbytki.cz.conf

<VirtualHost *:80>
    ServerAdmin admin@zbytki.cz
    ServerName zbytki.cz
    ServerAlias www.zbytki.cz
    DirectoryIndex index.html
    DocumentRoot /var/www/html/zbytki.cz/public_html
    LogLevel warn
    ErrorLog /var/www/html/zbytki.cz/log/error.log
    CustomLog /var/www/html/zbytki.cz/log/access.log combined
    <Directory "/var/www/html/zbytki.cz/public_html">
          Require all granted
    </Directory>
</VirtualHost>

/etc/hostname

zbytki.cz

/etc/apache2/apache2.conf

...
Timeout 300
...
KeepAlive Off
...
HostnameLookups Off
...
LogLevel warn
...    
AccessFileName .htaccess
...
<IfModule mpm_prefork_module>
     StartServers 4
     MinSpareServers 20
     MaxSpareServers 40
     MaxClients 200
     MaxRequestsPerChild 4500
</IfModule>

/etc/apache2/ports.conf

NameVirtualHost *:80
Listen 80
...

If you need more information just ask.
Can someone please help me ?

Dogomen
  • 43
  • 1
    Is $ a2ensite zbytki.cz.conf applied? – pa4080 Sep 12 '16 at 17:15
  • yes, site zbytki.cz already enabled – Dogomen Sep 12 '16 at 18:09
  • Did you try to use incognito browser window? I think it should work if you call it up from the same pc. Sometimes previous not successful attempts remains in browser cache. – pa4080 Sep 12 '16 at 18:15
  • I cleared cache in firefox, it doesnt fix my problem. – Dogomen Sep 12 '16 at 18:21
  • I concluded that you are trying to open http://zbytki.cz (http://192.168.123.106) by second PC from your local network - is that true? – pa4080 Sep 12 '16 at 19:29
  • If the answer is yes - just for a test, try to open the host address from the server directly. In the terminal, you can use lynx: $ sudo apt install lynx; lynx zbytki.cz. – pa4080 Sep 12 '16 at 19:40
  • I have two virtual machines, ubuntu server (bridged adapter) and ubuntu desktop (NAT and Host-only networking). I am trying to open Server domain name from dektop. – Dogomen Sep 12 '16 at 19:45
  • Ok, right! I think yours configuration is OK, but what is the result of $ lynx zbytki.cz, executed from server's console? – pa4080 Sep 12 '16 at 19:50
  • It works shows Hello World!!! but when I try with alias www.zbytki.cz It doesnt work shows message: "This site requires Cookies and Javascript enabled please change your browser settings or upgrade your browser". – Dogomen Sep 12 '16 at 20:16
  • If you add 127.0.1.1 www.zbytki.cz in /etc/hosts it will work too. – pa4080 Sep 12 '16 at 20:53

1 Answers1

1

Your web server's configuration is OK. To access certain host via host name, instead of IP-address, you must have pre-configured Domain Name Service / Server (DNS). There is two solutions:

1st. If you want you can configure yours own DNS which you can use in your local network. Here you go the manual - look at Primary Master configuration.

2nd. You can buy (register) a domain name from any DNS provider. This domain will be accessible from the Internet. For example I bought one from host.bg - there has a promotion of .info at the moment.

In this case you will need a (public) static IP-adress or pre-configured Dynamic DNS (DDNS), which will connects your dinamic IP-adress with the domain name.


I've made short survey and I found that domain zbytki.cz is registred from someone - hope that is you.

enter image description here

When I checked with $ nslookup zbytki.cz it returns: ** server can't find zbytki.cz: NXDOMAIN.

So the domain is registered but is not configured to work with certain (static) IP address.

pa4080
  • 29,831