개발! 딱 깔끔하고 센스있게!

Cenos 7 / 아파 치 / PHP - Makdir (): 권한 이 거부 되 었 습 니 다. 본문

개발 스크랩 메모/PHP

Cenos 7 / 아파 치 / PHP - Makdir (): 권한 이 거부 되 었 습 니 다.

렉사이 2020. 11. 23. 02:41

중 복 될 때 까지!나 를 심연 으로 추방 하고 내 이 야 기 를 들 어 봐.)

나 는 내 가 일 하 는 회 사 를 위해 Intranet 사이트 를 개발 해 왔 다.

처음에 나 는 Windows 7 / IIS 를 직접 운영 하 는 워크스테이션 에서 그것 을 개발 했다.

사이트 / 애플 리 케 이 션 이 거의 완성 되면 서 저 는 아파 치 를 운영 하 는 Cenos 7 기 계 를 얻 었 습 니 다.

그래서 저 는 그 시스템 으로 옮 기기 시 작 했 습 니 다.

나 는 이미 대부분의 작은 문 제 를 해결 하 였 고, 지금 은 사이트 가 운행 하기 시작 했다.

그러나 사이트 의 일부분 은 우리 의 데이터 베 이 스 를 연결 하고 로그 인 자 를 기반 으로 로그 인 로그 디 렉 터 리 / 파일 을 만 듭 니 다.

이 부분 은 mkdir () 함 수 를 사용 하지만 권한 문 제 를 얻 었 습 니 다.

mkdir(): Permission denied 

다음은 내 가 이미 한 일이 다.

  • Since I'm using Centos 7, the Apache user/group is apache:apache. I've utilized chown and changed the owner of /var/www/html/ and the Logs folder to the apache user/group. To be on the safe side, I double checked the httpd.conf and also checked the running processes to ensure I had the correct user/group.
  • I've attempted, just for testing purposes, to change the permissions of all of those folders to chmod 777, but getting the same error.
  • Searched StackOverflow from top to bottom, and only getting answers for things that I've already tried, but to no avail.

그래서 저 는 chmod 나 chown 을 사용 해서 방문 할 폴 더 의 권한 을 변경 하 더 라 도 같은 유형의 오 류 를 만 날 수 있 습 니 다.

안전 을 위해 PHP 사용자 도 검 사 했 고 apache 사용자 도 사용 하고 있 습 니 다.

누 군가 다른 견 해 를 가 질 수 있다 면, 왜 일 을 하지 않 고, 권한 이 바 뀌 더 라 도, 나 를 일 깨 워 주 십시오.만약 내 가 이런 특수 상황 을 설명 하 는 글 을 우연히 놓 쳤 다 면, "복사" 를 외 치 며 나 를 심연 으로 추방 했다.

하하:)


편집좋 습 니 다.

진일보 한 테스트 에서 저 는 두 가지 문 제 를 발 견 했 는데 그것 이 전체 문 제 를 일 으 킨 것 같 습 니 다.

  1. PHP is trying to set permissions for the folder when it's created from the script, and it seems the server doesn't like that even if apache is the owner. Upon removing that portion of the code, the permissions error goes away, and I get an error with "no such file or directory."
  2. When testing creating directories with the user Apache through sudo, it was able to make a directory without a problem. However, my PHP script is creating 2 directories, and then a log file in the last one created. It seems that you can't create two directories at the same time?? For example, there is a Logs folder already created, and PHP is trying to create two directories under it, one for the user's ID and then another folder inside of that one with the date. So once the PHP script runs, it should create something like "Logs/5235/3-3-2015/"

PHP 에 있 는 mkdir 에 서 는 재 귀적 가 치 를 트 루 로 설정 하려 고 하 였 으 나 이 때 는 최초 로 제 기 된 권한 문 제 를 얻 었 습 니 다.

Recursive / mode 가 삭 제 될 때 권한 문 제 는 없 지만, 포 함 된 디 렉 터 리 는 만 들 수 없습니다.


편집

내 이론 을 테스트 하기 위해 서 나 는 패 널 을 삭제 하고 mkdir 에 게 목록 을 만 들 라 고 시 도 했 습 니 다.

오류 가 발생 한 것 은 이전 과 같 습 니 다.

비록 그것 이 아파 치 소유 이 고 내 가 777 으로 설정 해도 권한 문 제 를 되 돌려 준다.

대답 하 다.

755 / 777 권한 을 가지 고 있 지만 SELi눅 스 가 httpd 기록 / dir 를 만 드 는 것 을 막 고 있 기 때 문 일 수 있 습 니 다.

시도:

chcon -R -t httpd_sys_content_t /path/to/www chcon -R -t httpd_sys_content_rw_t /path/to/www/dir/for/rw 

추가 정보: http: / wiki. centos. org / Tips Antricks / selinux 도구

Comments