php-fpm临时文件路径问题【Sytemd PrivateTmp】

1、/tmp 下空间占用很大,php-fpm.service引起

[root@nginx tmp]# du * -sh
0   mongodb-27017.sock
0   pymp-6mt3cpxb
0   systemd-private-9a4bb7d57049416db37bc49075e08f42-chronyd.service-coRRiC
0   systemd-private-9a4bb7d57049416db37bc49075e08f42-mariadb.service-qOXdm6
27G systemd-private-9a4bb7d57049416db37bc49075e08f42-php-fpm.service-MmI7Z9
[root@nginx tmp]#

2、如何设置PrivateTmp属性

[root@nginx tmp]# systemctl status php-fpm
● php-fpm.service - The PHP FastCGI Process Manager
   Loaded: loaded (/usr/lib/systemd/system/php-fpm.service; enabled; vendor preset: disabled)
   Active: active (running) since 日 2019-10-06 15:57:30 CST; 5 months 22 days ago
 Main PID: 8125 (php-fpm)
   Status: "Processes active: 1, idle: 19, Requests: 23921674, slow: 0, Traffic: 0.2req/sec"
    Tasks: 21
   Memory: 982.0M
   CGroup: /system.slice/php-fpm.service
           ├─  393 php-fpm: pool www
           ├─  394 php-fpm: pool www
           ├─  395 php-fpm: pool www
           ├─  944 php-fpm: pool www
           ├─  945 php-fpm: pool www
           ├─  946 php-fpm: pool www
           ├─ 1459 php-fpm: pool www
           ├─ 1460 php-fpm: pool www
           ├─ 2401 php-fpm: pool www
           ├─ 2402 php-fpm: pool www
           ├─ 2403 php-fpm: pool www
           ├─ 2984 php-fpm: pool www
           ├─ 2985 php-fpm: pool www
           ├─ 2986 php-fpm: pool www
           ├─ 8125 php-fpm: master process (/etc/php-fpm.conf)
           ├─ 9122 php-fpm: pool www
           ├─12550 php-fpm: pool www
           ├─16855 php-fpm: pool www
           ├─28379 php-fpm: pool www
           ├─31293 php-fpm: pool www
           └─32313 php-fpm: pool www

Warning: Journal has been rotated since unit was started. Log output is incomplete or unavailable.

3、编辑 php-fpm.service 配置文件

vim /usr/lib/systemd/system/php-fpm.service
将 PrivateTmp=true 改为 PrivateTmp=false

4、重启 php-fpm服务

[root@nginx tmp]# systemctl restart php-fpm.service
Warning: php-fpm.service changed on disk. Run 'systemctl daemon-reload' to reload units.

点赞

发表评论

电子邮件地址不会被公开。必填项已用 * 标注