Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php): failed to open stream: No such file or directory in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24

Warning: include(): Failed opening '/home/blog66rr/public_html/wp-content/plugins/hyper-cache/cache.php' for inclusion (include_path='.:/opt/cpanel/ea-php70/root/usr/share/pear') in /home/blog66rr/public_html/wp-content/advanced-cache.php on line 24
共用資料夾 – unethost無限空間虛擬主機 技術分享部落格

cpanel主機下,設定不同的帳戶可以共用資料夾

收到了客戶的要求,希望在他所租用的獨立主機下的二個account,A和B,有共用的資料夾。也就是說:

/home/A/public_html/share
/home/B/public_html/share
這兩個資料夾,是指到同一個位置。

本來我以為,只要用ln -s來建softlink,就可以把問題解決了。結果卻失敗了,softlink所在的那個帳戶,用ftp登入後,看不到share這個資料夾。這是為什麼呢?原因是在這邊,它寫說,symbolic link只能指向「正確的」的地方。使用者的ftp帳戶基本上是一個被chroot的環境,所以當然不能去看到別的使用者的檔案。

A symbolic link is a pointer to the “right” file. But if that original file is outside the jail then you can’t access it. This is the goal of a jail. Otherwise a normal user could create a symbolic link in the jail to/etc/passwd and just read it. What a security risk!

So jailed is jailed. Probably a hard link will do the job, as this is a “copy without duplicating the used size”. And for the FTP server it is like a normal file (with all the problems).

那麼,這樣的問題該如何處理呢?用 mount –bind來處理吧。這個是正確的作法。

mkdir /home/website/files/
mount –bind /home/shared/files /home/website/files/

像這樣子的作法,shared這個使用者ftp登入後,就看得到 website這個使用者的資料夾files了。因為 /home/shared/files 和 /home/website/files是同一個資料夾。