Up 実行ユーザの確認方法 作成: 2024-12-24
更新: 2024-12-24


    実行ユーザを調べる方法

    方法1 $ cd ~/apache/www $ mkdir test $ vi test/index.phtml <?PHP print "<pre>"; $d = posix_getpwuid(posix_geteuid()); print_r($d); print "</pre>"; ?> (注意:これをコピペするときは,?(全角) を半角の ? に変更すること) apache を起動 $ sudo systemctl start apache2 PC から http://10.10.10.1/test/index.phtml つぎが表示される: Array ( [name] => www-data [passwd] => x [uid] => 33 [gid] => 33 [gecos] => www-data [dir] => /var/www [shell] => /usr/sbin/nologin ) apache-php の実行ユーザは,www-data

    方法2 $ cd ~/apache/www $ mkdir test 実行ユーザが www-data でも書き込めるようにする $ sudo chgrp www-data test $ sudo chmod 775 test $ vi test/index.phtml <?PHP $cmd = "echo \"test\" > ./test.txt"; exec( $cmd ); ?> (注意:これをコピペするときは,?(全角) を半角の ? に変更すること) apache を起動 $ sudo systemctl start apache2 PC から http://10.10.10.1/test/index.phtml $ la -l test -rw-r--r-- 1 www-data www-data 5 Dec 22 17:21 test.txt apache-php の実行ユーザは,www-data