You need to do two things, the first is to make an apache2 virtual host that will respond to the domain name given and the port used; so in /etc/apache2/sites-available/tempplace.conf which should be symlinked to /etc/apache2/sites-enabled/000-tempplace you should have something like this:
<VirtualHost tempplace.localhost:80>
DocumentRoot /www/example1
ServerName tempplace.localhost
# Other directives here
</VirtualHost>
Once you have that part you can restart your apache2 server. Next you have to enable a localhost hostname, to do this you edit the file /etc/hosts and add as follows:
This effectively adds the tempplace.localhost resolve to your local dns and means that browsing to it will point to localhost. You should then be able to browse your Apache virtual server on your localhost without resorting to different ports.
You need to do two things, the first is to make an apache2 virtual host that will respond to the domain name given and the port used; so in
/etc/apache2/sites-available/tempplace.conf
which should be symlinked to/etc/apache2/sites-enabled/000-tempplace
you should have something like this:Once you have that part you can restart your apache2 server. Next you have to enable a localhost hostname, to do this you edit the file
/etc/hosts
and add as follows:This effectively adds the
tempplace.localhost
resolve to your local dns and means that browsing to it will point to localhost. You should then be able to browse your Apache virtual server on your localhost without resorting to different ports.Let me add some points to In Protest's answer.
1). enable the apache userdir module.
this will enable apache userdir module. Now you can put the contents of website in
~/public_html/
or whatever inside your home directory.Note: The default folder is
~/public_html
2). Make necessary changes to
/etc/apache2/mods-enabled/userdir.conf
.3). Restart the apache
Now you can access the site by navigating your browser to http://ip-address/~username.
4) Set a virtual host for this site as in In Protest'answer
If you are looking to run php files you need to do one more step
edit the
/etc/apache2/mods-enabled/php5.conf
and comment the following lines:Then restart the apache.
Thats it. You are done.
Ref:https://wiki.ubuntu.com/UserDirectoryPHP
Hope this helps. If you face any difficulties feel free to post it here.