What are PHP settings?
PHP is a language that runs many websites. Its settings control things like how much memory a script can use, or how big an upload can be. They live in a file called php.ini. The command line is a text window where you type commands instead of clicking.
Step 1: Connect
- Open a terminal. On Windows 10 or later, you can use PowerShell.
- Connect with SSH. SSH is a safe way to control a server from far away.
ssh username@your-server-address
Use the details from your welcome email.
Step 2: See the current settings
php -i | grep memory_limit
This shows the current memory limit. Change memory_limit to any other setting name.
php --ini
This shows which php.ini files PHP reads.
The command line PHP may use a different file than your website does. Check the web value with a page that runs phpinfo(). Delete that page afterwards.
Step 3: Change a setting
- Copy the file as a backup.
cp php.ini php.ini.bak
This keeps a safe copy.
- Open the file in a text editor.
nano php.ini
This opens the file in nano, an easy editor.
- Find the line to change, for example the following.
memory_limit = 256M
upload_max_filesize = 64M
post_max_size = 64M
max_execution_time = 300
Edit the numbers to what you need. Lines starting with a semicolon are comments and are ignored.
- Press Ctrl and O to save. Press Enter. Then press Ctrl and X to leave.
- Restart the web service so the change takes effect. On a VPS with root, the command is often this.
systemctl restart php-fpm
This restarts PHP. The service name differs by system, for example apache2 or php8.2-fpm.
Change a setting for one run only
php -d memory_limit=512M script.php
This runs one script with a bigger memory limit. Nothing is saved.
On shared hosting
You may not be able to edit the main file. Look in your control panel for a PHP settings tool, or ask support in a ticket.
Quick recap
- PHP settings live in
php.ini. - Use
php --iniandphp -ito look. - Back up, edit, save and restart the service.
- Use
php -dfor a one-time change.