Apache + php + mysql 설치

  • 본 문서에서는 APM(APACHE,PHP,MYSQL) 소스 컴파일 설치 하는 방법에 대해서 다룬다.

MySQL 설치

https://www.google.com/search?q=mysql+%EC%BB%B4%ED%8C%8C%EC%9D%BC+%EC%84%A4%EC%B9%98&oq=mysql+%EC%BB%B4%ED%8C%8C%EC%9D%BC+%EC%84%A4%EC%B9%98&aqs=chrome..69i57j0l5.7186j0j7&sourceid=chrome&ie=UTF-8 참고

APACHE 설치

  • 소스코드 다운로드

http://httpd.apache.org/download.cgi

  • 다운받은 소스의 압축 해제 후 소스코드 수정

server/mpm/prefork/prefork.c

#define DEFAULT_SERVER_LIMIT 2048 <--- 이 부분 수정
  • 컴파일

# ./configure
--prefix=/usr/local/apache-2.2.22
--enable-so
--enable-mods-shared=all
--enable-ssl
--with-ssl
--enable-rule=SHARED_CORE && make -j 4 && make install
  • rpaf_module 올리기(옵션)

웹서버 앞단에 proxy 서버나 기타 reverse proxy서버를 둘 경우 웹서버에는 실제 클라이언트 IP가 남지 않고 proxy 서버의 IP가 남게 되는데 X-Forwarded-For HTTP 헤더에 있는 클라이언트 IP정보를 웹서버에서 사용 할 수 있게 해 주는 모듈.

# /usr/local/apache/bin/apxs -i -c -n mod_rpaf-2.0.so mod_rpaf-2.0.c
LoadModule rpaf_module modules/mod_rpaf-2.0.so # /usr/local/apache/conf/httpd.conf 에 추가
  • dosevasive20_module 올리기(옵션)

apache용 DOS공격 방어 모듈

# /usr/local/apache/bin/apxs -cia mod_dosevasive20.c
LoadModule dosevasive20_module modules/mod_dosevasive20.so # /usr/local/apache/conf/httpd.conf 에 추가
  • cronolog 설치(옵션)

apache로그를 날짜 별로 나누어 주는 프로그램

# ./configure –prefix=/usr/local/cronolog && make && make install
  • apache 시작 스크립트 등록

아래 내용으로 /etc/rc.d/init.d/httpd 파일 생성

#!/bin/sh
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.
#              It is used to serve HTML files and CGI.
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
#
# Apache control script designed to allow an easy command line interface
# to controlling Apache.  Written by Marc Slemko, 1997/08/23
#
# The exit codes returned are:
#   XXX this doc is no longer correct now that the interesting
#   XXX functions are handled by httpd
#   0 - operation completed successfully
#   1 -
#   2 - usage error
#   3 - httpd could not be started
#   4 - httpd could not be stopped
#   5 - httpd could not be started during a restart
#   6 - httpd could not be restarted during a restart
#   7 - httpd could not be restarted during a graceful restart
#   8 - configuration syntax error
#
# When multiple arguments are given, only the error from the _last_
# one is reported.  Run "apachectl help" for usage info
#
ARGV="$@"
#
# |||||||||||||||||||| START CONFIGURATION SECTION  ||||||||||||||||||||
# --------------------                              --------------------
#
# the path to your httpd binary, including options if necessary
HTTPD='/usr/local/apache-2.2.22/bin/httpd'
#
# pick up any necessary environment variables
if test -f /usr/local/apache-2.2.22/bin/envvars; then
  . /usr/local/apache-2.2.22/bin/envvars
fi
#
# a command that outputs a formatted text version of the HTML at the
# url given on the command line.  Designed for lynx, however other
# programs may work.
LYNX="lynx -dump"
#
# the URL to your server's mod_status status page.  If you do not
# have one, then status and fullstatus will not work.
STATUSURL="http://localhost:80/server-status"
#
# Set this variable to a command that increases the maximum
# number of file descriptors allowed per child process. This is
# critical for configurations that use many file descriptors,
# such as mass vhosting, or a multithreaded server.
ULIMIT_MAX_FILES="ulimit -S -n `ulimit -H -n`"
# --------------------                              --------------------
# ||||||||||||||||||||   END CONFIGURATION SECTION  ||||||||||||||||||||
# Set the maximum number of file descriptors allowed per child process.
if [ "x$ULIMIT_MAX_FILES" != "x" ] ; then
    $ULIMIT_MAX_FILES
fi
ERROR=0
if [ "x$ARGV" = "x" ] ; then
    ARGV="-h"
fi
case $ARGV in
start|stop|restart|graceful|graceful-stop)
    $HTTPD -k $ARGV
    ERROR=$?
    ;;
startssl|sslstart|start-SSL)
    echo The startssl option is no longer supported.
    echo Please edit httpd.conf to include the SSL configuration settings
    echo and then use "apachectl start".
    ERROR=2
    ;;
configtest)
    $HTTPD -t
    ERROR=$?
    ;;
status)
    $LYNX $STATUSURL | awk ' /process$/ { print; exit } { print } '
    ;;
fullstatus)
    $LYNX $STATUSURL
    ;;
-)
    $HTTPD $ARGV
    ERROR=$?
esac
exit $ERROR
# chmod 755 /etc/rc.d/init.d/httpd
# chkconfig --add httpd
# chkconfig httpd on

PHP 설치

  • 사전 설치 패키지

# yum -y install libxml- curl-devel libjpeg-devel libpng-devel freetype-devel gd-devel libmcrypt-devel bison re2c
  • compile

# ./configure
--prefix=/usr/local/php
--with-apxs2=/usr/local/apache/bin/apxs
--with-mysql=/usr/local/mysql
--with-gd
--enable-safe-mode
--enable-magic-quotes
--enable-ftp
--enable-sockets
--enable-sysvshm
--with-zlib
--with-jpeg-dir
--disable-debug
--with-curl
--with-freetype-dir
--enable-mbstring
--enable-exif
--with-iconv
--with-openssl
--enable-soap
--with-mcrypt && make && make install
  • 컴파일이 끝난 후 php환경 설정 파일을 복사

cp /usr/local/src/php-5.5.5/php.ini-production /usr/local/php/lib/php.ini
  • 환경 설정

httpd.conf 에 아래 내용 추가

AddType application/x-httpd-php .php .htm .html
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.html # 이 부분은 찾아서 수정
  • 확인

/usr/local/httpd/htdocs/info.php 라는 파일 생성 후 파일 내용에 아래와 같은 코드를 저장한 후
웹 브라우져에서 “http://server-ip/info.php” 를 호출 php information 이 출력되면 성공적으로 설치 된 것이다.

코드 내용:

[php]
<?php
phpinfo();
?>
[/php]

답글 남기기

이메일 주소는 공개되지 않습니다. 필수 필드는 *로 표시됩니다