0

読み込まれた構成ファイルのパスは/usr/local/lib/php.ini(を使用して検索phpinfo();) です。

このファイルを編集したり、好きな場所にこのファイルのコピーを作成したりするにはどうすればよいですか? いくつかのフォーラムで、このコマンドを実行するように求められました。

cp /usr/local/lib/php.ini /public_htmlPHP.ini ファイルが public_html フォルダーにコピーされるようにします。しかし、このコマンドを実行する場所がわかりません。

私はこの問題を自分で解決できるように、PHP についてあまり考えていません。これを行うための詳細な手順は何ですか?

4

2 に答える 2

2

If you have access to your own dedicated server or virtual machine:

Open up the terminal, type sudo nano /usr/local/lib/php.ini, make the required changes, hit Ctrl + O to save, and then Ctrl + X to exit.

If you want to copy to somewhere else, use cp /usr/local/lib/php.ini /path/to/new/location

If you are using a shared hosting provider

You can not modify the php.ini file or use another version. You will need to override the settings in the .htaccess file or a PHP runtime. Please note that your shared host may have these settings disabled, so you can't hog the shared server's RAM.

File .htaccess example

php_value memory_limit 16M

Runtime example (at the very top of the PHP script)

ini_set('memory_limit', '16M');
于 2012-07-18T18:31:39.247 に答える
1

実行時にほとんどの ini 設定を変更することもできます。変更例はこちらmemory_limit。を使用ini_get_all()してすべての設定とその値の配列を取得し、変更する値を見つけてから を使用しますini_set()。構成オプションは、スクリプトの実行中にこの新しい値を保持し、スクリプトの最後に復元されます。

<?PHP
// before...
print_r(ini_get_all());
/**
 * Array
  (
        ...
        [memory_limit] => Array
            (
                [global_value] => 128M
                [local_value] => 128M
                [access] => 7
            )
        ...
  )
 */

// Set the new value
ini_set('memory_limit', '16M');

// after...
print_r(ini_get_all());
/**
 * Array
   (
       ...
       [memory_limit] => Array
           (
               [global_value] => 128M
               [local_value] => 16M
               [access] => 7
           )
      ...
  )
 */

これは、ホストが許可する権限にも依存します。

于 2012-07-18T18:43:19.293 に答える