본문으로 바로가기

Centos 7 APM 설치 (apache, php, mysql)

category 서버 & 시스템/Linux 2019. 2. 15. 15:45
반응형



설치환경

CentOS release 7


Apache 2.4.9

MySQL 5.6.29

MariaDB 10.0.2.3

PHP 5.3.21







[Apache 설치]


1.  필수 구성요소 설치


1) 설치에 필요한 라이브러리 설치

# yum -y install openssl openssl-devel mhash mhash-devel libtool libtool-ltdl libtool-ltdl-devel imap-devel imap zlib-devel zlib freetype-devel freetype libpng-devel libpng libjpeg-devel libjpeg libtiff-devel libtiff gd-devel gd pcre-devel pcre libxml-devel libxml libxml2-devel libxml2 gdbm-devel gdbm ncurses-devel ncurses curl-devel curl expat-devel expat bzip2-devel bzip2-libs bzip2 libc libc-devel libc-client-devel gcc* wget



2) apr 설치

http://archive.apache.org/dist/apr/에서 다운로드 가능


# cd /usr/local/src

# wget http://archive.apache.org/dist/apr/apr-1.5.2.tar.gz

# tar zxvf apr-1.5.2.tar.gz

# cd apr-1.5.2

# ./configure

# make

# make install



3) apr-util 설치

http://archive.apache.org/dist/apr/에서 다운로드 가능


# cd /usr/local/src

# wget http://archive.apache.org/dist/apr/apr-util-1.5.4.tar.gz

# tar zxvf apr-util-1.5.4.tar.gz

# cd apr-util-1.5.4

# ./configure --with-apr=/usr/local/apr

# make

# make install



4) apache 설치

http://archive.apache.org/dist/httpd/에서 다운로드 가능


# cd /usr/local/src

# wget http://archive.apache.org/dist/httpd/httpd-2.4.9.tar.gz

# tar zxvf httpd-2.4.9.tar.gz

# cd httpd-2.4.9

# ./configure --prefix=/usr/local/apache --enable-so --enable-rewrite --enable-mods-shared=all --enable-modules=shared --enable-ssl --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr --with-mpm=prefork

# make

# make install



5) 부팅시 자동실행 등록 및 서비스 등록

# cp /usr/local/apache/bin/apachectl /etc/init.d/httpd


# vi /etc/init.d/httpd \\ 아래 내용 추가

# chkconfig: 2345 90 90 

# description: init file for Apache server daemon 

# processname: /usr/local/apache/bin/apachectl 

# config: /usr/local/apache/conf/httpd.conf 

# pidfile: /usr/local/apache/logs/httpd.pid 



# chkconfig --add httpd

# chkconfig httpd on



6) httpd.conf 설정

# vi /usr/local/apache/conf/httpd.conf


User nobody

Group nobody

ServerName localhost:80

DirectoryIndex index.html index.php index.jsp

AddHandler cgi-script .cgi

AddType application/x-httpd-php-source .phps

AddType application/x-httpd-php .php .jsp .html


