How to create a project outside the directory / var / www /?

I have a Ubuntu server with a static IP address for testing, I would like to create a project (for example, hello-world) outside the / var / www / directory, say, in this place (/ home / username / Webroot / hi-world /). It should be accessible through a browser as follows http://xxx.xxx.xxx.xxx/hello-world/ How to do this?

+4
source share
3 answers

I would use an alias:

Alias /hello-world /home/www/foo <Directory "/home/www/foo"> Options -MultiViews -FollowSymLinks +SymLinksIfOwnerMatch AllowOverride all </Directory> 
+3
source

you configure the virtual host in your apache configuration file: apache2.conf or httpd.conf:

 <VirtualHost *:80> ServerPath /hello-world DocumentRoot /home/username/webroot/hello-world </VirtualHost> 
+1
source

Enable FollowSymlinks in apache and make a link

 ln -s /path/to/your/project /var/www/projectname 

And updating content is easy without rebooting the server

 rm /var/www/projectname ln -s /path/to/your/project-v2 /var/www/projectname 
+1
source

All Articles