본문으로 바로가기

[CentOS] APM 설치 - yum

category 리눅스/CentOS 2013. 7. 1. 19:49

설치 환경 : CentOS 6.4 Minimal
설치 방법 : yum을 이용한 설치
설치 버전 : Apache - 2.2.15-28, PHP - 5.3.3-22(+ APC), MySQL - 5.1.69-1, phpmyadmin - 2.11.11.3-2
사용 포트 : Apache 80, MySQL 3306

MySQL 설치

yum install mysql mysql-server mysql-connector-odbc

  Dependencies Resolved 

  ================================================================================
   Package                   Arch       Version                 Repository   Size
  ================================================================================

  Installing:
   mysql                     x86_64     5.1.69-1.el6_4          updates     907 k
   mysql-server              x86_64     5.1.69-1.el6_4          updates     8.7 M


  Installing for dependencies:
   perl                      x86_64     4:5.10.1-131.el6_4      updates      10 M
   perl-DBD-MySQL            x86_64     4.013-3.el6             base        134 k
   perl-DBI                  x86_64     1.609-4.el6             base        705 k
   perl-Module-Pluggable     x86_64     1:3.90-131.el6_4        updates      39 k
   perl-Pod-Escapes          x86_64     1:1.04-131.el6_4        updates      31 k
   perl-Pod-Simple           x86_64     1:3.13-131.el6_4        updates     211 k
   perl-libs                 x86_64     4:5.10.1-131.el6_4      updates     577 k
   perl-version              x86_64     3:0.77-131.el6_4        updates      50 k


  Transaction Summary
  ================================================================================
  Install      10 Package(s)

  Total download size: 21 M
  Installed size: 65 M

MySQL 서비스 등록

chkconfig mysqld on

MySQL 서비스 시작

service mysqld start

  MySQL 데이타베이스 초기화 중:  Installing MySQL system tables...
  OK
  Filling help tables...
  OK

  To start mysqld at boot time you have to copy
  support-files/mysql.server to the right place for your system

  PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
  To do so, start the server, then issue the following commands:

  /usr/bin/mysqladmin -u root password 'new-password'
  /usr/bin/mysqladmin -u root -h uzuro.com password 'new-password'

  Alternatively you can run:
  /usr/bin/mysql_secure_installation

  which will also give you the option of removing the test
  databases and anonymous user created by default.  This is
  strongly recommended for production servers.

  See the manual for more instructions.

  You can start the MySQL daemon with:
  cd /usr ; /usr/bin/mysqld_safe &

  You can test the MySQL daemon with mysql-test-run.pl
  cd /usr/mysql-test ; perl mysql-test-run.pl

  Please report any problems with the /usr/bin/mysqlbug script!

                                                             [  OK  ]
  mysqld (을)를 시작 중:                                     [  OK  ]

mysql_secure_installation

mysql에서 제공하는 보안관리 인스톨가이드 같은 것인데 수동으로 작업해야되는 것들을 손쉽게 설정할 수 있도록 도와준다.

mysql_secure_installation

  NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

  In order to log into MySQL to secure it, we'll need the current
  password for the root user.  If you've just installed MySQL, and
  you haven't set the root password yet, the password will be blank,
  so you should just press enter here.

 
  # ENTER를 누름 
  Enter current password for root (enter for none):     

  OK, successfully used password, moving on...

  Setting the root password ensures that nobody can log into the MySQL
  root user without the proper authorisation.

  # root 패스워드를 설정하겠는가? (y입력)
  Set root password? [Y/n] 

  # 새로운 패스워드 입력
  New password:   

  # 새로운 패스워드 재입력
  Re-enter new password:    
  Password updated successfully!
  Reloading privilege tables..
   ... Success!


  By default, a MySQL installation has an anonymous user, allowing anyone
  to log into MySQL without having to have a user account created for
  them.  This is intended only for testing, and to make the installation
  go a bit smoother.  You should remove them before moving into a
  production environment.


  # 테스트용도의 anonymous 유저 삭제(y 입력)
  Remove anonymous users? [Y/n] 
   ... Success!


  Normally, root should only be allowed to connect from 'localhost'.  This
  ensures that someone cannot guess at the root password from the network.

  #  root 유저의 원격접속 불허(y입력)
  Disallow root login remotely? [Y/n] 
   ... Success!

  By default, MySQL comes with a database named 'test' that anyone can
  access.  This is also intended only for testing, and should be removed
  before moving into a production environment.

  # 누구나 접속할수 있는 test DB삭제(y입력)
  Remove test database and access to it? [Y/n] 
   - Dropping test database...
   ... Success!
   - Removing privileges on test database...
   ... Success!

  Reloading the privilege tables will ensure that all changes made so far
  will take effect immediately.

  # 변경내용을 적용(y입력)
  Reload privilege tables now? [Y/n] 
   ... Success!

  Cleaning up...


  All done!  If you've completed all of the above steps, your MySQL
  installation should now be secure.

  Thanks for using MySQL!  

