如何在 wordpress 上找到我的 php.ini?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6165558/
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 23:32:44  来源:igfitidea点击:

How can I find my php.ini on wordpress?

wordpressphp

提问by Maha

I want to increase max execution time on my wordpress site. I know I should edit php.ini, but can't seem to find it!

我想在我的 wordpress 网站上增加最大执行时间。我知道我应该编辑 php.ini,但似乎找不到它!

any tips?

有小费吗?

回答by Brad Fletcher

I see this question so much! everywhere I look lacks the real answer.

我看到这个问题太多了!我到处寻找都缺乏真正的答案。

The php.ini should be in the wp-admindirectory, if it isn't just create it and then define whats needed, by default it should contain.

php.ini 应该在wp-admin目录中,如果它不只是创建它然后定义需要什么,默认情况下它应该包含。

upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300

回答by Peter B Butler

I used this, very cool tool

我用过这个,非常酷的工具

https://wordpress.org/plugins/php-settings/

https://wordpress.org/plugins/php-settings/

This plugin provides a simple user interface with a code editor to edit your local .ini settings.

这个插件提供了一个简单的用户界面和一个代码编辑器来编辑你的本地 .ini 设置。

This can be used to change settings like upload_max_filesizeor max_execution_timewhich are often set to very low values by the hosting companies.

这可以用于更改设置,如 upload_max_filesizemax_execution_time这往往是由托管公司设置为非常低的值。

回答by realhdx

Wordpress dont have a php.ini file. It just a cms, look into your server. for example if you use XAMPP in windows xampp\php\php.iniis the location.

Wordpress 没有 php.ini 文件。它只是一个cms,查看您的服务器。例如,如果您在 windows 中使用 XAMPPxampp\php\php.ini是位置。

回答by markratledge

A php.ini file is not installed by default with Wordpress. You may have one already installed by your web host. Look in your root directory or ask your web host or read your web host's documentation on how to install one.

Wordpress 默认不安装 php.ini 文件。您的网络主机可能已经安装了一个。查看您的根目录或询问您的网络主机或阅读您的网络主机关于如何安装的文档。

Look for max_execution_timein your php.ini file and change to 60 or 90

max_execution_time在 php.ini 文件中查找并更改为 60 或 90

回答by Max The Stranger

Open .htaccess file in a code editor like sublime text and then add..

在代码编辑器(如 sublime text)中打开 .htaccess 文件,然后添加..

php_value upload_max_filesize 1000M
php_value post_max_size 2000M
php_value memory_limit 3000M
php_value max_execution_time 1800
php_value max_input_time 180

hope it helps..............it did for me.

希望它有帮助......它对我有用。

回答by Salman von Abbas

Use the php_ini_loaded_filefunction to get the location of your php.ini file.

使用php_ini_loaded_file函数获取 php.ini 文件的位置。

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}

回答by Manoj

This Worked For Me. I have installed wordpress in godaddy shared server. Open .htaccess file using editor and add the following from the first line,

这对我有用。我已经在 Godaddy 共享服务器中安装了 wordpress。使用编辑器打开 .htaccess 文件并从第一行添加以下内容,

#  BEGIN Increases Max Upload Size
php_value upload_max_filesize 20M
php_value post_max_size 20M
php_value max_execution_time 300
php_value max_input_time 300
#  END Increases Max Upload Size

This solved the php.ini issues for me in the server.

这为我在服务器中解决了 php.ini 问题。

回答by Michael Cropper

I just came across this thread while searching for an answer to why the php.ini file would be within the /wp-admin/ folder for WordPress that I have just seen in an odd setup - because it really really shouldn't be there.

我刚刚在寻找 php.ini 文件为什么会在 WordPress 的 /wp-admin/ 文件夹中的答案时遇到了这个线程,我刚刚在一个奇怪的设置中看到了这个问题 - 因为它真的不应该在那里。

