search
HomeBackend DevelopmentPHP ProblemHow to modify php.ini on mac

How to modify php.ini on mac

Jan 18, 2022 am 10:37 AM
macphp.ini

How to modify php.ini on mac: 1. Execute the "sudo cp /private/etc/php.ini.default /private/etc/php.ini" command; 2. Directly modify the php.ini configuration file That’s it.

How to modify php.ini on mac

The operating environment of this article: macOS10.15 system, PHP7.1 version, MacBook Air 2019 computer

PHP usage modification php .ini configuration file (Mac)

##1. Configure php.ini# in the PHP environment that comes with Mac

## 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 /etc/php.ini/default , you can make a copy for modification.

Copy command:

sudo cp /private/etc/php.ini.default /private/etc/php.ini

After successful copying

cd /private/etc/sudo vi php.ini

2. Modify the php.ini configuration file in XAMPP For Mac

Modify the php.ini configuration file during installation Directory/Applications/XAMPP/xamppfiles/etc/php.ini

file_uploads=on/offmax_execution_time=30memory_limit=50M upload_max_filesize=20Mupload_tmp_dirpost_max_size=30M
Whether it is allowed to upload files via http
The maximum execution time allowed for the script, if it exceeds this time, an error will be reported
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.
The maximum size of files allowed to be uploaded, this command must be smaller than post_max_size
The temporary storage directory for uploaded files
Allow the post method to accept the maximum size
$_FILES array content is as follows:

$_FILES['myFile']['name']$_FILES['myFile']['type']$_FILES['myFile']['size']$_FILES['myFile'] ['tmp_name']$_FILES['myFile']['error']
The original name of the client's last file
The MIME type of the file, the browser needs to provide support for this information, such as "image/gif"
The size of the uploaded file in bytes
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
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: 0UPLOAD_ERR_INI_SIZE value: 1UPLOAD_ERR_FORM_SIZE value: 2UPLOAD_ERR_PARTIAL value: 3UPLOAD_ERR_NO_FILE Value: 4Value: 5

       文件被上传结束后,默认地被存储在了临时目录中,这时您必须将它从临时目录中删除或移动到其它地方,如果没有,则会被删除。

       也就是不管是否上传成功,脚本执行完后临时目录里的文件肯定会被删除。

附:修改PHP上传文件大小限制的方法

1. 一般的文件上传,除非文件很小.就像一个5M的文件,很可能要超过一分钟才能上传完.

       但在php中,默认的该页最久执行时间为 30 秒.就是说超过30秒,该脚本就停止执行.

       这就导致出现 无法打开网页的情况.这时我们可以修改 max_execution_time

       在php.ini里查找

max_execution_time

       默认是30秒.改为

max_execution_time = 0

       0表示没有限制

2. 修改 post_max_size 设定 POST 数据所允许的最大大小。此设定也影响到文件上传。

       php默认的post_max_size 为2M.如果 POST 数据尺寸大于 post_max_size $_POST$_FILES superglobals 便会为空.

       查找 post_max_size .改为

post_max_size = 150M

3. 很多人都会改了第二步.但上传文件时最大仍然为 8M.

       为什么呢.我们还要改一个参数upload_max_filesize 表示所上传的文件的最大大小。

       查找upload_max_filesize,默认为8M改为

upload_max_filesize = 100M

       另外要说明的是,post_max_size 大于 upload_max_filesize 为佳.

推荐学习:《PHP视频教程

No error occurred, the file was uploaded successfully
The uploaded file exceeds the value limited by the upload_max_filesize option in php.ini
The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form
Only part of the file was uploaded
No file was uploaded
The uploaded file size is 0

The above is the detailed content of How to modify php.ini on mac. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
ACID vs BASE Database: Differences and when to use each.ACID vs BASE Database: Differences and when to use each.Mar 26, 2025 pm 04:19 PM

The article compares ACID and BASE database models, detailing their characteristics and appropriate use cases. ACID prioritizes data integrity and consistency, suitable for financial and e-commerce applications, while BASE focuses on availability and

PHP Secure File Uploads: Preventing file-related vulnerabilities.PHP Secure File Uploads: Preventing file-related vulnerabilities.Mar 26, 2025 pm 04:18 PM

The article discusses securing PHP file uploads to prevent vulnerabilities like code injection. It focuses on file type validation, secure storage, and error handling to enhance application security.

PHP Input Validation: Best practices.PHP Input Validation: Best practices.Mar 26, 2025 pm 04:17 PM

Article discusses best practices for PHP input validation to enhance security, focusing on techniques like using built-in functions, whitelist approach, and server-side validation.

PHP API Rate Limiting: Implementation strategies.PHP API Rate Limiting: Implementation strategies.Mar 26, 2025 pm 04:16 PM

The article discusses strategies for implementing API rate limiting in PHP, including algorithms like Token Bucket and Leaky Bucket, and using libraries like symfony/rate-limiter. It also covers monitoring, dynamically adjusting rate limits, and hand

PHP Password Hashing: password_hash and password_verify.PHP Password Hashing: password_hash and password_verify.Mar 26, 2025 pm 04:15 PM

The article discusses the benefits of using password_hash and password_verify in PHP for securing passwords. The main argument is that these functions enhance password protection through automatic salt generation, strong hashing algorithms, and secur

OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.OWASP Top 10 PHP: Describe and mitigate common vulnerabilities.Mar 26, 2025 pm 04:13 PM

The article discusses OWASP Top 10 vulnerabilities in PHP and mitigation strategies. Key issues include injection, broken authentication, and XSS, with recommended tools for monitoring and securing PHP applications.

PHP XSS Prevention: How to protect against XSS.PHP XSS Prevention: How to protect against XSS.Mar 26, 2025 pm 04:12 PM

The article discusses strategies to prevent XSS attacks in PHP, focusing on input sanitization, output encoding, and using security-enhancing libraries and frameworks.

PHP Interface vs Abstract Class: When to use each.PHP Interface vs Abstract Class: When to use each.Mar 26, 2025 pm 04:11 PM

The article discusses the use of interfaces and abstract classes in PHP, focusing on when to use each. Interfaces define a contract without implementation, suitable for unrelated classes and multiple inheritance. Abstract classes provide common funct

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)