Tag Archives: symlink

XAMPP and Windows: How to Create a Symbolic Link Tips, Tricks and Tutorials 25 NOV 2014

If you have scripts which need to be run in your local web browser but fall outside of your web root or any other declared vhost directory, there is always the option of simply creating symbolic links to these external locations from within your web root folder.

To do this (and I needed to on my Windows 7 environment to get around some Sencha ajax origin restrictions during debugging) follow the following steps:

1. Click the Start button to bring up the start menu.

2. Type cmd in the universal search box at the bottom of the start menu. (You should see at the top of the search results under Programs cmd.exe highlighted)

3. Press the Ctrl + Shift + Enter to launch the command prompt (cmd.exe) as Administrator. If you don’t do this, you’ll get a error saying that there are insufficient permissions to create the symbolic link later on. (You can also right click and select “Run as Administrator” to achieve the same thing.)

4. A box saying “Windows needs your permission to continue” will pop up. Click Continue.

5. Go to the directory you want to create the link in. For example: cd c:\xampp\htdocs\

6. Use mklink to create your symbolic link (or shortcut):

mklink /D externalfolder "c:\Users\username\Documents\My Folder\"

Note: The /D is there because, in this example, we are linking to a directory. “externalfolder” is the name of the symbolic link (change to whatever you want). Finally, the path is where the symbolic link actually resolves to.

Using the example laid out below, we could now point our browser to http://localhost/externalfolder/hello-world.php which would run just fine, with the browser executing c:\Users\username\Documents\My Folder\hello-world.php in reality.

Useful little trick to be aware of.

xampp logo

Ubuntu Server: Pointing Apache’s default /var/www Folder to a Different Folder CodeUnit 11 APR 2011

If you build a Zend Framework website then you will know that it is customary practice to move most of the work out of the publicly accessible web folder and then simple feed back the results to this folder so that the visitors can see a page off your site. So all projects always contain a /public folder which technically should be the root of your Apache webserver.

If you don’t in particular want to mess around with the various rights and permissions already linked to the default /var/www folder, it turns out that there is a elegantly simple solution to your problem – simply symlink the /var/www folder to your zendproject/public folder!

rm -r /var/www
ln -sv /home/user/zendproject/public /var/www

What we are doing above is simply removing the existing /var/www folder and then creating a symlink version of it that points to our project’s public folder. So now anyone browsing our web server will be served pages out of the /public folder, without them knowing any different, keeping the rest of our Zend project out of any potential snooper’s hands!