If you need to increase the upload max filesize and adjust other PHP settings but don't have access to the MultiPHP INI Editor or prefer using the .htaccess file, you can do this easily through a few simple steps. Here’s how to modify your .htaccess file to change these PHP values.

What You’ll Learn:

  1. Accessing the .htaccess file.
  2. Adding PHP directives to increase upload limits.
  3. Verifying the changes.

1. Log in to cPanel

Start by logging into your cPanel account:

  • Go to your cPanel login URL (usually yourdomain.com/cpanel).
  • Enter your username and password.

2. Access the File Manager

  1. In the cPanel dashboard, scroll down to the Files section.
  2. Click on File Manager.
  3. Navigate to your website’s root directory (usually /public_html).

3. Locate or Create the .htaccess File

  1. Look for the .htaccess file in the root directory. If it doesn’t exist, you can create one:
    • Click on the + File button in the File Manager.
    • Name the new file .htaccess.
  2. Right-click on the .htaccess file and select Edit.

4. Add PHP Directives

In the .htaccess file, add the following lines to increase the upload max filesize and adjust other PHP values:

apache

Copy code

# Increase upload max filesize

php_value upload_max_filesize 64M

php_value post_max_size 64M

php_value memory_limit 128M

php_value max_execution_time 300

 

Explanation of Settings:

  • upload_max_filesize: Maximum size for uploaded files.
  • post_max_size: Maximum size for POST data; should be larger than upload_max_filesize.
  • memory_limit: Maximum amount of memory a script may use.
  • max_execution_time: Maximum time in seconds a script can run.

5. Save Changes

  1. After adding the directives, click Save Changes to apply your edits.

6. Verify Changes

To ensure that your changes have taken effect:

  1. Create a PHP Info File:
    • In the File Manager, create a new file named phpinfo.php.

Add the following code:
php
Copy code
<?php

phpinfo();

?>

  • Save the file.
  1. Open the PHP Info Page:
    • In your web browser, go to yourdomain.com/phpinfo.php.
    • Look for the upload_max_filesize, post_max_size, and memory_limit settings to confirm that they have been updated.

7. Best Practices

  • Backup Configuration: Always backup your current .htaccess file before making changes.
  • Test Your Application: After making these changes, test file uploads to ensure everything is functioning correctly.
  • Remove phpinfo.php: For security reasons, delete the phpinfo.php file once you’ve verified the settings.

Conclusion

Modifying the .htaccess file is an effective way to increase the upload max filesize and other PHP settings on your website. By following these steps, you can easily make the necessary adjustments to accommodate larger file uploads and improve the overall functionality of your web applications.

Помог ли вам данный ответ? 0 Пользователи нашли это полезным (0 голосов)