简体   繁体   English

如何访问php.ini文件

[英]How to access the php.ini file

I need to change some variables in the php.ini file to be able to upload files. 我需要更改php.ini文件中的一些变量才能上传文件。 I bought a domain & hosting, and i access it through FileZilla. 我买了一个域名和托管,我通过FileZilla访问它。 Usisng phpinfo() I know Usisng phpinfo()我知道

Configuration File (php.ini) Path is /usr/local/php/p56 配置文件(php.ini)路径是/ usr / local / php / p56

Loaded Configuration File is /usr/local/directadmin/data/users/kristak/php/funwithhakase.pl/php56.ini 加载的配置文件是/usr/local/directadmin/data/users/kristak/php/funwithhakase.pl/php56.ini

I don't know which of these files should I access and how to change the desired variables. 我不知道应该访问哪些文件以及如何更改所需的变量。 I tried putting the adresses into FileZilla, but nothing appeared. 我尝试将地址放入FileZilla,但没有出现。 Pls help :) 请帮忙:)

Properly you are not able to access the php.ini file. 正确地,您无法访问php.ini文件。 Maybe you can change some settings in your hosting backend. 也许您可以更改主机后端中的某些设置。 Otherwise contact the support of your hosting provider. 否则,请与您的托管服务提供商联系。

First - you should see your hosting documentation regarding specific access / permissions. 首先 - 您应该看到有关特定访问/权限的托管文档。 You also did not mentioned what control panel you are using ( whm, cpanel, plesk , virtualmin, custom ) 您还没有提到您正在使用的控制面板(whm,cpanel,plesk,virtualmin,custom)

As for runtime : 至于运行时:

You can use ini_set in order to change some of the runtime variables. 您可以使用ini_set来更改某些运行时变量。

It might not be available with your hosting, but you can always try ( most hosting that I have encountered allow it to some degree ) 它可能不适用于您的托管,但您可以随时尝试(我遇到的大多数托管允许它在某种程度上)

Likewise, you can use ini_get to see current values, for example to know what is the upload_max_filesize that is currently used : 同样,您可以使用ini_get查看当前值,例如,了解当前使用的upload_max_filesize是什么:

echo 'upload_max_filesize = ' . ini_get('upload_max_filesize') . "";

and to set it : 并设置它:

ini_set('upload_max_filesize','1024M');

or with error suppression : 或者有错误抑制:

@ini_set('upload_max_filesize',$my_Value);

Depending on your hosting, you could potentially do that with most variables of the ini file : 根据您的托管,您可以使用ini文件的大多数变量执行此操作:

ini_set('max_execution_time','10');
ini_set('memory_limit','1024M');
ini_set('post_max_size','1024M');

Another way ( again - hosting permitting ) is to use .htaccess 另一种方式(再次 - 托管许可)是使用.htaccess

Syntax is a bit different 语法有点不同

php_value upload_max_filesize "80M"
php_value post_max_size "80M"
php_value max_execution_time "2000"
php_value memory_limit "150M"

Under some hosting that permit - you can actually put per-folder user.ini \\ .user.ini or php.ini \\ .php.ini with the values you want to override - but again, best is to consult hosting documentation. 在某些允许的托管下 - 您实际上可以将每个文件夹user.ini \\ .user.iniphp.ini \\ .php.ini与您要覆盖的值.php.ini一起 - 但同样,最好是咨询托管文档。

If you want to make sure to know where is the used ini you can also try 如果你想确保知道在哪里使用ini你也可以尝试

<?php echo php_ini_loaded_file(); ?>

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

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