Centos 7 APM 설치 [펌] - 2

- 환경 설정

로그를 “/var/log/httpd” 폴더로 저장하기 위해서 설정하기 전에 폴더를 생성한다.

1
[root@host httpd-2.4.6] mkdir /var/log/httpd

설치시 환경 설정 경로(–sysconfdir)를 “/etc/httpd” 폴더로 설정했기 때문에 “/etc/httpd” 폴더에 설정 파일들이 생성되어 있다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
[root@host httpd-2.4.6] cd /etc/httpd
[root@host httpd] vi httpd.conf
 
# 사용할 모듈의 주석을 제거하여 활성화한다
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule dav_module modules/mod_dav.so
LoadModule vhost_alias_module modules/mod_vhost_alias.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule rewrite_module modules/mod_rewrite.so
...
 
# 그룹 계정 비활성화
<IfModule unixd_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group #-1
</IfModule>
 
# 관리자 이메일
ServerAdmin keypointer@gmail.com
 
# 서버 이름
 
# 루트 디렉토리
DocumentRoot "/usr/local/httpd/htdocs"
<Directory "/usr/local/httpd/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # for more information.
    #
    Options FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   AllowOverride FileInfo AuthConfig Limit
    #
    AllowOverride None
 
    #
    # Controls who can get stuff from this server.
    #
    Require all granted
</Directory>
 
# 폴더로 접근할 때 실행하는 인덱스 파일 설정
#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>
 
# 로그 파일 저장 위치
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "/var/log/httpd/error_log"
<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common
 
    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>
 
    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "/var/log/httpd/access_log" common
 
    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access_log" combined
</IfModule>
 
# 설정 파일 import
# Server-pool management (MPM specific)
Include /etc/httpd/extra/httpd-mpm.conf
# Language settings
Include /etc/httpd/extra/httpd-languages.conf
# Virtual hosts
#Include /etc/httpd/extra/httpd-vhosts.conf
# Distributed authoring and versioning (WebDAV)
Include /etc/httpd/extra/httpd-dav.conf
 
-----------------------------------------------------------------
 
[root@host httpd] vi extra/httpd-mpm.conf
 
#
# PidFile: The file in which the server should record its process
# identification number when it starts.
#
# Note that this is the default PidFile for most MPMs.
#
 
    PidFile "/var/log/httpd/httpd.pid"
 
----------------------------------------------------------------
 
[root@host httpd] vi extra/httpd-languages.conf
 
DefaultLanguage ko
 
# LanguagePriority allows you to give precedence to some languages
# in case of a tie during content negotiation.
#
# Just list the languages in decreasing order of preference. We have
# more or less alphabetized them here. You probably want to change this.
#
LanguagePriority ko en ca cs da de el eo es et fr he hr it ja ltz nl nn no pl pt pt-BR ru sv tr zh-CN zh-TW
- 서비스 등록

apachectl 스크립트는 chkconfig 로 동작할 수 있도록 수정해야 한다.

Symbolic Link 를 만들고 apachectl 스크립트의 상단 부분을 아래와 같이 수정해야만 서비스로 추가가 가능하다.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
[root@host httpd] ln -s /usr/local/httpd/bin/apachectl /etc/rc.d/init.d/httpd
[root@host httpd] vi /usr/local/httpd/bin/apachectl
 
#!/bin/sh
#
# Apache This starts and stops Apache.
#
# chkconfig: 35 20 80
# description: Apache Web Service
#
# Licensed to the Apache Software Foundation
...
 
----------------------------------------------------------------
 
[root@host httpd] service httpd start
- 공유 라이브러리 추가
1
2
[root@host httpd] echo "/usr/local/httpd/module" >> /etc/ld.so.conf
[root@host httpd] ldconfig

 

PHP 설치

