WEB Server - NGINX PHP 5.3 설치하기 - CentOS 7






    이번 포스팅에서는 PHP 5.2 버전 관리에 필요한 컴파일 설치에 대해서 알아보도록 하겠습니다













     PHP 5.3 PHP-FPM 라이브러리 설치




    1. 심볼릭 링크 설정


    [root@php php]# ln -s /usr/lib64/libjpeg.so /usr/lib/
    [root@php php]# ln -s /usr/lib64/libpng.so /usr/lib/
    




    2. libmcrypt-2.5.8 설치



    libmcrypt-2.5.8.tar.gz



    1) libmcrypt-2.5.8.tar.gz 압축해제


    [root@nginx ~]# tar zxf libmcrypt-2.5.8.tar.gz
    



    2) libmcrypt-2.5.8 소스 트리 구성


    [root@nginx ~]# ./configure --prefix=/usr/local/
    



    3) libmcrypt-2.5.8 설치 시작


    [root@nginx ~]# make && make install
    





     PHP 5.3 PHP-FPM 설치



    PHP 5.3 버전 부터는 PHP-FPM을 지원하므로 따로 패치를 진행하지 않으셔도 됩니다.




    1. PHP 5.3 압축해제 및 이동


    [root@php ~]# tar zxf php-5.3.27.tar.gz
    [root@php ~]# cd php-5.3.27
    




    2. PHP 5.3 소스트리


    [root@php php-5.3.27]# ./configure --prefix=/usr/local/php53 \
    --with-mysql=/usr/local/mariadb \
    --with-mysqli=/usr/local/mariadb/bin/mysql_config \
    --with-curl \
    --disable-debug \
    --enable-safe-mode \
    --enable-sockets \
    --enable-sysvsem=yes \
    --enable-sysvshm=yes \
    --enable-ftp \
    --enable-magic-quotes \
    --with-ttf \
    --enable-gd-native-ttf \
    --enable-inline-optimization \
    --enable-bcmath \
    --with-zlib \
    --with-gd \
    --with-gettext \
    --with-jpeg-dir=/usr \
    --with-png-dir=/usr/lib \
    --with-freetype-dir=/usr \
    --with-libxml-dir=/usr \
    --enable-exif \
    --enable-sigchild \
    --enable-mbstring \
    --enable-fastcgi \
    --enable-fpm \
    --enable-zip \
    --with-openssl \
    --enable-soap 
    




    3. PHP 5.3 컴파일 설치


    [root@php php-5.3.27]# make && make install
    




    4. php 설정파일 복사


    [root@php php-5.3.27]# cp -a php.ini-development /usr/local/php53/lib/php.ini
    [root@php php-5.3.27]# cp -arp /usr/local/php53/etc/php-fpm.conf.default /usr/local/php53/etc/php-fpm.conf
    




    5. PHP 5.3 구동파일 복사 및 권한설정


    [root@php php-5.3.27]# cp -arp /usr/local/php53/sbin/php-fpm /etc/init.d/php-fpm53
    [root@php php-5.3.27]# chmod 700 /etc/init.d/php-fpm53
    



    6. PHP-FPM 구동 스크립트 생성


    php-fpm53.txt




    vi /etc/init.d/php-fpm53


    #! /bin/sh

    ### BEGIN INIT INFO

    # Provides:          php-5.3.27-fpm

    # Required-Start:    $all

    # Required-Stop:     $all

    # Default-Start:     2 3 4 5

    # Default-Stop:      0 1 6

    # Short-Description: starts php-5.3.27-fpm

    # Description:       starts the PHP FastCGI Process Manager daemon

    ### END INIT INFO

    php_fpm_BIN=/usr/local/php53/sbin/php-fpm

    php_fpm_CONF=/usr/local/php53/etc/php-fpm.conf

    php_fpm_PID=/usr/local/php53/var/run/php-fpm.pid

    php_opts="--fpm-config $php_fpm_CONF"


    wait_for_pid () {

            try=0

            while test $try -lt 35 ; do

                    case "$1" in

                            'created')

                            if [ -f "$2" ] ; then

                                    try=''

                                    break

                            fi

                            ;;

                            'removed')

                            if [ ! -f "$2" ] ; then

                                    try=''

                                    break

                            fi

                            ;;

                    esac

                    echo -n .

                    try=`expr $try + 1`

                    sleep 1

            done

    }

    case "$1" in

            start)

                    echo -n "Starting php-fpm "

                    $php_fpm_BIN $php_opts

                    if [ "$?" != 0 ] ; then

                            echo " failed"

                            exit 1

                    fi

                    wait_for_pid created $php_fpm_PID

                    if [ -n "$try" ] ; then

                            echo " failed"

                            exit 1

                    else

                            echo " done"

                    fi

            ;;

            stop)

                    echo -n "Gracefully shutting down php-fpm "

                    if [ ! -r $php_fpm_PID ] ; then

                            echo "warning, no pid file found - php-fpm is not running ?"

                            exit 1

                    fi

                    kill -QUIT `cat $php_fpm_PID`

                    wait_for_pid removed $php_fpm_PID

                    if [ -n "$try" ] ; then

                            echo " failed. Use force-exit"

                            exit 1

                    else

                            echo " done"

                           echo " done"

                    fi

            ;;

            force-quit)

                    echo -n "Terminating php-fpm "

                    if [ ! -r $php_fpm_PID ] ; then

                            echo "warning, no pid file found - php-fpm is not running ?"

                            exit 1

                    fi

                    kill -TERM `cat $php_fpm_PID`

                    wait_for_pid removed $php_fpm_PID

                    if [ -n "$try" ] ; then

                            echo " failed"

                            exit 1

                    else

                            echo " done"

                    fi

            ;;

            restart)

                    $0 stop

                    $0 start

            ;;

            reload)

                    echo -n "Reload service php-fpm "

                    if [ ! -r $php_fpm_PID ] ; then

                            echo "warning, no pid file found - php-fpm is not running ?"

                            exit 1

                    fi

                    kill -USR2 `cat $php_fpm_PID`

                    echo " done"

            ;;

            *)

                    echo "Usage: $0 {start|stop|force-quit|restart|reload}"

                    exit 1

            ;;

    esac





    7. PHP-FPM 실행


    [root@php php-5.3.27]# /etc/init.d/php-fpm start
    


    Posted by 서버이야기