目次

2024.07.10 PHP-FPMのumask変更

Apache ユーザのumaskを変更したくて、修正したけどApacheだけだと変更できなかった。
PHP-FPMを利用の場合、ちゃんとこちらも変更しないと、正しく反映されなかった。

Apache

mkdir -p /etc/systemd/system/httpd.service.d
cat >> /etc/systemd/system/httpd.service.d/umask.conf << 'EOL'
[Service]
UMask=0002
EOL
systemctl daemon-reload
systemctl restart httpd

PHP-FPM

mkdir -p /etc/systemd/system/php-fpm.service.d
cat >> /etc/systemd/system/php-fpm.service.d/umask.conf << 'EOL'
[Service]
UMask=0002
EOL
systemctl daemon-reload
systemctl restart php-fpm

確認方法

test.php

<?php
ini_set('display_errors', "On");
file_put_contents('./testfile', 'test output file.');
echo "output test";
?>