PHP 경고 : 알 수 없음 : 스트림을 열지 못했습니다.
최근 mod_rewrite가 작동하도록 apache httpd.conf 파일을 편집했습니다. 이 문제가 그 원인인지 아닌지는 모르겠지만 그날 부터이 문제가 발생합니다.
이것이 제가 소프트웨어를 실행할 때 프런트 엔드에서 보는 것입니다.
서버 오류 http : // localhost / prestashop /을 ( 를) 검색하는 동안 웹 사이트에서 오류가 발생했습니다 . 유지 관리를 위해 다운되었거나 잘못 구성되었을 수 있습니다.
이를 트리거하는 특정 파일이 없습니다. 그러나 일반적으로 4-5 개의 php 파일로 구성된 작은 프로그램은 잘 실행되지만 PrestaShop과 같은 많은 파일이있는 소프트웨어는 그렇지 않습니다.
나는 로그를 확인했고 이것이 내가 찾은 것입니다.
[Wed Mar 16 19:33:39 2011] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
[Wed Mar 16 19:33:39 2011] [error] [client ::1] PHP Fatal error: Unknown: Failed opening required '/var/www/html/yomig/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
[Wed Mar 16 19:33:39 2011] [error] [client ::1] File does not exist: /var/www/html/favicon.ico
[Wed Mar 16 19:33:41 2011] [error] [client ::1] PHP Warning: Unknown: failed to open stream: Permission denied in Unknown on line 0
[Wed Mar 16 19:33:41 2011] [error] [client ::1] PHP Fatal error: Unknown: Failed opening required '/var/www/html/yomig/index.php' (include_path='.:/usr/share/pear:/usr/share/php') in Unknown on line 0
Mac에서 DocumentRoot를 사용자 Sites 디렉토리로 변경했기 때문에 동일한 오류가 발생했습니다.
이 문제를 해결하기 위해 재귀 명령을 실행하여 Apache 서비스에 읽기 권한이 있는지 확인했습니다.
sudo chmod -R 755 ~/Sites
Fedora를 실행중인 경우 SELinux가 방해하지 않는지 확인하십시오. 다음 명령으로이 문제를 해결하십시오.
sudo /sbin/restorecon -R /var/www/.
자세한 정보 : linuxquestions.org/questions/linux-server-73/
나는 같은 오류가 있었고 내 문제는 파일 권한이 잘못되었다는 것입니다.
chmod 755 index.php
나를 위해 일했습니다.
잘못된 파일 주소를 삽입 할 때이 문제가 발생했습니다. .htaccess
php_value auto_prepend_file "/home/user/wrong/address/config.php"
따라서 auto_prepend_file 을 사용하는 경우 파일 경로를 확인하십시오. .htaccess
PHP가 오류 파일과 줄을 결정할 수 없도록 호출되었습니다 .
여기에 문제를 해결하는 방법이 있습니다. 이동 :
cd /var/www
sudo chown www-data:www-data * -R
sudo usermod -a -G www-data username
사용자 이름으로 사용자 이름을 변경하십시오. 도움이되기를 바랍니다.
내 마음에 진정한 방법은 다음과 같습니다.
# add READ permission to all directories and files under your DocumentRoot
sudo chmod +r /path/to/DocumentRoot/ -R
# add EXECUTE permission to all DIRECTORIES under your DocumentRoot
find /path/to/DocumentRoot/ -type d -exec chmod +x {} \;
SELinux 차단 문제이며 Linux는 httpd 액세스를 차단했습니다. 해결책은 다음과 같습니다.
# restorecon '/var/www/html/wiki/index.php'
# restorecon -R '/var/www/html/wiki/index.php'
# /sbin/restorecon '/var/www/html/wiki/index.php'
오늘 나에게 /home/user/public_html/index.php 와 함께 일어 났고 해결책은 chmod o+x /home/user
이 디렉토리가 X를 가져야하기 때문에 수행하는 것이 었습니다. 그렇지 않으면 아파치 서버가 파일을 나열 할 수 없습니다 (즉, 수행 ls
)
나는 방금이 동일한 문제를 발견했으며 내 경우에는 selinux로 인해 발생했습니다. 비활성화하면 문제가 해결되었습니다. 그리고 아니요, 워크 스테이션에 selinux가 필요하지 않습니다. 감사합니다.
이것은 또한 다른 디렉토리에 대한 Windows 심볼릭 링크를 만든 것을 잊고 다른 디렉토리에 적절한 권한이 없다는 것을 잊은 경우에도 발생합니다 (특히 혼란 스럽습니다).
user1992554의 위 답변에 대한 인용문이 이것은 Linux Mint에서 나를 위해 완벽하게 작동하여 Warning : failed to open stream : Permission denied를 제거했습니다.
cd / var / www
sudo chown www-data : www-data * -R
sudo usermod -a -G www-data 사용자 이름
Fedora 25에서는 SE Linux 문제로 판명되었으며 알림은 저에게 도움이되는이 솔루션을 제공했습니다.
setsebool -P httpd_read_user_content 1
제 경우에는 _www
아파치가 사용 하는 그룹 이 폴더의 액세스 목록에서 누락되었으므로 먼저 다음과 같이 누락 된 그룹을 추가해야했습니다.
sudo chown -R _www ~/path-to-folder
_www
Apache가 실행되는 사용자 또는 그룹으로 변경하십시오 .
아파치의 사용자 / 그룹 찾기 apachectl -S
출력은 엄청나지만 다음과 같이 끝을보십시오.
User: name="_www"
Group: name="_www"
This isn't a direct answer to the question, but I had the same problem. I installed VSFTPD on my Ubuntu Server VPS. I could upload files, but every file I uploaded didn't have execution permissions (all files had rights "600"). These posts explain explain exactly what you have to do to configure your VSFTPD to set default rights on your files:
- Default File Permissions Apache /var/www/
- vsFTPd default uploaded file permissions on Ubuntu not working
Once, this happens to me as well. and when I googled the matter, I got to know that this happens when the permissions on the file is wrongfully set to 000 (which means that no one can read, write, or execute that file). Then I just changed my file permission privilege into Read & Write and it's worked for me.
To change file permission settings on mac: Right click on the particular file and click on Get info from dropdown menu and refer to the sharing and permissions panel and change privilege settings into Read & Write
Check dos and unix file format. This problem is seen on linux platforms if dos file format is used. Use doc2unix command like below and then retry it should work dos2unix *.php
This solution for below problem
Wed Nov 12 07:50:19 2014] [error] [client IP1] PHP Warning: Unknown: failed to
open stream: Permission denied in Unknown on line 0
[Wed Nov 12 07:50:19 2014] [error] [client IP1] PHP Fatal error: Unknown: Failed
opening required '/var/www/html/index.php' (include_path='.:/usr/share/pear:
/usr/share/php') in Unknown on line 0
Except the permissions, the problem can be open_basedir. If you are using it (and I suggest to use it) then check the settings at the VirtualHost :
php_admin_value open_basedir <YOUR ROOT>
Go to folder htdocs
cd htdocs
Execute
chmod -R 755 sites
No need to sudo !
참고URL : https://stackoverflow.com/questions/5326531/php-warning-unknown-failed-to-open-stream
'Development Tip' 카테고리의 다른 글
Laravel Advanced 함수에 변수를 전달하는 방법은 어디입니까? (0) | 2020.11.09 |
---|---|
HTML에서 공백없이 긴 줄을 감싸는 방법은 무엇입니까? (0) | 2020.11.09 |
백본에서 상위 클래스에 액세스 (0) | 2020.11.09 |
R dplyr : 여러 열 삭제 (0) | 2020.11.09 |
DataGridView에 선택한 행이 표시되도록하려면 어떻게해야합니까? (0) | 2020.11.09 |