简体   繁体   English

PHP.ini 不起作用

[英]PHP.ini does not work

I opened the notepad, inserted 3 lines in it, saved it as php.ini, and uploaded it in public_html, but I am still getting an error that requires to first switch the magic quotes off.我打开记事本,在其中插入 3 行,将其保存为 php.ini,并将其上传到 public_html,但我仍然收到需要先关闭魔术引号的错误。 The syntax of the three lines is as following:三行的语法如下:

magic_quotes_gpc = 0 
magic_quotes_runtime = 0 
magic_quotes_sybase = 0 

What am I doing wrong?我究竟做错了什么?

use phpinfo() function to see what php.ini file you're actually using使用phpinfo() function 查看您实际使用的php.ini文件

You can probably alter these settings in a .htaccess configuration file as well:您也可以在.htaccess配置文件中更改这些设置:

php_flag magic_quotes_gpc off
php_flag magic_quotes_runtime off
php_flag magic_quotes_sybase off

See PHP: How to change configuration settings .请参阅PHP:如何更改配置设置

Most hosting companies lets you define a local ini file.大多数托管公司允许您定义本地 ini 文件。 Check their support pages, and see where you should put your php.ini file for it to be read by the php engine.检查他们的支持页面,看看你应该把 php.ini 文件放在哪里,以便 php 引擎读取它。 If they have an option for this, you don't have to worry about restarting the server.如果他们有这个选项,您不必担心重新启动服务器。

If you can't find any info about it, create a page with the following code:如果您找不到任何有关它的信息,请使用以下代码创建一个页面:

<?php phpinfo(); ?>

And look for the property named "Configuration File (php.ini) Path".并查找名为“配置文件(php.ini)路径”的属性。 This is where you should put the file.这是您应该放置文件的地方。

It's not meant to be placed in the public_html folder... it should be in your PHP installation folder.它不应该放在 public_html 文件夹中......它应该在您的 PHP 安装文件夹中。

Php.ini is not usually located in public_html. Php.ini 通常不在 public_html 中。 If you can't access your real php.ini, try writing如果您无法访问您的真实 php.ini,请尝试编写

php_flag magic_quotes_gpc off

in a .htaccess file (in public_html).在 .htaccess 文件中(在 public_html 中)。

Most hosting companies won't let you play around with the php.ini unless you rent a dedicated server from them.大多数托管公司不会让您使用 php.ini,除非您从他们那里租用专用服务器。 On that, you could try on page php.ini settings like the following:在此,您可以尝试在页面 php.ini 设置,如下所示:

ini_set("magic_quotes_gpc", "0");
ini_set("magic_quotes_runtime", "0"); 
ini_set("magic_quotes_sybase", "0");

If that doesn't work, then you'll have to ask your hosting company about it.如果这不起作用,那么您将不得不询问您的托管公司。

On CentOS 8 run在 CentOS 8 上运行

service php-fpm restart

To read the edited php.ini file读取编辑后的 php.ini 文件

Well, you have to change your main php.ini which I don't think is in public_html.好吧,您必须更改主要的 php.ini,我认为它不在 public_html 中。 Moreover, in order to see the changes you have to restart your php engine.此外,为了查看更改,您必须重新启动 php 引擎。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM