You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

PHP-FPM全局PHP配置修改位置咨询

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 (usually 128M) with your desired limit — for example, memory_limit = 256M
  • upload_max_filesize: Find upload_max_filesize = and set it to something like upload_max_filesize = 64M. A quick heads-up: you should also update post_max_size to a value that’s equal to or larger than upload_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, like date.timezone = Asia/Shanghai (use a valid PHP timezone identifier, such as Europe/London or America/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

火山引擎 最新活动