search
HomeOperation and MaintenanceCentOSHow to modify php.ini in centos

How to modify php.ini in centos

Sep 27, 2020 pm 03:30 PM
centos

How to modify php.ini in centos: first use the phpinfo function to find the location of "php.ini"; then use Xshell to connect to the server; then enter the file and search for keywords; and finally modify it through the operation command.

How to modify php.ini in centos

Recommended: "centos Getting Started Tutorial" "PHP Video Tutorial

1.php.ini attribute default value
file_uploads = on ;Switch whether to allow file uploading through HTTP. The default is ON
upload_tmp_dir; Files are uploaded to the server where temporary files are stored. The default is the system default temporary folder.
upload_max_filesize: The maximum size of files allowed to be uploaded. The default is 2M
post_max_size: refers to the maximum value that can be received through POST to PHP through the form, including all values ​​in the form. The default is 8M

max_execution_time: The maximum time value (seconds) for each PHP page to run, the default is 30 seconds
max_input_time: The maximum time required for each PHP page to receive data, the default is 60 seconds
Change to (reference)
max_execution_time = 600
max_input_time = 600
file_uploads = on
upload_tmp_dir = /tmp
upload_max_filesize = 32m
post_max_size = 32m

2. Configure php.ini

Restart the Apache server

Centos (7)/Linux

1. Find php.ini

Create php file and use it The phpinfo() function finds the location of php.ini

echo phpinfo();

as shown in the picture:

How to modify php.ini in centos

2. Use Xshell to connect to the server and vi to edit the file

# vi /etc/php.ini

3. Enter the file and search for keywords (see the beginning, just change it to what you want)

1) In command mode (press ESC to enter, if there is no response, just type the command) and hit the slash lever ( / ) 2) "/" appears in the status bar (lower left foot of the screen). Enter the keyword you are looking for and press Enter.
3) If you want to continue to search for this keyword, type the character n / type the character N (capital N) to search forward;

4. Modify,

The following is the command Some operation commands in mode

Operation Analysis
i Enter text editing mode
Esc Exit text editing mode
:w Save the current modifications but do not exit
:q Exit vi without saving the file
:wq

Save the current modifications and exit vi

:q! Do not save the file and force exit vi
:e! Discard all changes and start editing again from the last time you saved the file

5.php.ini needs to be restarted after modification Apache server (the Internet says to restart PHP, my attempt failed, and it succeeded after restarting Apache)

1) PHP start, stop and restart commands

service php-fpm start
service php-fpm stop
service php-fpm reload

2) Apache start stop and restart command

service httpd start start
service httpd restart restart
service httpd stop Stop the service

6. Attached check the reason why the file upload failed

$_FILES['file']['error'] Display the error code related to the file upload

  1. Value: 0; No error occurs and the file is uploaded successfully.
  2. Value: 1; The uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
  3. Value: 2; The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
  4. Value: 3; Only part of the file was uploaded.
  5. Value: 4; No files were uploaded.

The above is the detailed content of How to modify php.ini in centos. 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
Comparing CentOS Replacements: Features and BenefitsComparing CentOS Replacements: Features and BenefitsMay 01, 2025 am 12:05 AM

Alternatives to CentOS include AlmaLinux, RockyLinux, and OracleLinux. 1.AlmaLinux provides RHEL compatibility and community-driven development. 2. RockyLinux emphasizes enterprise-level support and long-term maintenance. 3. OracleLinux provides Oracle-specific optimization and support. These alternatives have similar stability and compatibility to CentOS, and are suitable for users with different needs.

CentOS vs. Other Linux Distributions: A ComparisonCentOS vs. Other Linux Distributions: A ComparisonApr 30, 2025 am 12:07 AM

CentOS is suitable for enterprise and server environments due to its stability and long life cycle. 1.CentOS provides up to 10 years of support, suitable for scenarios that require stable operation. 2.Ubuntu is suitable for environments that require quick updates and user-friendly. 3.Debian is suitable for developers who need pure and free software. 4.Fedora is suitable for users who like to try the latest technologies.

CentOS's Departure: Choosing the Right AlternativeCentOS's Departure: Choosing the Right AlternativeApr 29, 2025 am 12:04 AM

Alternatives to CentOS include AlmaLinux, RockyLinux, and OracleLinux. 1.AlmaLinux and RockyLinux rebuild RHEL 1:1, providing high stability and compatibility, suitable for enterprise environments. 2. OracleLinux provides high performance through UEK, suitable for users who are familiar with the Oracle technology stack. 3. When choosing, stability, community support and package management should be considered.

CentOS's Replacement: Exploring the New OptionsCentOS's Replacement: Exploring the New OptionsApr 28, 2025 am 12:17 AM

CentOS alternatives include RockyLinux, AlmaLinux, and OracleLinux. 1. RockyLinux and AlmaLinux provide stable distributions compatible with RHEL, suitable for users who need long-term support. 2. CentOSStream is suitable for users who focus on new features and development cycles. 3. OracleLinux is suitable for users who need enterprise-level support.

Replacing CentOS: Identifying Suitable ReplacementsReplacing CentOS: Identifying Suitable ReplacementsApr 27, 2025 am 12:04 AM

CentOS needs alternatives because CentOSStream no longer provides long-term support. Alternative options include: 1. RockyLinux, which provides 10 years of life cycle support, suitable for users who need stability. 2.AlmaLinux also provides 10 years of support and has strong community support. 3. OracleLinux, provides RHEL-compatible version, and flexible life cycle management.

The End of CentOS: Evaluating the ImpactThe End of CentOS: Evaluating the ImpactApr 26, 2025 am 12:03 AM

The end of CentOS has had a significant impact on users, with users having the option of RHEL, AlmaLinux, Debian or Ubuntu as alternatives. 1. The migration cost is high, requiring time and money. 2. Community division affects open source projects. 3.RHEL provides commercial support, but it is costly. 4.AlmaLinux is similar to CentOS and has low migration costs. 5. Debian and Ubuntu need more time to adapt.

CentOS: An Explanation of the Decision-Making ProcessCentOS: An Explanation of the Decision-Making ProcessApr 25, 2025 am 12:03 AM

CentOS is suitable as an enterprise-class server operating system because it is stable, secure and free. 1) It is based on RHEL and provides high compatibility with RHEL. 2) Use yum for package management to ensure that the software is easy to install and update. 3) The community regularly releases security patches, with a support cycle of up to 10 years.

The Discontinuation of CentOS: Understanding the FactorsThe Discontinuation of CentOS: Understanding the FactorsApr 24, 2025 am 12:01 AM

The reason why CentOS stopped maintaining is RedHat's strategic change. User response strategies include: 1. Migrating to other distributions, such as UbuntuServer, Debian or RockyLinux; 2. Continue to use CentOS7 until June 2024; 3. Turning to CentOSStream; 4. Build solutions, such as custom distributions based on RHEL or using container technology.

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

WebStorm Mac version

WebStorm Mac version

Useful JavaScript development tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

PhpStorm Mac version

PhpStorm Mac version

The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function