如果你正在使用WordPress,你迟早要问自己这个问题. Although not directly connected to WordPress, php.ini 是服务器上最重要的配置文件之一,因为它负责配置PHP安装, 这样你的WordPress网站就会懂php了.ini location is important.
您可能需要更改的最常见参数是 upload_max_filesize. By default it’s 2Mb, which can be quite low. 其他流行的包括register_globals、safe_mode和max_execution_time. 您还可以使用该文件启用或禁用PHP安装的扩展.
根据您的系统和服务器环境,有不同的位置和方法可以找到php.ini location.
Whether you’re working on localhost, or on a live server, the easiest and proven way to locate your php.ini文件的目的是创建一个PHP文件,其中只有一行代码,并查看输出.
phpinfo(); ?>
You should see something like this:
Your php.ini文件应该位于“配置文件路径”部分, 或者像我在“加载配置文件”部分的情况. The first location is the default one, 第二个位置适用于将PHP安装用作模块的情况.
如果在某些情况下,创建一个php文件并插入一行代码对您不起作用, there are some other ways to find php.ini.
If you’re working locally, finding php.Ini将取决于您使用的服务器环境. 让我们快速浏览一些最受欢迎的.
Left click on your WAPM server icon, then go to PHP -> php.ini. Easy? Easy.
XAMPP是一个有点不同的野兽,但也可以不太困难地驯服. Run your XAMPP installation, 右键单击“Config”按钮(在Apache模块前面),就是这样了, our little guy:
如果你使用的是Linux,在终端运行以下命令:
php -i | grep "Loaded Configuration File"
It should output something like this:
Loaded Configuration File => /usr/local/lib/php.ini
In most cases the php.ini将位于“加载的配置文件”中。, but if it’s not there, 将' Loaded Configuration File '字符串替换为' Configuration File '.
The location of php.ini mostly depends on the hosting you’re using, 但是我们将在这里介绍一些最常见的场景.
打开文件管理器,并导航到根目录. Our little guy should be sitting at the bottom.
If you don’t know how to find your root folder, 只需在主public_html目录上走一层.
不幸的是,如果您使用的是共享主机,则无法访问php.ini file. 解决方法是在您的文件中指定所需的配置设置 .htaccess file in the following pattern:
php_value name value
这里的名称表示需要更改的PHP属性的名称. The same applies to the value. 例如,下面这行将上传文件的最大大小更改为8mb:
php_value upload_max_filesize 8M
If you made at least one change to php.Ini文件,您必须重新启动服务器,否则更改将不适用. 如果你在Linux上,写下面的命令:
/etc/init.d/httpd restart WAMP用户必须右键单击工具栏中的服务器图标, and choose ‘Restart all services’.
If you’re using XAMPP, go to the main dashboard, 点击“Apache”模块前面的“停止”按钮, and then click the ‘start’ button again.
As you can see, finding php.Ini可能既棘手又容易. 我试图涵盖最常见的解决方案和服务器环境, 希望这个指南能帮助你最终找到这个文件. If you know any other ways to find php.Ini,请在下面的评论中分享你的想法.
它是一个定义所有需要PHP的程序的工作的文件. 它包含默认配置并控制诸如资源限制和上传大小等重要内容.
如前所述,它包含了在PHP上工作的应用程序的非常重要的配置. 如果你想改变其中的一些-你将需要php.ini.
首先,它可能是upload_max_filesize. 默认值(2Mb)通常太小,网站所有者会将其设置得更大. Besides that, 您可能想要更改register_globals的值, safe_mode, and max_execution_time.
How to Build & Maintain Elementor WordPress Website? [Free Course]
How to Build and Maintain an HTML5 Website? [Free Course]
Ultimate Gutenberg Editor Learning Course
订阅我们的时事通讯和访问独家内容和提供只提供给og体育首页Post订户.
Leave a Reply
You must be logged in to post a comment.