Php apache linux kullanıcı alın

4 Cevap php

Ben yabancı bir linux sistemde kulüpler ve üzerinde çalışır apache kullanıcıyı belirlemek gerekir (ve bu yüzden php yapar).

The aim: I need to get the owner of the script (this is no problem as I can use SplFileInfo) and compare it to the owner of the apache process.

Ben herhangi bir alternatif önerilere açığım.

Regards, Mario

Edit: Additional info:

The script is a thumbnail generator, that uses an XML file to generate thumbs from larger images. The script needs to create folders and write files. As I cannot influence the php configuration and I do not have any shell access, this has to be done very silently. The creation process stopps via exception and sends a mail on failue. As most of php's function cannot throw exceptions on failue, I need some manual checks to determine the environment I'm in. Therefore I need the apache user to compare it to some directory or fileowner.

4 Cevap

Sen çalıştırmak için exec function php çağırabilirsiniz whoami:

<?php echo exec('whoami'); ?>

posix_getuid () ve posix_getpwuid (bkz.)

phpinfo sistem birçok bilgi dökümü. Apache2 yükler için, apache kullanıcı ve grup kimlikleri görüntüleyen bir bölüm vardır. Sadece bir satır, phpinfo () olan bir php komut dosyası oluşturmayı deneyin ve web tarayıcınızda açın.

Burada bazı karmaşık cevaplar.

Bu benim için çalışıyor:

$user = getenv('APACHE_RUN_USER');

Bu bir soru sordum ama şimdi kesinlikle orada beri apache eklenmiş sadece yeni bir şey olup olmadığından emin değil.