Question

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

Posted May 4, 2016 2.1k views
ApacheLAMP 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(?)

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

×
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.

Submit an Answer