note 94562 added to function.symlink
| From: | Porjo at osu1 dot php dot net | Date: | Thu, 12 Nov 2009 03:36:19 +0000 |
| Subject: | note 94562 added to function.symlink | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-162791@lists.php.net to get a copy of this message | ||
Keep in mind when using a shared filesystem such as NFS, that you probably don't want to create
a symbolic link with absolute paths e.g.
On Server1 you are running a PHP script that needs to create a symbolic link called widget2 which
links to widget1 inside an NFS share mounted on your localhost at /mnt/nfs/widgets
On Server2 this same NFS share is mounted under /usr/local/widgets
If you used absolute paths on Server1, then Server2 would try to reference /mnt/nfs/widgets/widget1
which it won't be able to find...
You need to cd into the directory first, then create the link - that way the link will be relative.
Unless you run the PHP script from the same directory where you'll be creating the symbolic
links, then you can't use symlink(). Use exec() instead as follows:
<?php
exec("cd <nfs mount path>; ln -s <target> <link_name>");
?>
----
Server IP: 69.147.83.197
Probable Submitter: 203.153.237.62
----
Manual Page -- http://www.php.net/manual/en/function.symlink.php
Edit -- https://master.php.net/note/edit/94562
Del: integrated -- https://master.php.net/note/delete/94562/integrated
Del: useless -- https://master.php.net/note/delete/94562/useless
Del: bad code -- https://master.php.net/note/delete/94562/bad+code
Del: spam -- https://master.php.net/note/delete/94562/spam
Del: non-english -- https://master.php.net/note/delete/94562/non-english
Del: in docs -- https://master.php.net/note/delete/94562/in+docs
Del: other reasons-- https://master.php.net/note/delete/94562
Reject -- https://master.php.net/note/reject/94562
Search -- https://master.php.net/manage/user-notes.php