Creating symlinks without shell access
While testing out the WordPress plugin WP-Cache, used to cache and speed up wordpress powered websites, I came across a list of commens on the plugin creator’s website where alot of comments had questions as to how one should create a symlink that was required in the plugin installation.
Alot of us (me included) do not have shell access and are unable to execute the Unix “ln” command to make this happen. But fear not, there is an easy php-solution to this problem. The function is called … yeah you guessed it: symlink().
The function works like this:
bool symlink ( string target, string link )
HERE IS HOW you can use it to set up the required symlink in the WP-Cache installation:
1. Create a blank php-file in the root of your website. Name it createsymlink.php.
2. Paste the code below into the file and save it. Make sure you replace “/path/to/website/” with your website’s real path.
$success = symlink('/path/to/website/wp-content/plugins/wp-cache/wp-cache-phase1.php', '/path/to/website/wp-content/advanced-cache.php');
if ($success)
echo "Symlink was created";
else
echo "Symlink creation failed!";
3. Make sure that your wp-content folder is writeable
4. Use your webbrowser and open www.yourwebsite.com/createsymlink.php, making the code run. This should fix the symlink creation for you and the success message should be displayed on screen.
5. Delete createsymlink.php from your server.
Related links
» Read the php documentation on the symlink function
» WP-Cache plugin website
Technorati Tags: WordPress, symlink, unix commands, php functions, caching, wp-cache
on October 5th, 2006 at kl. 8.20
Thanks for the tip!
Don’t forget to put
at the very end (after your code). This is implied by “create a blank php file,” but could easily be overlooked by non-programmers. Not that I made that mistake or anything ;-)
on March 27th, 2007 at kl. 2.14
[…] There’re a lot of WordPress users, who want to install wp-cache plugin, but couldn’t do so, ‘coz, the original version of WP-Cache2 by Ricardo Galli, needs to create a symbolic link between the ‘wp-cache-pahse1.php’ file, and ‘advanced-cache.php.’ The creation of symlink requires access to shell or telnet, but many web hosting companies don’t allow shell / telnet access. To overcome the symlink problem, Torkil Johnsen’s has posted a solution, some people were able to get through, but some couldn’t do so. If you’re the one with no success, then here is a solution for you: […]
on April 11th, 2007 at kl. 5.56
Thank you very much for this tip!
on November 7th, 2007 at kl. 4.42
[…] problem to create the symbolic link because you need to have a shell access to do it. But thanks to Torkil Johnsen for sharing this method to […]