Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: fopen() - Operation not permitted
Forum PHP.pl > Forum > PHP
artur9010
Witam, chce "podmienić" wszystkie exec() które nie wymagają użycia tej funkcji (czyli np. exec('cat plik')wink.gif na fopen, niestety pojawia się tutaj drobny problem ponieważ nie mogę otworzyć tego pliku.

Kod z fopen:
  1. [root@alarmpi ~]# php -r 'fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", "r");'
  2. PHP Warning: fopen(): open_basedir restriction in effect. File(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/) in Command line code on line 1
  3. PHP Warning: fopen(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq): failed to open stream: Operation not permitted in Command line code on line 1


Kod z exec:
  1. exec("cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq", $freqArray);
  2. $freq = $freqArray[0]/1000;


Wersja php:
  1. [root@alarmpi /]# php -v
  2. PHP 5.6.11 (cli) (built: Jul 10 2015 10:16:21)
  3. Copyright (c) 1997-2015 The PHP Group
  4. Zend Engine v2.6.0, Copyright (c) 1998-2015 Zend Technologies


Ten sam błąd pojawia się przy file, file_get_contents i każdej innej funkcji która operuje na plikach.
kartin
Co konkretnie jest niejasne w komunikacie błędu?
Cytat
open_basedir restriction in effect. File(/sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq) is not within the allowed path(s): (/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/) in Command line code on line 1


Jeśli chcesz rozszerzyć dozwolone katalogi to szukaj w configu Apache
Kod
php_admin_value open_basedir "/srv/http/:/home/:/tmp/:/usr/share/pear/:/usr/share/webapps/"
i dopisz kolejny katalog.

Ostatecznie możesz też usunąć ograniczenie, ale to jest bardzo zły pomysł.
Kod
php_admin_value open_basedir none


Po wprowadzeniu zmiana nie zapomnij o restarcie Apache.
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.