2012. 5. 19. 12:14

Trigger an Error

오류 발생시키기(Trigger an Error)
사용자가 데이터를 입력할 수 있는 스크립트에서는,
불법적인 입력이 발생했을때 오류를 발생시키는 것이 상당히 유용합니다.

PHP에서는, 이걸 trigger_error() 함수를 통해 실행 할 수 있습니다

'' 카테고리의 다른 글

그누보드 게시판 테이블 그리고 댓글  (0) 2014.06.16
남은 글자수 체크  (1) 2012.07.23
jQuery Mobile 페이지 이동  (1) 2011.11.03
자바스크립트 레퍼런스  (0) 2011.11.03
소셜 관련 3가지  (0) 2011.09.29
Posted by 다오나무
영삼이의 IT정보2012. 4. 30. 15:33

PHP에서 꼭 알아야 될 함수

(1) 변수 관련 함수

☞ empty 함수

      

구문 : int empty(mixed var)
기능 : 변수가 설정되어 있는지 알아본다.

변수가 설정되어 있지 않으면 true를 리턴하고, 값이 있으면 false를 리턴합니다.

<파일명 : ex29.php>

<?
$a="";
$b="string";
if (empty($a)) echo "a empty<br>";
if (empty($b)) echo "b empty<br>";
?>

☞ isset 함수

      

구문 : int isset(mixed var)
기능 : 변수가 설정되어 있는지 알아본다.

변수가 설정되어 있으면 true, 그렇지 않으면 false를 리턴합니다.

만약에 unset()으로 변수가 이미 해제되었다면 더 이상 isset()는 true를 리턴하지 않습니다.

<파일명 : ex30.php>

<?
$a="string";
if (isset($a)) echo "1. a is set<br>";
unset($a);
if (isset($a)) echo "2. a is set<br>";
?>

☞ unset 함수

      

구문 : int unset(mixed var)
기능 : 변수의 설정을 해제한다.

변수의 설정을 해제한 루 true를 리턴합니다.

 

(2) 문자열 관련 함수

☞ addslashes 함수

      

구문 : string addslashes(string str)
기능 : 필요한 곳을 역슬래시(\)로 감싼다.

