Media Log

아파치 관련 디렉토리와 파일 위치

/etc/httpd/conf -> httpd.conf파일 위치
/home/httpd -> 웹서버 기본 디렉토리
/home/httpd/html -> 홈페이지가 저장되는 디렉토리
/usr/sbin -> 아파치 서버 실행 파일이 있는 디렉토리
/var/log/httpd -> 웹서버 로그파일이 기록되는 위치
/etc/rc.d/init.d/httpd -> 아파치기동스크립트 (init.d 디렉토리에서 ./httpd라고 치고 엔터를 치면 실행 옵션이 쭉 나온다. [root@ss init.d] ./httpd start 이런식으로 작동을 하면된다.)

아파치에서 php설정
LoadModule php5_module libexec/libphp5.so 추가해준다. (모듈 추가부분에)
AddType application/x-tar .tgz 추가 (보통은 존재한다 주석처리되어있으면 주석해제)
AddType application/x-httpd-php .php .html. htm  (.tgz 다음줄에 추가)
Addtype application/x-http-php-source .phps  (다음줄에 추가)

php유동변수 만들기 이거 정말 찾았었는데 이렇게 기초적인걸 몰랐다니. ㅠ.ㅠ
$name = "yyyy";
$$name = "lee";

echo "$$name";
echo ("$yyy");

결과
$yyy
lee

php 파일다운로드 소스
<?
$fileName = $_REQUEST["filePath"];
$t_name = $_REQUEST["t_name"];
$file = "/data/$fileName";

// 브라우저 골라서 헤더를 따로 따로 전송 해 준다.(5.5 일때는 다르게 해줘야 함)
if(strstr($HTTP_USER_AGENT, "MSIE 6.") or strstr($HTTP_USER_AGENT, "MSIE 5.5"))
{
 Header("Content-type: application/x-msdownload");
 header("Content-type: application/octet-stream");
 header("Cache-Control: private, must-revalidate");
 header("Pragma: no-cache");
 header("Expires: 0");
}
else
{
 header("Cache-control: private");
 header("Content-type: file/unknown");
 header('Content-Length: '.filesize("$file"));
 Header("Content-type: file/unknown");
 Header("Content-Disposition: attachment; filename=$fileName");
 Header("Content-Description: PHP5 Generated Data");
 header("Pragma: no-cache");
 header("Expires: 0");
}

if(file_exists("$file"))
{
 $fp = fopen("$file", "r");
 if(!fpassthru($fp))
 fclose($fp);
}
else
{
 echo "<script>alert('해당 파일이나 경로가 존재하지 않습니다.');history.back();</script>";
}
?>

다른 url에 있는 파일 존재여부
파일 존재여부 file_exists는 상대디렉토리를 이용해 파일의 존재여부를 알아낸다.
url을 이용해서 알아볼려면 아래 처럼 하면된다.

$imgpath = "http://hoooow.tistory.com/data/img.gif";
$file_headers = @get_headers($imgpath);
if($file_headers[0] == 'HTTP/1.1 404 Not Found'){"이미지 파일이 없다~";}