Apache 설치

yum -y install httpd mod_ssl

  Dependencies Resolved
  ===================================================================================================================================================================================
   Package                                     Arch                                 Version                                              Repository                             Size
  ===================================================================================================================================================================================

  Installing:
   httpd                                       x86_64                               2.2.15-28.el6.centos                                 updates                               821 k

  Installing for dependencies:
   apr                                         x86_64                               1.3.9-5.el6_2                                        base                                  123 k
   apr-util                                    x86_64                               1.3.9-3.el6_0.1                                      base                                   87 k
   apr-util-ldap                               x86_64                               1.3.9-3.el6_0.1                                      base                                   15 k
   httpd-tools                                 x86_64                               2.2.15-28.el6.centos                                 updates                                73 k
   mailcap                                     noarch                               2.1.31-2.el6                                         base                                   27 k

  Transaction Summary
  ===================================================================================================================================================================================
  Install       6 Package(s)

  Total download size: 1.1 M
  Installed size: 3.6 M

Apache 서비스 등록

chkconfig httpd on

Apache 서비스 시작

service httpd start

  httpd (을)를 시작 중: httpd: Could not reliably determine the server's fully qualified domain name, using uzuro.com for ServerName

                                                           [  OK  ]

서비스를 시작하면 위와 같이 오류가 하나 발생한다. 이것은 Apache의 설정파일인 httpd.conf에 ServerName이 지정되지 않았기 때문이다. httpd.conf에서 ServerName를 변경한다. 실제 인터넷 도메인과 맞출 필요는 없고 형식만 맞춰주면 된다.

vi /etc/httpd/conf/httpd.conf 

  # ServerName gives the name and port that the server uses to identify itself.
  ServerName www.example.com:80
  # ServerName directive.
  #    ServerName dummy-host.example.com

이후 다시 서비스를 재시작하면 경고메세지가 사라진다.

service httpd restart

  httpd 를 정지 중:                                          [  OK  ]
  httpd (을)를 시작 중:                                      [  OK  ]

서비스를 재시작한다.

service httpd restart

브라우저에서 확인

DNS설정이 되어있지 않다면 IP번호를 직접 입력한다.

브라우저 확인

PHP 설치

yum -y install php

  Dependencies Resolved

  ===================================================================================================================================================================================
   Package                                      Arch                                     Version                                        Repository                              Size
  ===================================================================================================================================================================================

  Installing:
   php                                          x86_64                                   5.3.3-22.el6                                   base                                   1.1 M


  Installing for dependencies:
  php-cli                                      x86_64                                   5.3.3-22.el6                                   base                                   2.2 M
  php-common                                   x86_64                                   5.3.3-22.el6                                   base                                   524 k


  Transaction Summary
  ===================================================================================================================================================================================
  Install       3 Package(s)


  Total download size: 3.8 M

  Installed size: 13 M

Apache 재시작

service httpd restart

phpinfo 작성

vi /var/www/html/info.php

  <?php phpinfo(); ?>

브라우저에서 접속해 본다. http://IP주소/info.php

phpinfo

phpinfo에서 Server API를 확인해보면 Apache 2.0 Handler와 연동하여 작동하고 있다. 스크롤을 내려보면 PHP5에서 사용가능한 모든 모듈들이 enabled 되어 있다. 아직 MySQL과 연동할 것들을 설치하지 않았기에 MySQL과 관련된 것들은 표시되지 않는다.

MySQL과 PHP의 연동

PHP와 MySQL을 연동하려면 php-mysql 패키지가 필요하다. 그 밖의 필요한 PHP5 모듈들은 yum search php 와 같은 명령으로 찾아볼 수 있다. 원하는 모듈을 설치하고 Apache를 재시작하면 phpinfo에 반영됨을 확인할 수 있다.

