Change PHP Configuration Settings

This section provides a tutorial example on how to change PHP configuration settings, like increasing upload_max_filesize and post_max_size to upload large files with PHP scripts.

If you are running a Website using PHP scripts, you may want to change some default configuration settings.

For example, PHP scripts will support only up to 2 MB for a single upload file by default. If you want to increase this limit to 10 MB, you need to following these steps on your Linux computer.

1. Modify two configuration settings in the php.ini file.

herong$ sudo vi /etc/php.ini

post_max_size = 10M
upload_max_filesize = 10M

2. Restart the php-fpm service used by the Apache httpd server.

herong$ systemctl restart php-fpm

==== AUTHENTICATING FOR org.freedesktop.systemd1.manage-units ====
Authentication is required to restart 'php-fpm.service'.
Authenticating as: Herong Yang (herong)

3. Verify the new settings by running the test_phpinfo.php script at http://localhost/test/test_phpinfo.php. You should see:

Directive             Local Value      Master Value

post_max_size         10M              10M
upload_max_filesize   10M              10M

Now you can upload large files with your PHP scripts.

Table of Contents

 About This Book

 Introduction to Linux Systems

 Process Management

 Files and Directories

 Running Apache HTTP Server (httpd) on Linux Systems

 Running Apache Tomcat on Linux Systems

Running PHP Scripts on Linux Systems

 Install and Manage PHP Packages on CentOS

 "php -i" - Dump PHP Environment Information

 Install and Manage PHP Modules on CentOS

 Files Used in PHP "include" Statements

 Publish PHP Scripts on Apache HTTP Server

 Dump PHP/Apache Environment Information

Change PHP Configuration Settings

 Apache PHP file_put_contents() Permission Denied

 SELinux Security Context on /var/www/html

 Migrate Old Scripts to New PHP Release

 Running MySQL Database Server on Linux Systems

 Running Python Scripts on Linux Systems

 Conda - Environment and Package Manager

 GCC - C/C++ Compiler

 OpenJDK - Open-Source JDK

 Graphics Environments on Linux

 SquirrelMail - Webmail in PHP

 Tools and Utilities


 Full Version in PDF/EPUB