본문으로 바로가기

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

category 서버 & 시스템/Linux 2017. 10. 3. 15:28
반응형

설치환경


CentOS release 6.8 (Final)

Server version: Apache/2.4.3 (Unix)
mysql  Ver 14.14 Distrib 5.1.63

PHP 5.3.21





[Apache 설치]


1.  필수 구성요소 설치

1)  의존 패키지 설치 (필수 라이브러리)

 # yum -y install openssl openssl-devel mhash mhash-devel libtool libtool-ltdl libtoolltdl-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 expatdevel expat bzip2-devel bzip2-libs bzip2 libc libc-devel libc-client-devel gcc*


2) apr & apr-util 설치

# wget --user apm --password http://ris.smileserv.com/source/apr-1.5.1.tar.gz

# tar zxvf apr-1.5.1.tar.gz

# cd apr-1.5.1

# ./configure

# make && make install


# wget --user apm --password http://ris.smileserv.com/source/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 



3) 아파치 설치

# cd /usr/local/src

# wget --user apm --password http://ris.smileserv.com/source/httpd-2.4.3.tar.gz

# tar zxvf httpd-2.4.3.tar.gz


# cd httpd-2.4.3


# vi /httpd-2.4.3/server/mpm/prefork/prefork.c

# define DEFAULT_SERVER_LIMIT 256 \\ 존값 256에서 1024로 변경


# ./configure --prefix=/usr/local/apache \

--enable-so \

--enable-rewrite \

--enable-mods-shared=all \

--enable-modules=shared \

--enable-ssl \

--with-included-apr=/usr/local/apr \

--with-included-apr-util \

--with-mpms-shared=all \

--with-apr=/usr/local/apr \

--with-mpm=prefork 

# make && make install


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

ServerName www.example.com:80  \\ ServerName 127.0.0.1:80 으로 변경 (localhost:80, 본인IP:80 모두 가능)

 

AddType application/x-httpd-php .php4 .php .phtml .ph .inc .html .htm  \\ 



2. 아파치 서비스 등록 (자동실행설정)

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

# chmod 700 /etc/init.d/apachectl


# vi /etc/init.d/apachectl

#!/bin/sh 밑에 아래 다섯줄 추가

# 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 apachectl

# chkconfig apachectl on

# chkconfig --level 3 apachectl on


3. 방화벽추가

1) iptables 사용시

# vi /etc/sysconfig/iptables  \\ 아랫줄 추가  d추가가

-A INPUT -p tcp -m state --state NEW -m tcp --dport 80 -j ACCEPT 

# /etc/init.d/apachectl restart 


2) firewalld 사용시

# firewall-cmd --zone=public --add-port=80/tcp –permanent 

# firewall-cmd –reload // # systemctl restart firewalld

# vi /etc/firewalld/zones/public.xml  \\이곳에서 포트추가한 것 확인가능



4. 설치확인

# /etc/init.d/apachectl restart

# netstat -nltp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp              0           0 :::80                              :::*                                  LISTEN     3876/httpd          



* 오류발생

** 오류**

# /etc/init.d/apachectl start

# /etc/init.d/apachectl start AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using rlfiddlaks- 1122.novalocal. Set the 'ServerName' directive globally to suppress this message 


** 해결방법**

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

User nobody  \\수정 

Group nobody \\수정 

ServerName localhost 및 해당서버 IP:80  \\수정 

AddHandler cgi-script .cgi \\주석해제

AddType application/x-httpd-php-source .phps \\추가 

AddType application/x-httpd-php .php .jsp .html \\추가 

DirectoryIndex index.html index.php index.jsp \\추가  


\\제일 아래부분에 추가