문자열이 작은 따음표(')나 큰 따음표("), 또는 역슬래시(\)와 같은 문자를 가지고 있는 경우 이 문자 앞에 역슬래시(\)를 추가하여 전체 문자열을 반환합니다.

보통 SQL 문에서 작은 따음표나 큰 따음표에 역슬래시를 추가할 때 많이 사용합니다.

<파일명 : ex31.php>

<?
$str="addslash 연습입니다. '연습'";
echo "addslash() 함수 사용 전 : $str <br>";
$str=addslashes($str);
echo "addslash() 함수 사용 후 : " . $str . "<br>";
?>

☞ stripslashes 함수

      

구문 : string stripslashes(string str)
기능 : addslashes()로 역슬래시가 추가된 문자열에서 역슬래시를 제거한다.

addslashes() 함수를 통해 역슬래시 처리가 된 문자에서 역슬래시(\) 문자를 제거하여 원 상태로 되돌립니다.

<파일명 : ex32.php>

<?
$str="addslash 연습입니다. '연습'";
echo "addslashes() 함수 사용 전 : $str <br>";
$str=addslashes($str);
echo "addslashes() 함수 사용 후 : $str <br>";
$str=stripslashes($str);
echo "stripslashes() 함수 사용 후 : $str <br>";
?>

☞ echo 함수

      

구문 : echo(string arg1, string [argn] …)
기능 : 하나 또는 그 이상의 문자열을 출력한다.

인자들을 모두 출력합니다.

<파일명 : ex33.php>

<?
$str1="echo 연습입니다.";
$str2="echo 사용하기";
echo $str1 . "<br>";
echo $str1.$str2;
?>

☞ explode 함수

      

구문 : array explode(string separator, string string)
기능 : 구분자를 사용하여 문자열을 나눈다.

첫 번째 인자를 구분자로 하여 두 번째 인자를 나누어 배열로 리턴합니다.

<파일명 : ex34.php>

<?
$str="aaa;bbb;ccc;ddd;eee;fff;";
$array=explode(";",$str);
for ($i=0, $max=count($array); $i<$max; $i++) {
   echo "$i = $array[$i] <br>";
}
?>

☞ htmlspecialchars 함수

      

구문 : string htmlspecialchars(string string)
기능 : 특수문자들을 HTML 코드로 바꾼다.

게시판이나 방명록 등에서 사용자가 입력한 특수문자들을 변환시킵니다.

  &(ampersand)를 '&'로
  "(double quote)를 '"'로
  <(less than)을 '&It;'로
  >(greater than)을 '>'로 바꾸어 리턴합니다.

위의 4가지 특수문자를 제외한 나머지 문자는 변환하지 않습니다.

<파일명 : ex35.php>

<?
$str="HTML 에서 <b>특수문자</b> 변환하기";
echo "htmlspecialchars() 사용 전 : $str <br>\n";
$str=htmlspecialchars($str);
echo "htmlspecialchars() 사용 후 : $str <br>";
?>

☞ nl2br 함수

      

구문 : string nl2br(string string)
기능 : 개행(\n)을 <BR>태그로 바꾼다.

폼으로 입력받을 때 입력하는 사람이 엔터를 치면 다음 줄로 넘어갑니다. 그런데 입력받은 내용을 데이터베이스에 넣고 나중에 출력할 때는 문자들이 모두 붙어서 나옵니다. 따라서 데이터베이스에서 내용을 얻어 브라우저로 보여줄 때 함수를 사용하면 다음 줄로 넘어가게 보입니다.

<파일명 : ex36.php>

<?
$str="nl2br 을 위한 예제
한줄...
두줄...
세줄...
";

echo "nl2br() 사용 전 : $str <br>\n";
$str=nl2br($str);
echo "nl2br() 사용 후 : $str <br>";
?>

☞ printf 함수

      

구문 : string nl2br(string string)
기능 : 개행(\n)을 <BR>태그로 바꾼다.

echo 함수와 비슷한 역할을 합니다.

<파일명 : ex37.php>

<?
$a=14.5;
$b=3.3;
$sum=$a+$b;
printf("%02.2f + %02.2f = %02.2f <br>", $a, $b, $sum);
printf("결과값의 정수값 = %d", $sum);
?>

☞ sprintf 함수

      

구문 : string sprintf(string format, mixed [args]...)
기능 : 포맷 문자열을 통해 지정해 준 포맷으로 문자열을 반환합니다.

 sprintf() 함수는 C에서 사용법과 비슷하게 지정해 준 포맷에 맞게 문자열을 반환합니다.

<파일명 : ex38.php>

<?
$a=14.5;
$b=3.3;
$sum=$a+$b;
$str=sprintf("%02.2f + %02.2f = %02.2f <br>", $a, $b, $sum);
echo $str;
$str=sprintf("정수값 = %d <br>", $sum);
echo $str;
$str=sprintf("실수값 = %f <br>", $sum);
echo $str;
?>

☞ strip_tags 함수

      

구문 : string strip_tags(string str, string [allowable_tags])
기능 : 문자열에서 HTML과 PHP 태그를 제거한다.

문자열 중에서 HTML과 PHP 태그를 제거한 문자열을 반환합니다.

<파일명 : ex39.php>

<?
$str="strip_tags() 연습입니다.
<b>HTML 태그</b>
<? echo \"php 태그 \"; ?>
";

echo ("strip_tags 사용 전 : $str <br>");
$str=strip_tags($str);
echo ("strip_tags 사용 후 : $str <br>");
?>

☞ strlen 함수

      

구문 : int strlen(string str)
기능 : 문자열의 길이를 구한다.

문자열의 길이를 리턴합니다.

<파일명 : ex40.php>

<?
$str="We are the world";
echo ("$str 의 문자열 길이 = ");
echo strlen($str);
?>

☞ substr 함수

      

구문 : string substr(string string, int start, int [length])
기능 : 문자열의 일부분을 리턴합니다.

start로부터 length 만큼 리턴합니다. length가 생략되면 문자열의 끝까지 리턴합니다. start가 음수일 경우 뒤에서부터 리턴합니다. length가 음수일 경우 뒤에서부터 length까지만 리턴합니다.

<파일명 : ex41.php>

<?
//start가 양수일 경우
$rest=substr("abcdef", 1); 
echo "$rest <br>";
$rest=substr("abcdef", 1, 3);
echo "$rest <br>";

//start가 음수일 경우
$rest=substr("abcdef", -1);
echo "$rest <br>";
$rest=substr("abcdef", -2);
echo "$rest <br>";
$rest=substr("abcdef", -3,1);
echo "$rest <br>";

//length가 음수일 경우
$rest=substr("abcdef", 1, -1);
echo "$rest <br>";
?>

☞ trim 함수

      

구문 : string trim(string str)
기능 : 문자열의 시작과 끝의 공백을 없앤다.

인자로 주어진 문자열의 맨 앞과 맨 끝의 공백을 지우고 리턴합니다.

<파일명 : ex42.php>

<?
$str="\t 앞과 뒤쪽의 탭과 공백이 있는 문자\t  ";
echo "trim 사용 전 : $str <br>\n";
$str=trim($str);
echo "trim 사용 후 : $str <br>";
?>

 

(3) 정규표현형식 관련 함수

☞ ereg 함수

      

구문 : int ereg(string pattern, string string, array [regs])
기능 : 일치하는 문자열을 찾는다.

두 번째 인자(문자열)에서 첫 번째 인자(패턴)를 찾습니다. 패턴에 괄호가 포함되어 있으면 세 번째 인자를 필요로 합니다. 일치된 패턴이 세 번째 인자인 배열로 차곡차곡 들어갑니다.

예를 들어, 첫 번째 괄호와 일치된 문자열은 $regs[1] 안에 들어가고, 두 번째 괄호와 일치된 문자열은 $regs[2]에 들어갑니다. $regs[0]에는 두 번째 인자 전체가 들어가 있습니다.

<파일명 : ex43.php>

<?
//YYYY-MM-DD 형식의 날짜를 DD.MM.YYYY 형식으로 출력하는 예제
$date=date("Y-m-d", time());

if (ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $date, $regs)) {
   echo "$regs[3].$regs[2].$regs[1]";
} else {
   echo "잘못된 데이터 형식입니다.: $date";
}
?>

☞ eregi 함수

      

구문 : int eregi(string pattern, string string, array [regs])
기능 : 대소문자 구분 없이 일치하는 문자열을 찾는다.

ereg()와 똑같습니다. 차이점은 대소문자 구별을 하지 않습니다.
두 번째 인자(문자열)에서 첫 번째 인자(패턴)를 찾습니다. 패턴에 괄호가 포함되어 있으면 세 번째 인자를 필요로 합니다. 일치된 패턴이 세 번째 인자인 배열에 차곡차곡 들어갑니다.
예를 들어, 첫 번째 괄호와 일치된 문자열은 $regs[1] 안에 들어가고, 두 번째 괄호와 일치된 문자열은 $regs[2]에 들어갑니다. $regs[0]에는 두 번째 인자 전체가 들어가 있습니다.

☞ ereg_replace 함수

      

구문 : string ereg_replace(string pattern, string replacement, array string)
기능 : 일치하는 문자열을 찾아 바꾼다.

문자열(string)에서 패턴(pattern)을 찾아 바꿀문자(replacement)로 바꾼 후에 리턴합니다. 일치하는 패턴(pattern)이 없으면 원래의 문자열을 리턴합니다.

패턴(pattern)에는 괄호를 사용할 수 있습니다. 맨 바깥쪽 괄호부터 괄호 전체를 1,2,...로 생각하면 됩니다.

<파일명 : ex44.php>

<?
$string="This is a test";
echo ereg_replace(" is", " was", $string) . "<br>\n";
echo ereg_replace("( )is", "\\1was", $string) . "<br>\n";
echo ereg_replace("(( )is)", "\\2was", $string) . "<br>\n";
?>

☞ eregi_replace 함수

      

구문 : string eregi_replace(string pattern, string replacement, array string)
기능 : 일치하는 문자열을 찾아 바꾼다.

문자열(string)에서 패턴(pattern)을 찾아 바꿀문자(replacement)로 바꾼 후에 리턴합니다. 일치하는 패턴(pattern)이 없으면 원래의 문자열을 리턴합니다.
ereg_replace()함수와 같은 기능입니다. 단지 차이는 대소문자를 무시한다는 것입니다.

☞ split 함수

      

구문 : string split(string pattern, string string, int [limit])
기능 : 정규 표현식을 사용하여 문자열을 나눈 후 배열로 저장한다.

패턴(pattern)으로 준 첫 번째 인자가 구분자가 되어 두 번째 인자의 문자열을 나누어 배열로 리턴합니다. 오류가 발생하면 false를 리턴합니다.

limit는 나누어 저장할 문자열의 개수이며, 생략 가능합니다. 주의할 점은 패턴(pattern)으로 앞에서부터 나누어집니다. limit보다 뒤에 있는 문자열들은 나눠지지 않고 마지막 배열에 들어갑니다.

<파일명 : ex45.php>

<?
$date="04/30/1998";
list($month, $day, $year)=split("[/.-]", $date);
echo "Month: $month; Day: $day; Year: $year";
?>

(4) 배열 관련 함수

☞ array 함수

      

구문 : array array(...)
기능 : 배열을 만든다.

....부분에 매개변수가 들어갑니다.

매개변수는 '=>' 연산자를 이용하여 배열 인덱스에 넣을 수도 있습니다. 즉 array(키 => 값);

<파일명 : ex46.php>

<?
$fruits=array("fruits" => "orange", "numbers" => 1);

echo "fruits value = " . $fruits["fruits"] . "<br>";
echo "fruits numbers = " . $fruits["numbers"] . "<br>";
?>

☞ count 함수

      

구문 : int count(mixed var)
기능 : 변수가 가지고 있는 값들의 수를 리턴한다.

주로 배열변수를 대상으로 합니다. 여기서 그냥 변수라고 한 것은 어느 변수든디 한가지 값은 가지고 있기 때문입니다.

변수가 배열이 아닐 경우 1을 리턴합니다.(배열변수가 아니면 그냥 한가지 값을 가집니다.)

변수가 정의되지 않았을 경우 0을 리턴합니다.

[참고] 변수가 정의되지 않았을 경우 0을 리턴하지만, 배열변수가 공백으로 정의되었을 경우에도 0이 리턴됩니다. 변수가 정의되었는지 확인하려면 isset()함수를 사용합니다.

<파일명 : ex47.php>

<?
$fruits = array("fruits" => "orange", "numbers" => 1);
$array = array("a", "b", "c", "d", "e");

echo "fruits 배열의 개수 = " . count($fruits) . "<br>";
echo "array 배열의 개수 = " . count($array);
?>

☞ each 함수

      

구문 : array each(array array)
기능 : 배열에서 현재 포인터가 가리키고 있는 키 값과 값을 리턴한다.

배열 내부 포인터가 가리키고 잇는 키와 값을 리턴한 후 포인터는 다음 요소를 가르키게 됩니다.

실행하면 4개의 요소를 가진 배열로 리턴을 하는데 0과 key는 키 값을 가지고 있고, 1과 value는 값을 가지고 있습니다.

<파일명 : ex48.php>

<?
$fruits = array("fruits" => "orange", "numbers" => 1);
$result=each($fruits);
echo "key = $result[0], value = $result[1] <br>";
list($key, $value)=each($fruits);
echo "key = $key, value = $value <br>";
?>

☞ list 함수

      

구문 : void list(...)
기능 : 변수들을 배열처럼 쓸 때 사용한다.

array()와 마찬가지로 변수들을 배열처럼 쓸 때 사용합니다.

☞ sizeof 함수

      

구문 : int sizeof(array array)
기능 : 배열의 크기를 구한다.

배열 요소의 개수를 리턴합니다. count()와 같습니다.

<파일명 : ex49.php>

<?
$array=array("shellfish", "wheat", "stock");
$num1=count($array);
echo "count = " . $num1 . "<br>";
$num2=sizeof($array);
echo "sizeof = " . $num2 . "<br>";
?>

☞ sort 함수

      

구문 : void sort(array array)
기능 : 배열을 정렬한다.

배열 값들을 정렬합니다.

<파일명 : ex50.php>

<?
$fruits=array("lemon", "orange", "banana", "apple");
sort($fruits);
for ($i=0, $max=count($fruits); $i<$max; $i++) {
   echo "fruits[$i] = " . $fruits[$i] . "<br>";
}
?>

Posted by 다오나무
영삼이의 IT정보2011. 11. 17. 19:24

- 윈도우즈를 위한 미디어 플레이어

- 간단한 플레이어

