LAMP 설치 ( APM 설치) 설치 및 운용 / PHP 7.0 install
APM 설치를 yum을 이용하여 설치 진행도 가능하지만 comfile을 이용하여 설치를 진행한다
사용하는 버전은 다음과 같다
APACHE : 2.2.31
PHP : 7.0
MYSQL : 5.5.46
해당 버전은 현재 wordpress 최신 버전의 요구사항에 안정적인 APM 버전이다
설치 순서는 다음과 같다 1. mysql 2. apache / 3 php 그럼 설치를 진행해보자 / 사용 환경은 다음과 같다
OS: CentOS 6.x / 64bit
MYSQL 설치
1. 먼저 mysql 설치하기 앞서 cmake 를 설치 진행해 준다
1 |
[root@localhost ~]# yum -y install cmake |
2. 사용자 추가
1 2 3 |
[root@localhost ~]# groupadd mysql [root@localhost ~]# useradd -g mysql mysql |
3. mysql 다운로드 및 컴파일 진행
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
[root@localhost ~]# wget mirror.koreaidc.com/mysql/mysql-5.5.46.tar.gz [root@localhost ~]# tar xvfz mysql-5.5.46.tar.gz [root@localhost ~]# cd mysql-5.5.46 [root@localhost mysql-5.5.46]# cmake \ -DCMAKE_INSTALL_PREFIX=/usr/local/mysql \ -DWITH_EXTRA_CHARSETS=all \ -DMYSQL_DATADIR=/free/mysql_data \ -DENABLED_LOCAL_INFILE=1 \ -DWITH_INNOBASE_STORAGE_ENGINE=1 \ -DMYSQL_UNIX_ADDR=/tmp/mysql.sock \ -DSYSCONFDIR=/etc \ -DDEFAULT_CHARSET=utf8 \ -DDEFAULT_COLLATION=utf8_general_ci \ -DWITH_EXTRA_CHARSETS=all [root@localhost mysql-5.5.46]# make -j 17 (서버의 core 16개 스레드를 이용하여 컴파일 진행) [root@localhost mysql-5.5.46]# make install |
4. 권한 설정 및 데이터베이스 insatll ( install 하는 경우 디렉토리를 아래 경로에서 맞게 구성해야 한다
1 2 3 4 5 6 7 |
[root@localhost mysql-5.5.46]# chown -R root:mysql /usr/local/mysql [root@localhost mysql-5.5.46]# cd /usr/local/mysql/ [root@localhost mysql]# ./scripts/mysql_install_db --user=mysql --datadir=/free/mysql_data [root@localhost mysql]# chown -R mysql:mysql /free/mysql_data/ |
5. 시작 스크립트 등록 및 파일 복사 /etc/my.cnf
1 2 3 4 5 6 7 8 9 10 11 |
[root@localhost mysql]# chmod 700 support-files/mysql.server [root@localhost mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysql [root@localhost mysql]# cp support-files/mysql.server /usr/bin/ [root@localhost mysql]# ln -s /etc/rc.d/init.d/mysql /etc/rc.d/rc3.d/S97mysql [root@localhost mysql]# cp -a support-files/my-huge.cnf /etc/my.cnf [root@localhost mysql]# perl -pi -e "s/log-bin/#log-bin/g" /etc/my.cnf |
my.cnf 파일 수정
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
[root@localhost mysql]# vi /etc/my.cnf [client] -> 여기 항목에 아래 내용 추가 default-character-set = utf8 [mysqld] -> 여기 항목에 아래 내용 추가 default-storage-engine = MYISAM skip-innodb long_query_time = 5 log-slow-queries = /free/mysql_data/mysql-slow-queries.log max_connect_errors = 10000 wait_timeout= 60 max_connections= 2048 |
8. mysql 시작 및 mysql 접속 확인
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 |
[root@xinet mysql_data]# mysql.server start [root@localhost mysql]# /usr/local/mysql/bin/mysql Welcome to the MySQL monitor. Commands end with ; or \g. Your MySQL connection id is 1 Server version: 5.5.46 Source distribution Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. mysql> \s -------------- /usr/local/mysql/bin/mysql Ver 14.14 Distrib 5.5.46, for Linux (x86_64) using EditLine wrapper Connection id: 1 Current database: Current user: root@localhost SSL: Not in use Current pager: stdout Using outfile: '' Using delimiter: ; Server version: 5.5.46 Source distribution Protocol version: 10 Connection: Localhost via UNIX socket Server characterset: utf8 Db characterset: utf8 Client characterset: utf8 Conn. characterset: utf8 UNIX socket: /tmp/mysql.sock Uptime: 10 sec |
APACHE 설치 ( httpd-2.2.31)
1. 먼저 mysql 설치하기 앞서 관련 패키지를 설치 진행한다
1 |
[root@localhost ~]# yum install openssl openssl-devel |
2. 다운로드 및 압축해제
1 2 3 4 5 6 7 8 9 |
[root@localhost ~]# wget mirror.koreaidc.com/apache/httpd-2.2.31.tar.gz [root@localhost ~]# tar xvfz httpd-2.2.31.tar.gz [root@localhost ~]# cd httpd-2.2.31 [root@localhost httpd-2.2.31]# vi server/mpm/prefork/prefork.c #define DEFAULT_SERVER_LIMIT 2048 |
3. prefork 방식으로 설치를 진행하며 max_client 를 높이기 위해서 파일을 수정해 준다
#define DEFAULT_SERVER_LIMIT 256 -> 2048
1 2 3 |
[root@localhost httpd-2.2.31]# vi server/mpm/prefork/prefork.c #define DEFAULT_SERVER_LIMIT 2048 |
4. 컴파일 진행 및 설치 완료
1 2 3 4 5 6 7 |
[root@localhost httpd-2.2.31]#./configure --prefix=/usr/local/apache \ --enable-mods-shared=all --enable-module=shared --enable-rewrite --enable-ssl \ --with-ssl --with-mpm=prefork --with-included-apr [root@localhost httpd-2.2.31]# make -j 17 [root@localhost httpd-2.2.31]# make install |
5. 한글로 된 이미지나 문서 파일을 불러들이려면 mod_url을 패치 작업
1 2 3 4 5 6 7 8 9 |
[root@localhost httpd-2.2.31]# cd /root [root@localhost ~]# wget mirror.koreaidc.com/apache/mod_url-apache2.tar.gz [root@localhost ~]# tar xvfz mod_url-apache2.tar.gz [root@localhost ~]# cd mod_url-apache2 [root@localhost mod_url-apache2]# /usr/local/apache/bin/apxs -iac mod_url.c |
6. httpd.conf 파일에 mod_url 내용 추가
1 2 3 4 5 6 7 |
[root@localhost ~]# vi /usr/local/apache/conf/httpd.conf <IfModule mod_url.c> CheckURL On ServerEncoding UTF-8 ServerEncoding EUC-KR </IfModule> |
여기까지 설치를 진행했으면 apache는 설치가 완료 되었다
PHP 설치 ( php-5.4.45)
1. 먼저 PHP 설치하기 앞서 라이브러리를 설치 및 등록해 준다
1 2 3 4 5 |
[root@localhost ~]# yum -y install libtermcap libtermcap-devel gdbm-devel \ zlib* libxml* freetype* libpng* libjpeg* gd gd-dev libmcrypt libmcrypt-devel \ mhash mhash-devel apr apr-* libxml2 iconv unixODBC readline-devel \ qpixman qpixman-devel netpbm* libxslt* gmp gmp-devel \ bzip2-devel openssl-devel pcre-devel curl curl-devel |
2. mhash , libmcrypt 는 yum 에서 설치가 진행되지 않으니 rpm 파일 받아서 설치 진행
1 2 3 4 5 6 7 8 9 10 11 |
[root@localhost ~]# wget mirror.koreaidc.com/rpm/mhash-0.9.9.9-3.el6.x86_64.rpm [root@localhost ~]# wget mirror.koreaidc.com/rpm/mhash-devel-0.9.9.9-3.el6.x86_64.rpm [root@localhost ~]# wget mirror.koreaidc.com/rpm/libmcrypt-2.5.8-9.el6.x86_64.rpm [root@localhost ~]# wget mirror.koreaidc.com/rpm/libmcrypt-devel-2.5.8-9.el6.x86_64.rpm [root@localhost ~]# rpm -Uvh libmcrypt-* [root@localhost ~]# rpm -Uvh mhash-* |
3. 중간에 의존성 문제가 발생될 수 있으니 사전 작업 진행 (mysql-libs가 기본 설치되니 삭제 진행)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
[root@localhost ~]# rpm -e mysql-libs --nodeps [root@localhost ~]# cp -a /usr/lib64/libpng* /usr/lib/ [root@localhost ~]# cp -a /usr/lib64/libjpeg* /usr/lib/ [root@localhost ~]# ln -s /usr/local/mysql/lib /usr/local/mysql/lib64 [root@localhost ~]# vi /etc/ld.so.conf include ld.so.conf.d/*.conf /lib64 /usr/lib64 /usr/local/mysql/lib64 [root@localhost ~]# ldconfig |
4. PHP 다운로드 및 컴파일 진행 ( opcache enabl )
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 |
[root@localhost ~]# wget mirror.koreaidc.com/php/php-7.0.4.tar.gz [root@localhost ~]# tar xvfz php-7.0.4.tar.gz [root@localhost ~]# cd php-7.0.4 [root@localhost php-7.0.4]# ./configure \ --prefix=/usr/local/php \ --with-mysql=/usr/local/mysql \ --with-mysqli=/usr/local/mysql/bin/mysql_config \ --with-pdo-mysql=/usr/local/mysql \ --with-apxs2=/usr/local/apache/bin/apxs \ --with-config-file-path=/usr/local/apache/conf \ --with-zlib \ --with-gdbm \ --with-gettext \ --libdir=/usr/lib64 \ --libexecdir=/usr/libexec \ --with-libdir=lib64 \ --with-kerberos \ --with-iconv \ --with-curl \ --with-zlib \ --with-gd \ --with-freetype-dir=/usr \ --with-jpeg-dir=/usr \ --with-png-dir=/usr/lib64 \ --with-mcrypt \ --with-mhash \ --with-bz2 \ --with-openssl \ --with-libxml-dir \ --with-pear \ --with-xmlrpc \ --with-readline \ --with-gmp \ --enable-mysqlnd \ --enable-zip \ --enable-sockets \ --enable-sysvsem \ --enable-sysvshm \ --enable-sysvmsg \ --enable-exif \ --enable-ftp \ --enable-soap \ --enable-gd-native-ttf \ --enable-gd-jis-conv \ --enable-mbstring \ --enable-mbregex \ --enable-libxml \ --enable-dba \ --enable-bcmath \ --enable-wddx \ --enable-calendar \ --enable-sigchild \ --enable-shmop \ --enable-xml \ --enable-opcache \ --disable-debug \ --disable-phar \ --disable-maintainer-zts \ --disable-xmlwriter [root@localhost php-7.0.4]# make -j 17 [root@localhost php-7.0.4]# make install |
5. php.ini 파일 복사 및 옵션 내용 수정
1 2 3 4 5 6 7 8 |
[root@localhost php-7.0.4]# cp -a php.ini-development /usr/local/apache/conf/php.ini [root@localhost php-7.0.4]# vi /usr/local/apache/conf/php.ini short_open_tag = On date.timezone = "Asia/Seoul" error_reporting = "E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED" upload_max_filesize = 12M |
6. 일반 사용자도 php를 사용할수 있게 심버릵 링크 구성하고 설치 완료 화면을 확인하자
1 2 3 4 5 |
[root@localhost php-7.0.4]# ln -s /usr/local/php/bin/php /usr/bin/php [root@localhost php-7.0.4]# php -v PHP 7.0.4 (cli) (built: Mar 24 2016 23:09:09) ( NTS ) Copyright (c) 1997-2016 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies |
8. 여기까지 설치하고 웹서버에서 phpinfo 화면을 뛰우면 정상적으로 출력이 되지 않을것이다. apache와 매칭을 시켜줘야 되서
php 항목에 추가
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
[root@localhost ~]# vi /usr/local/apache/conf/httpd.conf <IfModule dir_module> DirectoryIndex index.html index.htm index.php </IfModule> <IfModule mime_module> TypesConfig conf/mime.types #AddType application/x-gzip .tgz #AddEncoding x-compress .Z #AddEncoding x-gzip .gz .tgz AddType application/x-compress .Z AddType application/x-gzip .gz .tgz AddType application/x-httpd-php .php4 .php .html .htm .inc AddType application/x-httpd-php-source .phps AddHandler cgi-script .cgi .pl #AddHandler type-map var #AddType text/html .shtml #AddOutputFilter INCLUDES .shtml </IfModule> |