<Directory /home/*>

 AllowOverride All

 Options +ExecCGI

 Require all granted 

</Directory >



5. 확인

# /usr/local/apache/bin/apachectl -v

Server version: Apache/2.4.3 (Unix)

Server built:   Oct  3 2017 11:25:04 








[MySQL 설치]


1.  계정추가

# groupadd -g 400 mysql

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



2. MySQL 설치

# wget --user apm --password http://ris.smileserv.com/source/mysql-5.1.63.tar.gz

# tar zxvf mysql-5.1.63.tar.gz

# cd mysql-5.1.63

# ./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/data --with-mysqld-user=mysql --with-extra-charsets=all --with-plugins=max --enable-thread-safe-client --with-charset=utf8

# make && make install  



3. MySQL 설정

1) 기본설정

# cd /usr/local/mysql-5.1.63

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

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

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


2) 초기 데이터베이스 구성 및 권한설정

# 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



4. 방화벽설정

1) iptables 사용시

# vi /etc/sysconfig/iptables  \\ 아랫줄 추가

-A INPUT -p tcp -m state --state NEW -m tcp --dport 3306 -j ACCEPT

# /etc/init.d/iptables restart


2) firewalld 사용시

# firewall-cmd --zone=public --add-port=3306/tcp --permanent 

# firewall-cmd --reload // # systemctl restart firewalld

# vi /etc/firewalld/zones/public.xml \\ 이곳에서 포트추가한 것 확인가능




4. 확인

# /etc/init.d/mysqld restart

# netstat -nltp

Active Internet connections (only servers)

Proto Recv-Q Send-Q Local Address               Foreign Address             State       PID/Program name   

tcp        0      0 0.0.0.0:3306                0.0.0.0:*                   LISTEN      28799/mysqld       


# /usr/local/mysql/bin/mysql -V

/usr/local/mysql/bin/mysql  Ver 14.14 Distrib 5.1.63, for unknown-linux-gnu (x86_64) using  EditLine wrapper








[PHP 설치]


1.  의존 패키지 설치 (필수 라이브러리)

# cd /usr/local/src


1) libmscrypt 설치

# wget http://ris.smileserv.com/source/libmcrypt-2.5.7.tar.gz

# tar zxvf libmcrypt-2.5.7.tar.gz

# cd libmcrypt-2.5.7

# ./configure

# make && make install


2) mhash 설치

# wget http://ris.smileserv.com/source/mhash-0.9.9.9.tar.gz

# tar zxvf mhash-0.9.9.9.tar.gz

# cd mhash-0.9.9.9

# ./configure

# make && make install


3) libc-client-devel 설치 (일단 안해보고 설치, 오류나면 설치)

# wget http://ris.smileserv.com/source/imap-2007f.tar.gz

# tar zxvf imap-2007f.tar.gz

# cd imap-2007f/src/c-client

# cp *.h /usr/local/include/

# cd /usr/local/src/imap-2007f

# make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd EXTRACFLAGS=-fPIC IP=4

# mkdir /usr/local/imap-2007f/

# mkdir /usr/local/imap-2007f/include/

# mkdir /usr/local/imap-2007f/lib/

# cp c-client/*.h /usr/local/imap-2007f/include/

# cp c-client/*.c /usr/local/imap-2007f/lib/

# cp c-client/c-client.a /usr/local/imap-2007f/lib/libc-client.a



2. PHP 설치

# wget --user apm http://ris.smileserv.com/source/php-5.3.21.tar.gz

# tar zxvf php-5.3.21.tar.gz

# cd php-5.3.21

# ./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-magicquotes --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=/usr/local/imap-2007f --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



3. PHP 설정


# cp php.ini-development /usr/local/apache/conf/php.ini

# vi /usr/local/apache/conf/php.ini \\ 아래와 같이 수정

short_open_tag = On 

post_max_size = 100M 

upload_max_filesize = 100M


# vi /usr/local/apache/htdocs/phpinfo.php

<?

phpinfo();

?>



4. 설치확인

# /usr/local/php/bin/php -v

PHP 5.3.21 (cli) (built: Oct  3 2017 12:46:29) 

Copyright (c) 1997-2013 The PHP Group

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



* 인덱스페이지가 다운로드 될 시

# vi /usr/local/apache/conf/httpd.conf \\ 아래 추가


AddType application/x-compress .Z

AddType application/x-gzip .gz .tgz

AddType application/x-httpd-php .php4 .php .phtml .ph .inc .html .htm

AddType application/x-httpd-php .php .html .htm .inc .pia .jsp

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





[변수설정]


# vi /root/.bash_profile \\ 기본환경변수에 mysql, php 경로 지정

PATH=$PATH:$HOME/bin:/usr/local/mysql/bin:/usr/local/php/bin:

# source /root/.bash_profile 




반응형