PHP-Skript als root von der Kommandozeile aus starten

996
Krystian

Wie kann ich ein PHP-Skript als root-Benutzer ausführen? Ich habe es versucht: sudo ./script.php

und in meinem Skript habe ich in einer Zeile: #!/usr/bin/php

1
Was passiert also, wenn Sie es so ausführen? Der Hochstapler vor 11 Jahren 0

1 Antwort auf die Frage

0
OmidTahouri

If I've understood correctly, you shouldn't need #!/usr/bin/php in your PHP script. Presuming you've got php installed with the command available, try the below from command line:

sudo php path/to/script.php 

...where script.php contains only PHP code.