ABOUT ME

-

Today
-
Yesterday
-
Total
-
  • yum install apache + php
    └ O.S. 2014. 3. 10. 18:27

    최초작성일 : 07.07.04
    내용추가일 : 14.03.10


    1. yum

    yum 의 탄생 배경이 대학에서 여러대의 컴퓨터의 패키지 버젼들을 일괄적으로 관리하기 위해서
    만들어졌다고 알고 있다.
    나역시 대학에서는 이런 버젼들을 어떻게 관리하나 궁금했는데~
    다들 같은 고민들을 하고 있었나 보다.

    [root@willow_linux html]# man yum

          yum is an interactive, automated update program which can be used for maintaining systems using rpm

          command is one of:
           * install package1 [package2] [...]
           * update [package1] [package2] [...]
           * check-update
           * upgrade [package1] [package2] [...]
           * remove | erase package1 [package2] [...]
           * list [...]
           * info [...]
           * provides | whatprovides feature1 [feature2] [...]
    700px        * clean [ packages | headers | metadata | cache | dbcache | all ]
           * makecache
           * groupinstall group1 [group2] [...]
           * groupupdate group1 [group2] [...]
           * grouplist [hidden]
           * groupremove group1 [group2] [...]
           * groupinfo group1 [...]
           * search string1 [string2] [...]
           * shell [filename]
           * resolvedep dep1 [dep2] [...]
           * localinstall rpmfile1 [rpmfile2] [...]
           * localupdate rpmfile1 [rpmfile2] [...]
           * deplist package1 [package2] [...]

    ~ 생략 ~

    URL    http://wiki.kldp.org/wiki.php/Yum-HOWTO

    2. apache

    서버에 apache가 설치되어 있는지 체크한다.
    [willow@willow_linux ~]$ yum list installed | grep httpd
    httpd.i386                               2.2.3-5                installed

    설치되어 있군~
    apache port 가 떠있는지 확인~
    [root@willow_linux ~]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
    ~ 생략 ~
    tcp        0      0 :::22                       :::*                        LISTEN      1953/sshd
    ~ 생략 ~

    apache 가 떠있지 않으므로 아파치를 실행한다.
    [root@willow_linux httpd]# /usr/sbin/apachectl start

    데몬 실행 확인~
    [root@willow_linux html]# netstat -lntp
    Active Internet connections (only servers)
    Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name
    ~ 생략 ~
    tcp        0      0 :::80                       :::*                        LISTEN      26880/httpd

    [root@willow sbin]# apachectl status
      Apache/2.2.3 (CentOS) Server at localhost Port 80

    httpd 의 기본위치는
    /etc/httpd/ 하위 디렉토리들..

    Tip service 로 관리하고자 할때 아래의 경로로 실행 파일을 복사해준다.
    [root@willow_linux html]# cp /usr/sbin/apachectl /etc/rc.d/init.d/
    [root@willow_linux html]# service apachectl restart

    웹브라우져로 해당 아이피를 입력하여 아파치 화면이 잘나오는지 확인한다.


    + 아파치 시작시 오류
    $ apachectl start
    Warning: DocumentRoot [/data/webroot/프로젝트/www] does not exist
    httpd: apr_sockaddr_info_get() failed for dblab_watchin01
    httpd: Could not reliably determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
    httpd (pid 25893) already running



    이런경우

    $ vi /etc/httpd/conf/httpd.conf

    ServerName 127.0.0.1:80


    + 아파치 Version & Vhost 확인

    CentOS 인경우

    $ httpd -v

    Server version: Apache/2.2.3

    Server built:   Oct 16 2013 12:18:29


    $ httpd -S

    VirtualHost configuration:

    wildcard NameVirtualHosts and _default_ servers:

    *:8080                 is a NameVirtualHost

             default server soap.xxx.co.kr (/etc/httpd/vhosts.d/H99_soap.xxx.co.kr.conf:4)

             port 8080 namevhost soap.xxx.co.kr (/etc/httpd/vhosts.d/H99_soap.xxx.co.kr.conf:4)

    *:80                   is a NameVirtualHost

             default server xxx.co.kr (/etc/httpd/vhosts.d/H01_xxx.co.kr.conf:4)

             port 80 namevhost xxx.co.kr (/etc/httpd/vhosts.d/H01_xxx.co.kr.conf:4)

    *:443                  is a NameVirtualHost

             default server xxx.co.kr (/etc/httpd/vhosts.d/H01_xxx.co.kr_ssl.conf:12)

             port 443 namevhost xxx.co.kr (/etc/httpd/vhosts.d/H01_xxx.co.kr_ssl.conf:12)

             port 443 namevhost web.xxx.co.kr (/etc/httpd/vhosts.d/H02_web.xxx.co.kr_ssl.conf:12)

    Syntax OK


    Debian 인 경우

    ]# apache2 -v

    Server version: Apache/2.2.16 (Debian)

    Server built:   Mar  3 2013 12:09:44


    ]# apache2ctl -S

    VirtualHost configuration:

    wildcard NameVirtualHosts and _default_ servers:

    *:80                   is a NameVirtualHost

             default server 127.0.0.1 (/etc/apache2/sites-enabled/000-default:1)

             port 80 namevhost 127.0.0.1 (/etc/apache2/sites-enabled/000-default:1)

             port 80 namevhost xxx.co.kr (/etc/apache2/sites-enabled/xxx.co.kr:1)

             port 80 namevhost watchdog-xxx.co.kr (/etc/apache2/sites-enabled/watchdog-xxx.co.kr:1)

    Syntax OK

    아파치 로그 샘플(rotatelogs vs cronolog)

     ErrorLog "|/usr/sbin/rotatelogs -l /var/log/httpd/willow.pe.kr-error_log_%Y%m%d%H 86400"
     CustomLog "|/usr/sbin/rotatelogs -l /var/log/httpd/willow.pe.kr-access_log_%Y%m%d%H 86400" combined

     ErrorLog "|/usr/sbin/cronolog --symlink=/data/wwwlog/willow.pe.kr_error_log /data/wwwlog/%Y/willow.pe.kr_error_%Y%m%d.log"
     CustomLog "|/usr/sbin/cronolog --symlink=/data/wwwlog/willow.pe.kr_access_log /data/wwwlog/%Y/willow.pe.kr_access_%Y%m%d.log" combined





    3. php

    [root@willow_linux httpd]# which php
    /usr/bin/which: no php in (/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin)

    yum 으로 설치여부를 확인한다.
    [willow@willow_linux ~]$ yum list installed | grep php

    없다면 설치 시작~

    우선 php 관련 목록들이 뭐가 있는 확인해본다.
    [root@willow_linux httpd]# yum list | grep php
    php.i386                                 5.1.6-3.6.fc6          updates
    php-Smarty.noarch                        2.6.18-1.fc6           extras
    php-adodb.noarch                         4.94-1.fc6             extras
    php-bcmath.i386                          5.1.6-3.6.fc6          updates
    php-cli.i386                             5.1.6-3.6.fc6          updates
    php-common.i386                          5.1.6-3.6.fc6          updates
    php-dba.i386                             5.1.6-3.6.fc6          updates
    php-dbase.i386                           5.1.6-4.fc6            extras
    ~ 생략 ~

    php 관련 설치할 패키지가 많다.
    설치할 목록을 정한다.

    우선 기본적인 php만 설치해보자

    [root@willow_linux httpd]# yum install php
    Loading "installonlyn" plugin
    Setting up Install Process
    Setting up repositories
    Reading repository metadata in from local files
    Parsing package install arguments
    Resolving Dependencies
    --> Populating transaction set with selected packages. Please wait.
    ---> Downloading header for php to pack into transaction set.
    php-5.1.6-3.6.fc6.i386.rp 100% |=========================|  18 kB    00:00
    ---> Package php.i386 0:5.1.6-3.6.fc6 set to be updated
    --> Running transaction check
    --> Processing Dependency: php-common = 5.1.6-3.6.fc6 for package: php
    --> Processing Dependency: libgmp.so.3 for package: php
    --> Processing Dependency: php-cli = 5.1.6-3.6.fc6 for package: php
    --> Restarting Dependency Resolution with new changes.
    --> Populating transaction set with selected packages. Please wait.
    ---> Downloading header for php-common to pack into transaction set.
    php-common-5.1.6-3.6.fc6. 100% |=========================|  20 kB    00:00
    ---> Package php-common.i386 0:5.1.6-3.6.fc6 set to be updated
    ---> Downloading header for gmp to pack into transaction set.
    gmp-4.1.4-9.fc6.i386.rpm  100% |=========================|  10 kB    00:00
    ---> Package gmp.i386 0:4.1.4-9.fc6 set to be updated
    ---> Downloading header for php-cli to pack into transaction set.
    php-cli-5.1.6-3.6.fc6.i38 100% |=========================|  18 kB    00:00
    ---> Package php-cli.i386 0:5.1.6-3.6.fc6 set to be updated
    --> Running transaction check

    Dependencies Resolved

    =============================================================================
    Package                 Arch       Version          Repository        Size
    =============================================================================
    Installing:
    php                     i386       5.1.6-3.6.fc6    updates           1.2 M
    Installing for dependencies:
    gmp                     i386       4.1.4-9.fc6      updates           634 k
    php-cli                 i386       5.1.6-3.6.fc6    updates           2.3 M
    php-common              i386       5.1.6-3.6.fc6    updates           140 k

    Transaction Summary
    =============================================================================
    Install      4 Package(s)
    Update       0 Package(s)
    Remove       0 Package(s)

    Total download size: 4.2 M
    Is this ok [y/N]: y
    Downloading Packages:
    (1/4): php-common-5.1.6-3 100% |=========================| 140 kB    00:01
    (2/4): gmp-4.1.4-9.fc6.i3 100% |=========================| 634 kB    00:01
    (3/4): php-5.1.6-3.6.fc6. 100% |=========================| 1.2 MB    00:02
    (4/4): php-cli-5.1.6-3.6. 100% |=========================| 2.3 MB    00:02
    Running Transaction Test
    Finished Transaction Test
    Transaction Test Succeeded
    Running Transaction
      Installing: gmp                          ######################### [1/4]
      Installing: php-common                   ######################### [2/4]
      Installing: php-cli                      ######################### [3/4]
      Installing: php                          ######################### [4/4]

    Installed: php.i386 0:5.1.6-3.6.fc6
    Dependency Installed: gmp.i386 0:4.1.4-9.fc6 php-cli.i386 0:5.1.6-3.6.fc6 php-common.i386 0:5.1.6-3.6.fc6
    Complete!

    yum 은 참 친절하다!!

    그외 필요한것들도 설치해본다.
    [root@willow_linux httpd]# yum -y install php-devel php-gd php-mbstring php-pear php-pecl-mailparse php-mysql mod_ssl

    설치가 잘 되었는지 확인한다.
    [root@willow_linux html]# which php
    /usr/bin/php

    [root@willow_linux html]# php -v
    PHP 5.1.6 (cli) (built: May  9 2007 11:47:50)
    Copyright (c) 1997-2006 The PHP Group
    Zend Engine v2.1.0, Copyright (c) 1998-2006 Zend Technologies

    아파치의 php 설정에 아래줄을 추가해준다.
    apache 2.2.x 대는 php.conf 설정을 수정하지 않아도 된다.
    [root@willow_linux httpd]# vi /etc/httpd/conf.d/php.conf

    AddHandler php5-script .php
    AddType text/html .php
    AddType application/x-httpd-php .php .html .htm .inc <- 추가하기

    아파치 설정에 아래줄을 추가한다.
    shell] vi /etc/httpd/conf/httpd.conf

    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz
    # add by willow 2009-08-11
    AddType application/x-httpd-php .php .php4 .php5 .html .htm .inc
    AddType application/x-httpd-php-source .phps


    그런다음~ 아파치 리스타트~
    [root@willow_linux httpd]# /usr/sbin/apachectl restart

    웹페이지를 띄워서 phpinfo() 를 출력해보자

    잘 출력되면 성공~


    php 5.3 이후로는 타임존 설정이 필요하다.

    PHP Warning:  strtotime(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected 'Asia/Seoul' for 'KST/9.0/no DST' instead in /data/webroot/xx.willow.pe.kr/model/index.php on line 25


    $ vi /etc/php.ini

    [Date]

    ; Defines the default timezone used by the date functions

    ; http://www.php.net/manual/en/datetime.configuration.php#ini.date.timezone

    ;date.timezone =

    date.timezone = Asia/Seoul

    + 상황이 여의치 않으면

    date_default_timezone_set('Asia/Seoul');



    Mysql 소켓파일 위치가 디폴트 경로가 아닐때

    PHP Warning:  mysql_connect(): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in /home/ymh/db/simple_connect_test.php on line 12


    $ vi /etc/php.ini

    ; Default socket name for local MySQL connects.  If empty, uses the built-in

    ; MySQL defaults.

    ; http://www.php.net/manual/en/mysql.configuration.php#ini.mysql.default-socket

    mysql.default_socket = /tmp/mysqld.sock

    + 상황이 여의치 않으면

    ini_set("mysql.default_socket", "/tmp/mysqld.sock");



    3. Zend Optimizer 

    중요 라이브러리를 zend 해서 사용하고있다.

    php 5.1.x ~ php 5.4.x 버젼까지 다양하게 다 사용해서;;;

    php 버젼별로 설치할 파일도 다르고.. zend할때도 어플리케이션 체크해서 zend 해야 해서..번거롭다..


    먼저, php 버젼 OS bit 를 체크해서 파일 다운로드한다.

    ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz


    압축을 푼후

    tar -zxvf ZendGuardLoader-php-5.3-linux-glibc23-x86_64.tar.gz


    phpinfo 위치를 확인해서

    $ php -info | grep extension_dir

    extension_dir => /usr/lib64/php/modules => /usr/lib64/php/modules


    모듈을 이동한다.

    mv ./ZendGuardLoader-php-5.3-linux-glibc23-x86_64/php-5.3.x/ZendGuardLoader.so /usr/lib64/php/modules


    Zend 옵션을 추가해준다.

    $ vi /etc/php.ini

    zend_extension=/usr/lib64/php/modules/ZendGuardLoader.so

    zend_loader.enable=1


    아파치 리스타트~! 확인~!

    $ php -v

    PHP 5.3.3 (cli) (built: Dec 11 2013 03:29:57) 

    Copyright (c) 1997-2010 The PHP Group

    Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

        with Zend Guard Loader v3.3, Copyright (c) 1998-2010, by Zend Technologies


    댓글

Designed by Tistory.