- 의존 라이브러리 설치
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
yum install libxml2-devel
yum install bzip2-devel
yum install libcurl-devel
yum install gdbm-devel
yum install libvpx yum install libvpx-devel
yum install libjpeg-turbo-devel
yum install libpng-devel
yum install libXpm libXpm-devel
yum install freetype-devel
yum install t1lib t1lib-devel
yum install gmp-devel
yum install libc-client libc-client-devel
yum install pam-devel
yum install libicu libicu-devel
yum install openldap-devel
yum install readline-devel
yum install libedit-devel
yum install libtidy libtidy-devel
yum install libxslt libxslt-devel
- libmcrypt 설치
1
2
3
4
5
6
[root@host downloads] wget http://sourceforge.net/projects/mcrypt/files/Libmcrypt/2.5.8/libmcrypt-2.5.8.tar.gz/download
[root@host downloads] tar zxvf libmcrypt-2.5.8.tar.gz
[root@host downloads] cd libmcrypt-2.5.8
[root@host libmcrypt-2.5.8] ./configure
[root@host libmcrypt-2.5.8] make; make install
[root@host libmcrypt-2.5.8] ln -s /usr/local/lib/libmcrypt.so.4 /usr/local/lib64/libmcrypt.so.4
- MySQL 라이브러리 참조
1
ln -s /usr/local/mysql/lib /usr/local/mysql/lib64
- 소스를 다운로드 받고 압축 해제
1
2
3
[root@host ~] cd /root/downloads
[root@host downloads] wget http://kr1.php.net/get/php-5.5.4.tar.gz/from/this/mirror
[root@host downloads] tar zxvf php-5.5.4.tar.gz
- 컴파일과 설치
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
[root@host downloads] cd php-5.5.4
[root@host php-5.5.4] ./configure --prefix=/usr/local/php \
--with-apxs2=/usr/local/httpd/bin/apxs --with-config-file-path=/etc/httpd \
--with-mysql=/usr/local/mysql --with-mysql-sock=/var/mysql \
--with-mysqli=/usr/local/mysql/bin/mysql_config \
--with-pdo-mysql=shared,/usr/local/mysql \
--with-regex=php --with-libxml-dir=/usr \
--with-openssl --with-pcre-regex \
--with-zlib --with-bz2 --with-curl \
--with-gdbm --with-db4=/usr --with-dbm \
--with-pcre-dir=/usr --with-openssl-dir=/usr \
--with-libxml-dir=/usr \
--with-gd \
--with-vpx-dir=/usr --with-jpeg-dir=/usr --with-png-dir=/usr \
--with-zlib-dir=/usr --with-xpm-dir=/usr \
--with-freetype-dir=/usr --with-t1lib=/usr \
--with-gettext --with-gmp --with-mhash \
--with-imap --with-imap-ssl \
--with-kerberos \
--with-icu-dir=/usr \
--with-ldap --with-ldap-sasl \
--with-libmbfl --with-onig \
--with-mcrypt \
--with-libedit --with-readline \
--with-tidy \
--with-libexpat-dir=/usr --with-xmlrpc --with-xsl \
--with-pear --with-pic \
--with-libdir=lib64 \
--enable-bcmath --enable-calendar \
--enable-exif --enable-ftp --enable-pcntl \
--enable-gd-native-ttf --enable-gd-jis-conv \
--enable-intl --enable-mbstring \
--enable-shmop --enable-sockets \
--enable-sysvmsg --enable-sysvsem --enable-sysvshm \
--enable-wddx --enable-zip \
--enable-mysqlnd \
--enable-dba=shared --enable-mod-charset \
--enable-dom --enable-mbregex --enable-inline-optimization \
--enable-sigchild --enable-soap \
--enable-maintainer-zts \
--enable-opcache=no
[root@host php-5.5.4] make; make install
- 환경 설정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
[root@host php-5.5.4] cp php.ini-production /etc/httpd/php.ini
[root@host php-5.5.4] vi /etc/httpd/php.ini
 
; PHP's default character set is set to empty.
; http://php.net/default-charset
default_charset = "UTF-8"
 
; Whether to allow HTTP file uploads.
; http://php.net/file-uploads
file_uploads = On
 
; Temporary directory for HTTP uploaded files (will use system default if not
; specified).
; http://php.net/upload-tmp-dir
upload_tmp_dir = /tmp
 
; Maximum allowed size for uploaded files.
; http://php.net/upload-max-filesize
upload_max_filesize = 50M
 
; Maximum number of files that can be uploaded via a single request
max_file_uploads = 20
 
; Defines the default timezone used by the date functions
; http://php.net/date.timezone
date.timezone = "Asia/Seoul"
- Apache 설정
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[root@host php-5.5.4] vi /etc/httpd/httpd.conf
 
# PHP 모듈이 정상적으로 추가되었는지 확인
LoadModule php5_module        modules/libphp5.so
 
<IfModule mime_module>
 
    ... 중략 ...
 
    AddType application/x-httpd-php .php .html
    AddType application/x-httpd-php-source .phps
 
</IfModule>
 
[root@host php-5.5.4] service httpd restart
- PATH 추가
1
2
3
[root@host php-5.5.4] ln -s /usr/local/php/bin/php /bin/php
[root@host php-5.5.4] ln -s /usr/local/php/bin/php-config /usr/local/bin/php-config
[root@host php-5.5.4] ln -s /usr/local/php/bin/phpize /usr/local/bin/phpize

– 테스트

1
root@host php-5.5.4] echo "<?php phpinfo() ?>" > /usr/local/httpd/htdocs/index.html