How to modify the configuration file of php: first find and open the php.ini configuration file; then find the "max_execution_time" item in the file; finally modify the parameters and save it.
The operating environment of this tutorial: MacOS X system, php5.6. This article is applicable to all brands of computers.
Recommended: "PHP Video Tutorial"
There is no default php.ini file in Mac OS X, but there is a corresponding template file php.ini.default, located at /private/etc/php.ini.default or Say /etc/php.ini/default, you can make a copy and modify it yourself.
Copy command:
sudo cp /private/etc/php.ini.default /private/etc/php.ini
After successful copying
cd /private/etc/sudo vi php.ini
Modify the php.ini configuration file during installation Directory/Applications/XAMPP/xamppfiles/etc/php.ini
file_uploads=on/off | Whether it is allowed to upload files via http |
max_execution_time=30 | The maximum execution time allowed for the script, if it exceeds this time, an error will be reported |
memory_limit=50M | Set the maximum amount of memory that a script can allocate to prevent runaway scripts from occupying too much memory. This instruction only takes effect when the –enable-memory-limit flag is set during compilation. |
upload_max_filesize=20M | The maximum size of files allowed to be uploaded, this command must be smaller than post_max_size |
upload_tmp_dir | The temporary storage directory for uploaded files |
post_max_size=30M | Allow the post method to accept the maximum size |
$_FILES array content is as follows:
$_FILES['myFile']['name'] | The original name of the client's last file |
$_FILES['myFile']['type'] | The MIME type of the file, the browser needs to provide support for this information, such as "image/gif" |
$_FILES['myFile']['size'] | The size of the uploaded file in bytes |
$_FILES['myFile'] ['tmp_name'] | The temporary file name stored on the server after the file is uploaded, usually the system default. It can be specified in upload_tmp_dir of php.ini, but setting it with the putenv() function will not work |
$_FILES['myFile']['error'] | Status code related to the file upload |
$_FILES['myFile']['error']
Status code related to the file upload . [‘error’] was added in PHP version 4.2.0. The following is its description: (They became constants after PHP3.0)
UPLOAD_ERR_OK Value: 0 | No error occurred, the file was uploaded successfully |
UPLOAD_ERR_INI_SIZE value: 1 | The uploaded file exceeds the value limited by the upload_max_filesize option in php.ini |
UPLOAD_ERR_FORM_SIZE value: 2 | The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form |
UPLOAD_ERR_PARTIAL value: 3 | Only part of the file was uploaded |
UPLOAD_ERR_NO_FILE Value: 4 | No file was uploaded |
Value: 5 | The uploaded file size is 0 |
文件被上传结束后,默认地被存储在了临时目录中,这时您必须将它从临时目录中删除或移动到其它地方,如果没有,则会被删除。
也就是不管是否上传成功,脚本执行完后临时目录里的文件肯定会被删除。
但在php中,默认的该页最久执行时间为 30 秒.就是说超过30秒,该脚本就停止执行.
这就导致出现 无法打开网页的情况.这时我们可以修改 max_execution_time
在php.ini里查找
max_execution_time
默认是30秒.改为
max_execution_time = 0
0表示没有限制
post_max_size
设定 POST 数据所允许的最大大小。此设定也影响到文件上传。 php默认的post_max_size
为2M.如果 POST 数据尺寸大于 post_max_size
$_POST
和 $_FILES superglobals
便会为空.
查找 post_max_size
.改为
post_max_size = 150M
为什么呢.我们还要改一个参数upload_max_filesize
表示所上传的文件的最大大小。
查找upload_max_filesize
,默认为8M改为
upload_max_filesize = 100M
另外要说明的是,post_max_size
大于 upload_max_filesize
为佳
The above is the detailed content of php modify configuration file. For more information, please follow other related articles on the PHP Chinese website!