WordPress by default doesn't include a php.ini file within the /wp-admin/ folder, so you should not have one there yourself. The php.ini file is designed to override the main server PHP configuration settings so that your account on the server is treated differently, within limits. As such, if you do need to use this file, please, for your own sanity (and that of others who happen to work with your systems in the future...), place the php.ini file in the root of your account, not hidden away in the /wp-admin/ folder, or any other folder for that matter.

默认情况下,WordPress 在 /wp-admin/ 文件夹中不包含 php.ini 文件,因此您自己不应该在其中放置一个。php.ini 文件旨在覆盖主服务器 PHP 配置设置,以便在限制范围内对您在服务器上的帐户进行不同的处理。因此,如果您确实需要使用此文件,请为了您自己的理智(以及将来碰巧使用您系统的其他人的理智......),将 php.ini 文件放在您帐户的根目录中,不会隐藏在 /wp-admin/ 文件夹或任何其他与此相关的文件夹中。

I'm surprised to see so many others commenting that it should be in the /wp-admin/ folder to be honest. I'd love to see some official documentation from WordPress stating that this is best practice, as this is certainly something that I would completely avoid.

我很惊讶看到这么多其他人评论说它应该在 /wp-admin/ 文件夹中。我很想看到 WordPress 的一些官方文档说明这是最佳实践,因为这当然是我会完全避免的。

回答by Simon

If you have access to our webroot, create a file asdf.php with

如果您有权访问我们的 webroot,请创建一个文件 asdf.php

<?php phpinfo(); ?>

in it and point your webbrowser to it. You should see all info in the first section.

在其中并将您的网络浏览器指向它。您应该会在第一部分中看到所有信息。

  • Configuration File (php.ini) Path
  • Loaded Configuration File
  • Scan this dir for additional .ini files
  • Additional .ini files parsed
  • 配置文件(php.ini)路径
  • 加载的配置文件
  • 扫描此目录以获取其他 .ini 文件
  • 已解析的其他 .ini 文件

This works for any php application and is therefore the universal way to find our php.ini

这适用于任何 php 应用程序,因此是查找我们的 php.ini 的通用方法

回答by Mugen

I am adding an answer based on my experience and also thanks to Michael Cropper and Salman von Abbas for their inputs.

我正在根据我的经验添加一个答案,并感谢 Michael Cropper 和 Salman von Abbas 的投入。

The php.ini file is created when php is installed on the server. I believe that wordpress installation requires php to be installed on the server. So your webhost typically installs it on their server and then sells you the hosting space. Then you install your wordpress on it.

php.ini 文件是在服务器上安装 php 时创建的。我相信wordpress安装需要在服务器上安装php。因此,您的虚拟主机通常将其安装在他们的服务器上,然后向您出售托管空间。然后你在它上面安装你的wordpress。

Hence, it follows clearly from this that the php.ini file will not be present in the wp-admin folder.

因此,很明显,php.ini 文件不会出现在 wp-admin 文件夹中。

So you need to look for it either at your root folder (but most likely it won't be there if you're on a shared webhosting plan). Then you need to create a file as such:

因此,您需要在您的根文件夹中查找它(但如果您使用的是共享虚拟主机计划,它很可能不会在那里)。然后你需要创建一个文件:

create a new file in the location = /public_html/your_domain/any_name.php

在位置创建一个新文件 = /public_html/your_domain/any_name.php

Put the following code inside the file:

将以下代码放入文件中:

<?php
$inipath = php_ini_loaded_file();

if ($inipath) {
    echo 'Loaded php.ini: ' . $inipath;
} else {
    echo 'A php.ini file is not loaded';
}

Now try to access the file through your browser as follows:

现在尝试通过浏览器访问该文件,如下所示:

https://your_domain/any_name.php

https://your_domain/any_name.php

This should show a message that clearly states the location of your php.ini file.

这应该显示一条消息,明确说明 php.ini 文件的位置。

If you're on a shared hosting plan then you probably won't have access to this folder. You will need to inform the web hosting support to take care of this for you.

如果您使用的是共享主机计划,那么您可能无法访问此文件夹。您需要通知网络托管支持人员为您处理此事。

Hope this helps!

希望这可以帮助!