본문 바로가기

프로그래밍/PHP

default -> FTP 기능 구현중 - SeLinux 와의 한판승부

일단 본인은 다른사람들이 전혀 겪지 못한 잡스런 오류/삽질을 전부 겪는다.ㅜㅜ

PHP로 FTP연결하는 함수중 ftp_connect함수에서 내 ftp서버로의 localhost접속이 이루어 지지 않는것이었다... 젠장할..

다른사람들은 setsebool -P ftpd_disabled_trans 1 이걸 해보라는데 본인은 더 특이하게도 ftpd_disabled_trans 란 정책이 존재하지 않는것이었다.ㅠㅠ

어떻게 할까 하다가

PHP.net 에서 참고될 문장을 첨부해 볼까한다.

I had some major problems running ftp_connect from my Web Browser and not from the CLI from 1 server and yet from another Internal server I had no trouble at all. After a few hours I figured out this was because SELINUX was enabled on one server and DISABLED on the server that it worked on.

So in short, if you are having trouble with connecting in your Web Browser make sure you have HTTPD connect's enabled in it like so at the command prompt:

; Turns it on temporarily.
/usr/sbin/setsebool httpd_can_network_connect=1

; Turns it on Permenantly
/usr/sbin/setsebool -P httpd_can_network_connect=1

I hope this helps make someones life a little easier. :)
(I actually found this fix on the fopen manual page).


여기서 잘 봐야 할것은 진한 부분이다

httpd_can_network_connect 정책을 on시켜 주면 ftp에서 localhost의 접속이 원할하게 이루어 진다.

저걸 알기 전까지는 ftp_connect("본인의 ftp주소", 포트번호); 이것의 리턴값이 1이었다.

그 이후로는 올바르게 잘~ 작동한다.

아 젠장 삽질 만세다.ㅜㅜ