http://mpui.sourceforge.net/index.php?page=about

About MPlayer and MPUI

MPlayer is arguably the best media player application of the world. Is is almost strictly monolithic, which means that it mainly consists of a single 7 MB executable that already contains all necessary codecs – for most files, it does not need any external codecs to be installed. If you want to know more about this wonderful program, please visit the MPlayer homepage.

The roots of MPlayer are in the Unix environment, and it shows in the way MPlayer is used: There is no graphical user interface, or at least none worth mentioning. Instead, MPlayer completely relies on a well-crafted command line interface and powerful keyboard shortcuts. While this is perfectly OK for Unix enthusiasts, Mac and Windows users prefer nice and more or less colorful graphical interfaces. There is already a »semi-official« OS X port, but up to now, no such project exists for the Windows platform.

This is where MPUI comes into play. It is a small program for Windows that takes the command-line hassle off you. Instead, you will get a no-frills, straight-to-the-point GUI that resembles the venerable Windows Media Player 6. It does not support every feature of MPlayer – there are just too many of them – but it is a solid »workhorse« media player tool suitable for most, if not all, everyday needs.

Features

MPlayer and MPUI, when teamed up, offer the following features:

  • A media player with a clean and simple interface.
  • Plays hundreds of different video and audio formats, including MPEG-1, -2 and -4 (DivX), H.264, MP3, Ogg Vorbis and AAC. For most media files, no additional codecs are needed. (This is because MPlayer is not one of the uncounted DirectShow players – the codecs are directly integrated into MPlayer.exe.)
  • MPUI and MPlayer together are just about 3.5 MB in size.
  • The most important MPlayer options (aspect ratio, deinterlacing, and postprocessing) can be configured without typing in cryptic command-line options. (But if you want or need some non-standard options, you can still add them by hand.)
  • Support for multiple audio and subtitle tracks on DVDs.
  • Combines MPlayer's cool keyboard navigation with a mouse-controlled seekbar.
  • Plays files, network streams and discs (such as (S)VCD or DVD). Drag&Drop supported.
  • Multilingual user interface.
  • No installation is required to use MPUI/MPlayer. Simply copy the two .exe files into a directory of your choice an run MPUI.
  • Using a special autorun.inf file, self-playing DivX CDs can be made. This adds only 3.5 MB to your CD, and on the computer playing the disc, no codecs need to be installed.
  • Both programs are free, licensed under the GNU General Public License.
Posted by 다오나무
영삼이의 IT정보2011. 10. 25. 01:28

[프로그램 소개]

1. 프로그램명 : XAMPP

2. 홈페이지 : http://www.apachefriends.org/en/xampp.html

3. 다운로드 : http://sourceforge.net/projects/xampp/files/

4. 개요

XAMPP is an easy to install Apache distribution containing MySQL, PHP and Perl.

간단히 설치하고 간단히 제거할 수 있는 아파치 웹서버이다.

*실행 : 압축 풀고 설정하고 서버 시작

*삭제 : 맘에 안들면 서버중지 후 프로그램 폴더 삭제.

*다른 버전 설치 : 압축 풀고 설정하고 서버 시작

결국 (설치 = 압축풀기)로 끝나는 웹서버이다.

윈도우, 리눅스, 맥 OS-X, 솔라리스 등 각종 OS에 맞게 포팅이 되어 있으며,

MySQL, PHP & PEAR, FTP Server 등 개발에 필요한 거의 모든  모듈이 포함되어 있다.

5. 사족

리눅스서버에서 윈도우서버로 마이그레이션하는 작업이 상당히 까다롭다는 것을 실감하게 되었다.

앞의 글에서도 밝혔듯이 큰 에러가 아닌 미묘하게 살짝 다른 부분들 때문에..

링크 :

정리하자면,

가. PHP3~4버전과 PHP5버전의 함수 및 변수처리의 미묘한 차이 (RESISTER_GLOBALS 등..)

나. MySQL의 기본 언어설정(euc_kr과 UTF-8)에 따른 DB이전문제

다. 웹서버의 권한 설정의 차이 (리눅스 APACHE 와 윈도우 IIS7)

라. 리눅스 전용으로 프로그래밍된 웹 프로그램들..

마. 방화벽 설정 - 서버단에서의 방화벽 및 서버내의 방화벽 설정