<Directory /home/*>

    AllowOverride All

    Options +ExecCGI

    Require all granted

</Directory> 








[MySQL 설치]



1) cmake 설치

http://cmake.org에서 다운로드 가능


# cd /usr/local/src

# wget https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz --no_check_certificate

# tar zxvf cmake-3.4.3.tar.gz

# cd cmake-3.4.3

# ./bootstrap

# make

# make install



2) mysql 계정 생성

# groupadd -g 400 mysql

# useradd -u400 -g400 -d /usr/local/mysql -s /bin/false mysql



3) mysql 설치

# cd /usr/local/src

# wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.29.tar.gz

# tar zxvf mysql-5.6.29.tar.gz

# cd mysql-5.6.29

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DWITH_EXTRA_CHARSETS=all -DENABLED_LOCAL_INFILE=1 -DWITH_INNOBASE_STORAGE_ENGINE=1 -DMYSQL_UNIX_ADDR=/tmp/mysql.sock -DSYSCONFDIR=/etc -DMYSQL_TCP_PORT=3306

# make

# make install


4) mysql 기본 설정

# cp -arp support-files/my-default.cnf /etc/my.cnf

# cp -arp support-files/mysql.server /etc/init.d/mysqld

# rm -rf /usr/local/mysql/data

# /usr/local/mysql/scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data --basedir=/usr/local/mysql

# chown -R mysql.mysql /usr/local/mysql

# chmod 700 /etc/init.d/mysqld

# chmod 711 /usr/local/mysql

# chmod 700 /usr/local/mysql/data

# chmod 751 /usr/local/mysql/bin

# chmod 750 /usr/local/mysql/bin/*

# chmod 755 /usr/local/mysql/bin/mysql

# chmod 755 /usr/local/mysql/bin/mysqldump

# echo "/usr/local/mysql/lib" > /etc/ld.so.conf.d/mysql.conf

# cd /usr/local/mysql

# ln -s lib lib64

# chkconfig --add mysqld

# chkconfig mysqld on






[MariaDB 설치]



1) cmake 설치

http://cmake.org에서 다운로드 가능


# cd /usr/local/src

# wget https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz

# tar zxvf cmake-3.4.3.tar.gz

# cd cmake-3.4.3

# ./bootstrap

# make

# make install



2) mysql 계정 생성

# groupadd -g 400 mysql

# useradd -u400 -g400 -d /usr/local/mariadb -s /bin/false mysql



3) mariadb 설치

ftp://ftp.kaist.ac.kr/mariadb/에서 다운로드 가능


# cd /usr/local/src

# wget ftp://ftp.kaist.ac.kr/mariadb/mariadb-10.0.21/source/mariadb-10.0.21.tar.gz

# tar zxvf mariadb-10.0.21.tar.gz

# cd mariadb-10.0.21

# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mariadb -DWITH_INNOBASE_STORAGE_ENGINE=1 -DWITH_ARCHIVE_STORAGE_ENGINE=1 -DWITH_BLACKHOLE_STORAGE_ENGINE=1 -DMYSQL_DATADIR=/usr/local/mariadb/data -DWITH_PERFSCHEMA_STORAGE_ENGINE=1 -DWITH_PARTITION_STORAGE_ENGINE=1 -DWITH_FEDERATEDX_STORAGE_ENGINE=1 -DWITH_ARIA_STORAGE_ENGINE=1 -DWITH_XTRADB_STORAGE_ENGINE=1 -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_general_ci -DENABLED_LOCAL_INFILE=1 -DWITH_EXTRA_CHARSETS=all -DWITH_READLINE=1 -DWITH_SSL=system -DWITH_ZLIB=system

# make

# make install


*가상서버에서 설치 안될 경우 -DWITH_MROONGA_STORAGE_ENGINE=OFF 넣고 진행해볼 것!!



4) maraiadb 기본 설정

# cp -arp scripts/mysql_install_db /usr/local/mariadb

# cd /usr/local/mariadb

# rm -rf data

# perl ./mysql_install_db --user=mysql --basedir=/usr/local/mariadb --datadir=/usr/local/mariadb/data

# mkdir -p /usr/local/mariadb/InnoDB/redoLogs 

# mkdir -p /usr/local/mariadb/InnoDB/undoLogs 

# chown -R mysql /usr/local/mariadb/data 

# chgrp -R mysql /usr/local/mariadb 

# mkdir /usr/local/mariadb/logs /usr/local/mariadb/tmp 

# chown mysql.mysql /usr/local/mariadb/tmp 

# chown mysql.mysql /usr/local/mariadb/logs

# chown -R mysql:mysql /usr/local/mariadb/data

# cp /usr/local/mariadb/support-files/mysql.server /etc/rc.d/init.d/mariadb 

# chmod 755 /etc/rc.d/init.d/mariadb

# chkconfig --add mariadb

# chkconfig mariadb on

# echo "/usr/local/mariadb/lib" > /etc/ld.so.conf.d/mysql.conf

# cd /usr/local/mariadb 

# ln -s lib lib64

# cd /usr/local/mariadb/support-files

# cp my-huge.cnf /etc/my.cnf



5) mariadb 유틸경로 설정

# vi /etc/profile

alias mysqladmin='/usr/local/mariadb/bin/mysqladmin'

alias mysqldump='/usr/local/mariadb/bin/mysqldump'

alias mysql='/usr/local/mariadb/bin/mysql'



6) mariadb 루트 패스워드 변경

# mysqladmin -u root password






[PHP 설치]


1) imap 관련 라이브러리 설치

# yum -y install epel-release

# cd /usr/local/src

# wget http://rpms.famillecollet.com/enterprise/remi-release-7.rpm 

# yum -y install remi-release-7.rpm

# yum -y install libc-client uw-imap-devel uw-imap uw-imap-static

# ln -s /usr/lib64/libc-client.a /usr/lib/libc-client.a 



2) libcrympt 설치

# cd /usr/local/src

# wget ftp://mcrypt.hellug.gr/pub/crypto/mcrypt/libmcrypt/libmcrypt-2.5.7.tar.gz

# tar zxvf libmcrypt-2.5.7.tar.gz

# cd libmcrypt-2.5.7

# ./configure

# make

# make install 



3) php 설치

# cd /usr/local/src

# http://ris.smileserv.com/source/php-7.0.24.tar.gz

# tar zxvf php-7.0.4.tar.gz

# cd php-7.0.4

# ./configure --prefix=/usr/local/php --with-apxs2=/usr/local/apache/bin/apxs --with-config-file-path=/usr/local/apache/conf --with-mysql=/usr/local/mysql --enable-mod-charset --enable-safe-mode --enable-sigchild --enable-magic-quotes --with-libxml-dir --with-openssl --with-zlib --with-zlib-dir --with-bz2 --enable-calendar --with-curl --enable-dba --with-gdbm --enable-exif --enable-ftp --with-gd --with-jpeg-dir --with-png-dir --with-freetype-dir --enable-gd-native-ttf --with-gettext --with-imap --with-imap-ssl --with-kerberos --enable-mbstring --with-mhash --with-mcrypt --enable-sockets --with-regex=php --enable-sysvmsg --enable-sysvsem --enable-sysvshm --enable-wddx --enable-zend-multibyte --enable-zip

# make

# make install 



4) php.ini 설정

# vi /usr/local/apache/conf/php.ini

short_open_tag = On

memory_limit = 256M

post_max_size = 10M

upload_tmp_dir = /tmp

upload_max_filesize = 20M

allow_url_fopen = Off

date.timezone = Asia/Seoul 




반응형

'서버 & 시스템 > Linux' 카테고리의 다른 글

lsof 사용법  (1) 2019.03.06
메일서버 이용 시 가상서버 사용자 설정  (0) 2019.02.25
Lazarus 설치  (0) 2019.02.13
우분투에서 rpm 이용하기  (0) 2019.02.12
ssh 접속시 텔레그램으로 알람오게하기  (0) 2019.01.30