这个 php.ini 文件到底在哪里?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3401436/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-25 09:36:23  来源:igfitidea点击:

where the heck is this php.ini file anyways?

phpmyadminphp

提问by JamesTBennett

I'm running php vs. 4.1.14 on yahoo with phpMyAdmin. it says the file is at /usr/lib/php/php4.ini but I can't find this anywhere. Is it in the phpMyAdmin folder? I really need to find this and turn of magic_quotes soon or I'm gonna go postal. Thanks.

我正在使用 phpMyAdmin 在雅虎上运行 php 与 4.1.14。它说文件在 /usr/lib/php/php4.ini 但我在任何地方都找不到。它在 phpMyAdmin 文件夹中吗?我真的需要尽快找到这个并关闭magic_quotes,否则我要去邮寄。谢谢。

Okay So i guess It wasn't that clear. I did phpinfo(). I don't know how to find that location on the server.....

好吧,我想这不是那么清楚。我做了 phpinfo()。我不知道如何在服务器上找到那个位置.....

采纳答案by Ehsan

Finding php.ini on a dedicated server can be done easily by phpinfo(as others said)

在专用服务器上查找 php.ini 可以通过phpinfo(如其他人所说)轻松完成

But I think you're using a shared hosting environment (so you can not edit php.ini) and actually need to turn off magic_quotes_gpc. (Am I right?) If so, simply create a file named .htaccessin the web root (or phpMyAdmin root) and put the following line in that.

但我认为您使用的是共享托管环境(因此您无法编辑 php.ini)并且实际上需要关闭magic_quotes_gpc. (我说得对吗?)如果是这样,只需创建一个.htaccess在 Web 根目录(或 phpMyAdmin 根目录)中命名的文件,然后在其中添加以下行。

php_flag magic_quotes_gpc off  

Hope to help :-)

希望有所帮助:-)

回答by Pekka

  1. Do a phpinfo(): It will tell you the exact full location of the php.ini used.

  2. You should not be using PHP 4any more. :)

  1. 做一个phpinfo():它会告诉你所使用的 php.ini 的确切完整位置。

  2. 您不应再使用 PHP 4。:)

回答by Jonathon Bolster

If you create a new PHP file with:

如果您创建一个新的 PHP 文件:

<?php phpinfo(); ?>

Then it will show you which php.ini file is loaded

然后它会告诉你加载了哪个 php.ini 文件

回答by Nathan Osman

You don't have to turn off magic quotes, just stick this at the top of every page:

您不必关闭魔术引号,只需将其粘贴在每一页的顶部即可:

function FixMagicQuotes()
{
    if(get_magic_quotes_gpc())
    {
        foreach($_POST as $key => $value)
        {
            $_POST[$key] = stripslashes($_POST[$key]);
        }
    }
}

FixMagicQuotes();

It will do nothing if magic quotes is disabled. If it is enabled, it will loop throught the POST fields, stripping slashes from each entry.

如果禁用魔术引号,它将什么也不做。如果启用,它将循环遍历 POST 字段,从每个条目中去除斜杠。

回答by Alan Storm

The path you found in phpinfo

您在 phpinfo 中找到的路径

/usr/lib/php/php4.ini

is path on the server of your hosting account. The forward slash at the beginning of the path indicates it's a path from the root level of the file system. Think of this like the C:\folder on a windows machine.

是您的主机帐户服务器上的路径。路径开头的正斜杠表示它是从文件系统根级别开始的路径。把它想象C:\成 Windows 机器上的文件夹。

If you have SSH access to the server you can edit this file with a command line editor ("pico" is the easiest to learn)

如果您可以通过 SSH 访问服务器,则可以使用命令行编辑器编辑此文件(“pico”是最容易学习的)

$ pico /usr/lib/php/php4.ini

If you're using an sFTP client you should have a command (possibly a button or a drop down menu) that is something like "Go to Folder" or "Go to Directory". This should allow you to enter the path

如果您使用的是 sFTP 客户端,您应该有一个类似于“转到文件夹”或“转到目录”的命令(可能是一个按钮或下拉菜单)。这应该允许您输入路径

/usr/lib/php/

which will drop you in the folder with php.ini.

这会将您放入带有 php.ini 的文件夹中。

Also via sFTP, when you log in you should see the ".." folder. Clicking on this will move you up a directory from your home directory. Keep click on this until you get to the top, then drill down to

同样通过 sFTP,当您登录时,您应该会看到“..”文件夹。单击此按钮会将您从主目录中上移一个目录。一直点击这个直到你到达顶部,然后向下钻取

/usr/lib/php

If you're accessing this through a file share of some kind, you're out of luck. Your system admin has effectively locked you out. Also, the above techniques may not work if the administrator of the server has blocked access to these folders and files (often common and necessary in a shared hosting environment)

如果您通过某种文件共享访问它,那么您就不走运了。您的系统管理员已有效地将您拒之门外。此外,如果服务器管理员阻止了对这些文件夹和文件的访问(在共享托管环境中通常是常见且必要的),则上述技术可能不起作用