http://www.stellarwebsolutions.com/en/articles.php
我刚刚让 .pem 与 paypal 一起工作,但如果不将它放在我的 public_html/ 文件夹中,我找不到访问 .pem 的方法,我知道这可能不是最好的方法。有没有办法从 php 访问我的 ssh 的根目录?或我的 ssh 的其他区域?
http://www.stellarwebsolutions.com/en/articles.php
我刚刚让 .pem 与 paypal 一起工作,但如果不将它放在我的 public_html/ 文件夹中,我找不到访问 .pem 的方法,我知道这可能不是最好的方法。有没有办法从 php 访问我的 ssh 的根目录?或我的 ssh 的其他区域?
您可以轻松访问 public_html 文件夹之外的任何文件,您只需确保 Web 服务器用户可以访问该文件。例如:
$ls -l
total 8
-rw-r--r-- 1 www-data www-data 12 Nov 26 13:08 test.txt
drwxr-xr-x 2 www-data www-data 4096 Nov 26 13:11 www
以下 php 脚本正在读取 test.txt:
<?php
$file = $_SERVER['DOCUMENT_ROOT'] . "/../test.txt"; // relative path
//$file = "/opt/nguyen/test.txt"; //absolute path
$contents = file($file);
$string = implode($contents);
echo $string;
?>
您还可以将文件放在 public_html 文件夹中并使用 .htaccess 拒绝访问:
<Files config.inc.php>
order allow,deny
deny from all
</Files>