Whenever I signed up for a web hosting account powered by cPanel, I would receive a welcome e-mail providing an address for accessing my site without the domain name.
Usually would look something like… http://107.170.153.132/~username
However, now that I am using Digital Ocean, I am no longer using cPanel, but sometimes I might to access a vhost using just the IP address. How could I go about doing that?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
I’m resolve this problem following https://www.digitalocean.com/community/tutorials/how-to-set-up-apache-virtual-hosts-on-ubuntu-12-04-lts
http://107.170.153.132/~username is an apache mod called userdir. If enabled, it allows any user on the system to create a public_html folder inside of their home folder and it can be accessed via the method above. For example, if the mod was enabled and my account on the server was mark and my home directory was /home/mark, I could create a folder called public_html and put web files in there and access them via http://1.2.3.4/~mark
If you have multiple IP addresses you can set up IP based virtual hosting. This means accessing different websites uising different IPs all on the same server.
You also have name based virtual hosts, which lets you use multiple domains (or sub domains) and have them ‘resolve’ or map to different websites, all on the one IP address. This lets mydomain.com, domain.com and cool-domain.com all map to different websites, even though they’re all hosted on the one server. You just need to set up virtual host required.
cPanel typically uses a mix of both named based virtual hosting and user dir mod, which gives it the functionality you describe. This is a common set up in shared hosting.
Since you seen to be more interested than the userdir mod, I’ll focus on that.
Log in as root and type
Make sure it looks like below (as per debian instructions):
Edit php config to allow php in user dirs
Ensure it looks like this:
Assuming you have a basic LAMP stack installed and configured, you should be able to add a user to the system, create a public_html folder in there and put some php/html pages and access them via http://1.2.3.4/~username
Remember to add files as the username you created, not root. Make sure the files have correct permissions. If you get access forbidden, run this command as the user you want the web pages in.