바. 기타.. 본인의 리눅스 및 윈도우 서버의 적응문제 등

사. 웹브라우저간 크로스브라우징 및 IE6 등 IE간 호환성 체크

6. 용도

- 리눅스용 웹서버 (카페24-리눅스 가상호스팅에서 실제 서비스 중..)

- 윈도우용 개발용 로컬 웹서버

- (윈도우용 서버는 IIS7+PHP+MySQL로 세팅 - 스마일서브에서 실제 서비스 중..)

7. 설정

* 수정문서명 및 위치

가. 윈도우

D:\xampplite\apache\conf\httpd.conf                // 기본 설정

D:\xampplite\apache\conf\extra\httpd-xampp.conf    // PHP관련 설정

D:\xampplite\apache\conf\extra\httpd-vhosts.conf   // 가상 호스트 설정

나. 리눅스

/opt/lampp/etc/httpd.conf

/opt/lampp/etc/extra/httpd-xampp.conf

/opt/lampp/etc/extra/httpd-vhosts.conf

* 설정 변경

[httpd.conf]

1. 서버 위치 설정

# 윈도우 기본설정 - 개발용으로 "xampp Lite"버전을 설치합

ServerRoot "/xampplite/apache"

# 리눅스의 경우

ServerRoot "/opt/lampp"

2. 포트 설정

# 유동IP등의 상황으로 80포트가 막혀 있을 경우 변경 해야함

Listen 80

3. 서버정보 설정

# 에러메세지 등에서 나타날 관리자의 메일주소

ServerAdmin admin@localhost

# 기본 서버이름 - 여러 상황에서 변경해야 할 수도 있음

ServerName localhost:80

4. 가상서버를 운용할 경우 문서(홈페이지)의 루트 설정)

# 기본설정은 윈도우/리눅스 모두 바꾸어야 함.

# 기본설정 DocumentRoot "/xampplite/htdocs"

DocumentRoot "/home"

# 윈도우의 경우 xampp 설치폴더와 홈페이지 루트폴더의 드라이브가 다른경우

DocumentRoot "e:/home"

5. 디렉토리 권한설정

# DocumentRoot을 바꾸었을 경우 필히 아래 디렉토리의 권한설정을 바꾸어야 한다.

# 추가항목

#  "LimitRequestBody 제한크기" 업로드 파일크기제한을 위해 추가

# 크기 예시 : 1MB=1048576 / 10MB=10485760 / 100MB=104857600 / 1GB=1073741824

#             200MB=209715200 / 500MB=524288000 [ 2GB-1=2147483647]

# 계산 공식 : 1024*1024 = 1메가 / 1024*1024*20 = 20메가 / 1024*1024*1024=1기가

# 기본설정 <Directory "/xampplite/htdocs"> 을 <Directory "/home">로 변경

<Directory "/home">

    Options Indexes FollowSymLinks Includes ExecCGI

    AllowOverride All

    Order allow,deny

    Allow from all

    LimitRequestBody 104857600

</Directory>

6. 기본문서명 지정

# domain.com/ 으로 접속할 경우 기본으로 보여지는 문서파일명

# index.php가 없을 경우 index.php4.... 왼쪽에서 오른쪽으로

# 경험상 "index.php"의 확장자가 제일 먼저 오는 것이 개발에 좋다.

<IfModule dir_module>

    DirectoryIndex index.php index.html index.htm index.php4 index.php3 index.cgi index.pl index.shtml index.phtml

</IfModule>

7. 로그파일 작성 조건 설정 (기본설정으로는 로그파일이 엄청나게 커진다.)

LogLevel crit // 치명적인 에러만 기록

8. HTML파일에서 PHP 사용을 위한 설정

[extra/httpd-xampp.conf]

#  .html .htm 추가 // html 파일에서 php 사용

AddType text/html .php .phps .php5 .php4 .php3 .phtml .phpt .html .htm

# |\.html$|\.htm$ // html, htm 추가

<FilesMatch "\.php$|\.php5$|\.php4$|\.php3$|\.phtml$|\.phpt$|\.html$|\.htm$">

  SetHandler application/x-httpd-php

</FilesMatch>

9. Virtual HOST 설정

링크 : [팁][리눅스] 네임서버 없이 IP로만 가상호스팅(Virtualhost) 설정시 주의점

