0

I'm aware that there are already questions like this, but those did not help.

I am running apache2 on debian 7 and I can access my site locally through 192.168.1.x and others can access it by my IP address. Now what I want to do is add a subdomain name, so they can access a certain folder like this: subdomain.myip. Here is what I currently have:

<VirtualHost *:80>
        ServerName username.localhost
        ServerAdmin username@localhost

        DocumentRoot /home/username/www/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /home/username/www/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        ErrorLog ${APACHE_LOG_DIR}/localhost.error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/localhost.access.log combined
</VirtualHost>

The only way I can access it at the moment is by going to username.localhost on debian itself. How can I make it so I can locally access it using username.192.168.1.x and others by username.myip?

0

First of all, change username.localhost in ServerName to something else. Localhost is a standart name for ip address 127.0.0.1 which means this PC. So, if someone tries to use username.localhost to access your website, he will try to search it on his own computer instead of yours. In fact this definition between localhost and 127.0.0.1 is written in hosts file. Second thing - You can't mix ip address and domain name together like username.192.168.1.x. You need use either domain name (like username.example.net) or just ip (192.168.1.x).

If you want to stick with domain name then you need either a domain name server or to modify mentioned above hosts file on every pc that should access you website add this string:

192.168.1.x    username.example.net

After that use username.example.net to access your site.

PS: Don't forget to check that firewall on your server is not blocking tcp port 80

  • Hi, thanks for your response. I want people to be able to access username.myip if possible, I will buy a domain for that later. I've set it up like this ServerName username.myip and in the hosts as 192.168.1.x username.myip (where x is the number I use, and myip my ip). This all without scucess though, I can't get someone to visit username.myip, though they can visit myip. I'm sorry if I'm missing something or sound stupid, but I can't figure it out. – user368278 Sep 14 '14 at 13:36
  • That's because you can not mix ip address and subdomain together. You can use something like 192.168.1.x/username however. – Anton Sep 15 '14 at 9:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.