How can you increase the PHP parameters upload_max_filesize, post_max_size, and memory_limit for my environment?

How to Increase PHP Parameters for ‘upload_max_filesize’, ‘post_max_size’, and ‘memory_limit’ on AccuWeb.Cloud?

PHP, a widely used server-side scripting language, is often configured to handle file uploads, data processing, and web applications. On AccuWeb.Cloud, tuning PHP parameters such as ‘upload_max_filesize‘, ‘post_max_size‘, and ‘memory_limit‘ is essential for optimizing your environment, especially if you’re managing uploads or complex scripts. This guide provides a complete step-by-step approach to increasing these values and ensuring a smoother and more efficient experience on AccuWeb.Cloud.

Increase PHP parameters

  • Understanding the Key PHP Parameters
  1. upload_max_filesize: This parameter sets the maximum file size for uploads. Any file exceeding this limit will trigger an error, so this setting must match your requirements. For example, if you’re managing media-rich applications, a large file size (e.g., 20 MB or more) may be necessary.
  2. post_max_size: This setting limits the entire POST request’s data size, which includes all files and form data. A recommended approach is to set this higher than ‘upload_max_filesize’, accommodating both file uploads and other data.
  3. memory_limit: This defines the maximum memory PHP scripts can consume. Insufficient memory can lead to failures during operations like file uploads or processing tasks. Setting this higher (such as 256 MB or more) for memory-intensive applications, like image or data processing, can prevent such issues.

Steps to Increase PHP Parameters on AccuWeb.Cloud

Step 1: Open your browser and visit the AccuWeb.Cloud dashboard (https://app.cp-accuweb.cloud/). Enter your login credentials. Once logged in navigate to your environment.

Login to AccuWeb.Cloud dashboard

Step 2: From the main dashboard, locate your target environment (e.g. the one hosting your website or application). Each environment on AccuWeb.Cloud has an isolated set of configurations, making it possible to adjust PHP parameters per environment.

Step 3: Under your environment, look for the Config button associated with the application server. Clicking Config opens a set of server settings, which includes access to the PHP configuration files.

Access PHP configuration files

Step 4: Locate the ‘php.ini‘ File, To locate the ‘php.ini‘ file, you can use one of the following methods:

Open web SSH access to connect to the server via SSH. Run the following command to display the current ‘php.ini’ file path:

php –ini

This command lists the active configuration file, including the full path.

Active configuration file

Step 5: Once the ‘php.ini‘ file is open, use the search feature to find each parameter (‘upload_max_filesize‘, ‘post_max_size‘, and ‘memory_limit‘). Update each parameter’s value according to your needs. Here’s a typical example:

upload_max_filesize = 100M
post_max_size = 128M
memory_limit = 928M

Tip: Always make sure ‘post_max_size‘ is higher than ‘upload_max_filesize‘ and allocate enough ‘memory_limit‘ for your scripts.

Step 6: After editing the values, save the ‘php.ini‘ file. Ensure permissions are correct and that the changes are preserved.

Ensure permissions

Step 7: To apply the new PHP configurations , restart the environment. In AccuWeb.Cloud Dashboard, locate the restart option for your application server. Confirm the restart. This ensures that PHP recognizes the new parameter values.

New PHP configurations

Step 8: Verify the New Settings by creating a PHP info file to confirm that the changes have taken effect:

<?php phpinfo(); ?>

Access the created file in your browser (e.g. ‘https://yourdomain.com/phpinfo.php’). Look for the values of ‘upload_max_filesize‘, ‘post_max_size‘, and ‘memory_limit‘ to confirm they match the new settings.

Creating a PHP info file

Important: Once verified delete the ‘phpinfo.php‘ file for security purposes.

Conclusion

Configuring PHP parameters like upload_max_filesize, post_max_size, and memory_limit is a crucial step in optimizing web applications hosted on AccuWeb.Cloud. These settings directly impact how the server handles data-intensive operations like file uploads and memory-heavy processes. By understanding and adjusting these parameters, you can ensure that your application runs smoothly provides a better user experience, and minimizes downtime or errors that could otherwise arise due to configuration limitations.