This tutorial explains how to locate your
php.ini file and change the php
memory_limit setting from the command line.
- Locate php.ini file
- Configure php.ini file
- Restart Apache2 webserver
1. Locate php.ini file
Firstly, you need to locate your
php.ini file. Different Linux distribution store php configuration files in different directories so you can lookup the
php.ini file in your php configuration if you are not sure where the file is located.
php -i | grep php.ini
In our case the
php.ini file is located in
2. Configure php.ini file
2.1. Edit your
php.ini file using a text editor.
2.2. Next, find the
memory_limit settings in the
php.ini file. You can search the contents of the
php.ini file by pressing the
Ctrl + w combination on your keyboard while editing the
php.ini file. Then, change the php memory limit value to the desired value in megabytes (
M). Now save changes and exit the text editor.
memory_limit = 256M.
Note: You will notice many other commonly used php settings in the
php.ini file, which you can modify according to your needs, such as
3. Restart Apache2 webserver
Finally, you need to restart your Apache2 webserver for changes to take effect.
systemctl restart httpd.service
You have successfully located the
php.ini configuration file and changed the php