yum install php-mysql php-devel  php-gd php-imap php-ldap php-mbstring php-odbc php-pear php-xml php-xmlrpc

  Dependencies Resolved

  ===================================================================================================================================================================================
   Package                                      Arch                                  Version                                           Repository                              Size
  ===================================================================================================================================================================================

  Installing:

   php-gd                                       x86_64                                5.3.3-22.el6                                      base                                   106 k
   php-imap                                     x86_64                                5.3.3-22.el6                                      base                                    50 k
   php-ldap                                     x86_64                                5.3.3-22.el6                                      base                                    38 k
   php-mysql                                    x86_64                                5.3.3-22.el6                                      base                                    81 k
   php-odbc                                     x86_64                                5.3.3-22.el6                                      base                                    50 k
   php-pear                                     noarch                                1:1.9.4-4.el6                                     base                                   393 k
   php-xml                                      x86_64                                5.3.3-22.el6                                      base                                   103 k
   php-xmlrpc                                   x86_64                                5.3.3-22.el6                                      base                                    52 k


  Installing for dependencies:
   freetype                                     x86_64                                2.3.11-14.el6_3.1                                 updates                                359 k
   libX11                                       x86_64                                1.5.0-4.el6                                       base                                   584 k
   libX11-common                                noarch                                1.5.0-4.el6                                       base                                   192 k
   libXau                                       x86_64                                1.0.6-4.el6                                       base                                    24 k
   libXpm                                       x86_64                                3.5.10-2.el6                                      base                                    51 k
   libc-client                                  x86_64                                2007e-11.el6                                      base                                   515 k
   libjpeg-turbo                                x86_64                                1.2.1-1.el6                                       base                                   174 k
   libpng                                       x86_64                                2:1.2.49-1.el6_2                                  base                                   182 k
   libtool-ltdl                                 x86_64                                2.2.6-15.5.el6                                    base                                    44 k
   libxcb                                       x86_64                                1.8.1-1.el6                                       base                                   110 k
   libxslt                                      x86_64                                1.1.26-2.el6_3.1                                  base                                   452 k
   php-pdo                                      x86_64                                5.3.3-22.el6                                      base                                    75 k
   unixODBC                                     x86_64                                2.2.14-12.el6_3                                   base                                   378 k


  Transaction Summary
  ===================================================================================================================================================================================
  Install      21 Package(s)

  Total download size: 3.9

Apache 재시작

service httpd restart

APC 설치

PHP 는 실행될 때 중간단계인 opcode(opcode 는 어셈블리 명령을 숫자로 바꾼 php 실행용 코드) 로 컴파일되고 이것이 램으로 이동하면서 실행된다. PHP 코드를 opcode로 컴파일하는 시간이 오래걸리는데, 컴파일된 결과를 cache에 저장하고 다시 불러올때 cache 에서 불러오면 컴파일을 다시할 필요가 없어져서 속도가 빨라진다.

여러가지의 php accelerator가 존재하는데 그중에서 php에서 밀고 있는 APC를 설치하도록 한다.

yum -y install php-pecl-apc 

  Dependencies Resolved

  ====================================================================================================================
   Package                        Arch                     Version                       Repository              Size
  ====================================================================================================================

  Installing:

   php-pecl-apc                   x86_64                   3.1.9-2.el6                   base                    96 k


  Transaction Summary
  ====================================================================================================================
  Install       1 Package(s)

  Total download size: 96 k
  Installed size: 318 k

Apache 재시작

service httpd restart

phpMyadmin 설치

MySQL 접속을 웹상에 손쉽게 접속할수 있는 애플리케이션을 설치한다.

http://webdir.tistory.com/117 <-- 링크를 참조하여 RPMforge를 레포지토리로 추가한후 시작한다.

yum -y install phpmyadmin

  Dependencies Resolved
  ====================================================================================================================
   Package                   Arch                  Version                              Repository               Size
  ====================================================================================================================

  Installing:

   phpmyadmin                noarch                2.11.11.3-2.el6.rf                   rpmforge                2.7 M


  Transaction Summary
  ====================================================================================================================
  Install       1 Package(s)

  Total download size: 2.7 M
  Installed size: 13 M

phpmyadmin 설정

기본적으로 phpmyadmin을 설치시에 localhost에서만 접속가능하도록 설정되어 있다. <Directory ...> 설정의 시작부터 끝까지 #으로 주석처리한다.

vi /etc/httpd/conf.d/phpmyadmin.conf

  #  Web application to manage MySQL

  #
  #    Order Deny,Allow
  #    Deny from all
  #    Allow from 127.0.0.1
  #

  Alias /phpmyadmin /usr/share/phpmyadmin
  Alias /phpMyAdmin /usr/share/phpmyadmin
  Alias /mysqladmin /usr/share/phpmyadmin

phpMyAdmin 인증 변경(cookie 를 http 로 변경)

vi /usr/share/phpmyadmin/config.inc.php
/* Authentication type */
$cfg['Servers'][$i]['auth_type'] = 'http';

Apache 재시작

service httpd restart

phpmyadmin 접속

http://IP주소/phpmyadmin/

기타 라이브러리

XE 설치시에 xml-common 이 필요하단다.

php-gd는 설치했지만 그냥 gd는 설치하지 않았는데 꺼림직하다.

php-mcrypt도 자주 사용하는 가본데... 없네..

php-mhash도 없다.

나중에 필요하게 되면 설치해보든가 하도록 하자.

몇몇의 라이브러리 libjpeg, libpng, freetype등등은 APM을 설치하면 의존성 문제로 인해 자동으로 다운로드된다.