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.
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:
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
- Value: 0; No error occurs and the file is uploaded successfully.
- Value: 1; The uploaded file exceeds the limit of the upload_max_filesize option in php.ini.
- Value: 2; The size of the uploaded file exceeds the value specified by the MAX_FILE_SIZE option in the HTML form.
- Value: 3; Only part of the file was uploaded.
- 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!

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 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.

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 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.

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 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 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 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.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

WebStorm Mac version
Useful JavaScript development tools

Dreamweaver Mac version
Visual web development tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function
