heaversm
By:
heaversm

How do I use subfolders of my server's IP address as their own "domains" without a FQDN

May 4, 2016 631 views
Apache LAMP Stack

I am using a LAMP stack on Ubuntu 14x.

I want to use my server's ip address/subfolder as a "root" domain (http://1.2.3.4/[client]), without using fully qualified domains (www.domain.com).

How do I set this up?

I read about using the apache userdir module, which seems like it would work, but I don't know how to add users.

I also read about setting up virtual hosts, but it seems like that only applies if you are using fully qualified domain names(?)

1 Answer

You can use IP addresses in virtual hosts too, e.g.:

<VirtualHost *:80>
  ServerName 1.2.3.4
</VirtualHost>

For the userdir module:

sudo a2enmod userdir
sudo service apache2 restart

Apache uses the users on your droplet, so to add others:

sudo adduser newuser

... which creates the directory /home/newuser

sudo mkdir /home/newuser/public_html
sudo chmod 0755 /home/newuser/public_html

Apache will now serve files out of /home/newuser/public_html at the address http://1.2.3.4/~newuser.

Have another answer? Share your knowledge.