10. PHP 설정은 다음 포스트에..

Posted by 다오나무
영삼이의 IT정보2011. 10. 21. 12:41
제일먼저 JDK를 설치하고 그다음 이클립스PDT 그리고 XAMPP순으로 설치하겠습니다.

나중에 설치할 이클립스PDT가 32비트용 바이너리파일만 제공하므로 윈도우용 JDK역시 32비트용으로 설치합니다
윈도우7 64비트라 하여도 JDK32비트 설치시 문제없이 사용가능합니다.

JDK다운로드 URL은 다음과 같습니다.
http://www.oracle.com/technetwork/java/javase/downloads/index.html
설치방법은 간단하니 생략

이제 이클립스PDT를 받습니다.
경로는 아래와 같습니다.
http://www.eclipse.org/pdt/downloads/

윈도우 플랫폼은 32bit만 제공합니다. 윈도우7 64비트라고 하여도 이전에 JDK32비트를 설치하였다면
32bit플랫폼인 이클립스PDT를 사용가능합니다. 다운받고 설치합니다(압축풀고 원하는경로에 배치, 필요에따라 단축아이콘생성)

다음은 XAMPP 입니다.
xampp 다운로드 url은 다음과 같습니다.
http://www.apachefriends.org/en/index.html

여기서 원하시는 플랫폼을 받으면 되겠습니다.

설치방법은 간단. installer를 다운받아서 실행하면 끝입니다.
XAMPP installer 1.6.x 버전에서는 디폴트 디렉토리가 C:\Program Files\xampp 였고 지금 버전인 1.7.x에서는 디폴트가 c:\xampp 입니다.

설치완료후 xampp 의 콘트롤 패널이 뜰텐데(안뜨면실행) 보안설정을 해주어야 합니다.


스타트 되어진상태에서 admin을 클릭하면 xampp 윈도우창이 뜰겁니다. 거기서
sercurity메뉴를 클릭합니다.


아래의 url을 클릭

그러면 mysql과 xampp 디렉토리의 비밀번호를 입력하는 창이나올텐데
자신이 사용하려는 비밀번호를 입력후 확인

mysql을 cmd 에서 콘솔로 이용하고싶다면 패스설정을 해주면된다.
환경변수 -> path - >other path..;C:\xampp\mysql\bin;

httpd 명령어를 cmd에서 바로 먹이기위해 패스설정
환경변수 -> path -> other path...;C:\xampp\apache\bin;



이제 이클립스PDT 를 위한 아파치 웹서버 설정을 해주자
아래는 이클립스를위한 서버설정의 가장쉽지만 가장 불편한 방법인데..
가상서버를 설정하는것은 따로 포스팅했다.

현재 상태로 이클립스에서 웹페이지를 RUN 시키면 URL을 찾을수 없다고 나옵니다
당연한 것이 기본URL을 아파치서버의 디폴트폴더로 잡혀있기 때문입니다.

아파치 웹 서버에 접속하면 웹 서버는 documentroot로 지정된 폴더에서 index로 작성된 웹페이지를 찾습니다
이클립스PDT는 기본적으로 htto://localhost 경로가 workspace로 지정됐다는 것으로 가정하여 동작합니다.

아파치 설치폴더의 conf/httpd.conf 파일을 텍스트 에디터로 엽니다.
documentRoot "아파치 디폴트폴더"

위의 구문을 찾아서
documentRoot "c:/workspace(이클립스에서 지정한 워크스페이스)"
으로 변경해주고

접근권한을 부여하기 위해 다음내용을 추가합니다
<Directory "Workspace 경로">
    Options Indexes FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
</Directory>


그다음은 MYSQL의 한글데이터 입력이 가능하도록 해야합니다
XAMPP는 단독으로 MYSQL을 설치했을 때와는 조금 다르게 설정합니다.


mysql 한글 설정하는 법

my.cnf 수정하기
xampp 가 설치된 디렉토리 네에 mysql/bin 폴더에 my.cnf 파일이 있습니다. 또는 my.ini

my.cnf 파일 수정

#한글설정
[mysqld]
character-set-server = euckr
#character-set-client-handshake = FALSE
skip-character-set-client-handshake
 
이제 이클립스에서 신나게 코딩

Posted by 다오나무