PHP-FPM全局PHP配置修改位置咨询
Hey there! Nice job finding the /etc/php/8.3/fpm/ directory — that’s exactly the right spot for your PHP 8.3 FPM setup paired with Nginx. Let’s walk through how to update those global settings you need (memory_limit, upload_max_filesize, and date.timezone):
1. Edit the main global PHP config file
All the core global PHP settings live in the php.ini file inside that FPM directory. Open it up with your preferred editor (nano is super straightforward for quick edits):
sudo nano /etc/php/8.3/fpm/php.ini
Use the search function (Ctrl+W in nano) to jump straight to each directive:
- memory_limit: Look for the line starting with
memory_limit =. Replace the default value (usually128M) with your desired limit — for example,memory_limit = 256M - upload_max_filesize: Find
upload_max_filesize =and set it to something likeupload_max_filesize = 64M. A quick heads-up: you should also updatepost_max_sizeto a value that’s equal to or larger thanupload_max_filesize(since the total size of a POST request can’t be smaller than the maximum upload file size) - date.timezone: Look for
;date.timezone =— the semicolon means this line is commented out. Remove the semicolon and set your timezone, likedate.timezone = Asia/Shanghai(use a valid PHP timezone identifier, such asEurope/LondonorAmerica/New_York, depending on your location)
2. Optional: Pool-specific overrides (for advanced use cases)
If you ever need to tweak settings for a specific FPM pool instead of globally, check the files in /etc/php/8.3/fpm/pool.d/ (the default pool is www.conf). You can add lines like php_admin_value[memory_limit] = 512M here, but keep in mind these will override the global php.ini settings for that pool only. Since you’re asking for global changes, you probably won’t need this right now, but it’s good to know!
3. Restart PHP-FPM to apply changes
Once you’ve saved your edits, you have to restart the PHP-FPM service for the new settings to kick in:
sudo systemctl restart php8.3-fpm
You don’t need to restart Nginx here — since Nginx just forwards requests to PHP-FPM, restarting the FPM service is all that’s required.
Double-check your changes
To make sure everything worked, create a temporary phpinfo.php file in your Nginx web root (usually /var/www/html/) with this content:
<?php phpinfo(); ?>
Visit this file in your browser (e.g., http://your-server-ip/phpinfo.php) and search for the directives you modified. Once you confirm the values are updated, delete this file right away — it exposes sensitive server details and is a major security risk.
备注:内容来源于stack exchange,提问作者suncat100




