【发布时间】:2015-06-01 05:52:18
【问题描述】:
我的脚本在 plesk 最新版本上运行,而 plesk 没有写权限。我必须用数据库中的值编写一个配置文件。
我尝试了以下,
$pathconn = $_SERVER['DOCUMENT_ROOT']."/mysite/_conn.php";
if(file_exists($pathconn)){
chmod($pathconn, 0777);
}
$file_contents = file_get_contents($pathconn);
$file_contents = str_replace("webuser_admin", $username."_admin", $file_contents);
$file_contents = str_replace("webpass", $mysql_password, $file_contents);
$file_contents = str_replace("web_db", $username."_ss", $file_contents);
file_put_contents($pathconn, $file_contents);
php 变量来自数据库,我需要使用这些变量更新_conn.php 文件以运行网站。由于权限问题,我不能这样做。
还有其他方法吗?我在某处读到我们可以作为apache 或root 用户执行此操作。但我不确定这是什么意思。请帮忙..
【问题讨论】:
-
我认为此链接可能对您的情况有用unix.stackexchange.com/questions/35711/…
-
我不知道如何使用这些命令。
-
您还在使用 Plesk 吗?我没有使用它,但我没有问题写入,使用 Apache 和 cPanel 或我的 WAMP 设置创建新文件...
-
@Wade Shuler 实际上我的大部分工作都在工作。但现在我只需要一些 php 脚本,它将 _conn.php 中的一些字符串替换为数据库中的值。我被困在这里,不知道下一步该做什么。
-
你试过这样的事情吗? 1hostingvision.com/shop/…