RadarURL

유닉스/리눅스
2014.05.26 10:26

CentOS 에 APM 설치하기

조회 수 1179 추천 수 0 댓글 0
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄

yum 으로 APM 패키지를 설치하고, 부팅시 자동 시작, 보안을 위한 설정을 다루겠습니다.

먼저 yum 으로 Apache + PHP + MySQL 패키지를 설치합니다.

1
yum install httpd mysql-server mysql php php-devel php-pear php-mysql php-mbstring php-gd

1. Apache 설정

- 먼저 설정 파일을 백업합니다.

1
cp -av /etc/httpd/conf/httpd.conf /etc/httpd/conf/httpd.conf.ori

 
- KeepAlive 항목은 Off 에서 On 으로 변경합니다.  중소규모에선 웹서버 사용량이 너무 많아 서비스가 멈출 정도가 아니라면 대부분의 경우 On 이 빠른 응답으로 유리합니다.

1
sed -i 's/KeepAlive Off/KeepAlive On/' /etc/httpd/conf/httpd.conf

 

- ServerName 은 아파치 시작시 경고 문구가 나오지 않도록 127.0.0.1 으로라도 입력해 둡니다.  (물론 실제 주소를 입력해도 됩니다.)

1
sed -i 's/#ServerName www.example.com:80/ServerName 127.0.0.1:80/' /etc/httpd/conf/httpd.conf

 

- AddDefaultCharset 항목은 UTF-8이 아닌 페이지에서 문제가 될 수 있으므로 주석 처리합니다.

1
sed -i 's/AddDefaultCharset UTF-8/#AddDefaultCharset UTF-8/' /etc/httpd/conf/httpd.conf

 

- 외부에서 Apache 버전을 알 수 없도록 숨깁니다.

1
2
sed -i 's/ServerTokens OS/ServerTokens Prod/' /etc/httpd/conf/httpd.conf
sed -i 's/ServerSignature On/ServerSignature Off/' /etc/httpd/conf/httpd.conf

 

- 이제 수정된 결과가 다음과 일치하는지 확인하면 됩니다.

1
grep -P 'KeepAlive O|^ServerName|AddDefaultCharset|ServerTokens|ServerSignature' /etc/httpd/conf/httpd.conf
ServerTokens Prod
KeepAlive On
ServerName 127.0.0.1:80
ServerSignature Off
#AddDefaultCharset UTF-8

 

2. PHP 설정

- 먼저 설정 파일을 백업합니다.

1
cp -av /etc/php.ini /etc/php.ini.ori

 
- /etc/php.ini 의 기본값은 다음과 같습니니다.

1
grep -P 'short_open_tag =|expose_php =|date.timezone =|register_globals =|register_long_arrays =|magic_quotes_gpc =|allow_call_time_pass_reference =|error_reporting =|display_errors =|display_startup_errors =' /etc/php.ini
short_open_tag = Off
allow_call_time_pass_reference = Off
expose_php = On
error_reporting = E_ALL & ~E_DEPRECATED
display_errors = Off
display_startup_errors = Off
register_globals = Off
register_long_arrays = Off
magic_quotes_gpc = Off
;date.timezone =

 

- 다음처럼 일반적인 설정을 적용해 줍니다.

1
2
3
sed -i 's/short_open_tag = Off/short_open_tag = On/' /etc/php.ini
sed -i 's/;date.timezone =/date.timezone = "Asia\/Seoul"/' /etc/php.ini
sed -i 's/allow_call_time_pass_reference = Off/allow_call_time_pass_reference = On/' /etc/php.ini

 

- 외부에서 PHP 버전을 숨깁니다.

1
sed -i 's/expose_php = On/expose_php = Off/' /etc/php.ini

 

- 장애 발생시 쉬운 해결을 위해 PHP 에러를 화면에 바로 보여줍니다. (보안에 민감하신 분은 Off로 그대로 두셔도 됩니다.)

1
2
sed -i 's/display_errors = Off/display_errors = On/' /etc/php.ini
sed -i 's/display_startup_errors = Off/display_startup_errors = On/' /etc/php.ini

 

- 일부 솔루션의 호환성 경고를 보이지 않기 위해 에러 레벨을 변경합니다.

1
sed -i 's/error_reporting = E_ALL \& ~E_DEPRECATED/error_reporting = E_ALL \& ~E_NOTICE \& ~E_DEPRECATED \& ~E_USER_DEPRECATED/' /etc/php.ini

 

- PHP 솔루션마다 필수 조건이 On, Off 2가지중 하나일 수 있지만, 국내 솔루션들은 아래와 같이 설정하면 무난합니다. 특히 사용하려는 PHP 솔루션에서 권장하는 magic_quotes_gpc 값을 모르실 경우, 일단 On 으로 두셔야 보안상 안전합니다.
참고) 1개 서버내에서 사이트마다 아래 값을 다르게 지정하는 방법도 있습니다. – http://www.php.net/manual/kr/configuration.changes.php
주의) 아래 값을 Off 로 두실 경우, 사용하려는 솔루션이 Off 환경에서 정상 동작하는지 반드시 확인하는 것이 좋습니다.

1
2
sed -i 's/register_globals = Off/register_globals = On/' /etc/php.ini
sed -i 's/magic_quotes_gpc = Off/magic_quotes_gpc = On/' /etc/php.ini

 

- (선택, 비권장) 아주 오래전에 제작한 솔루션에서 $HTTP_SERVER_VARS 등의 $HTTP_*_VARS 변수를 사용하는 경우에만 On 으로 변경합니다.
참고) 그누보드, XE 등의 솔루션들은 아래 항목을 Off 로 그대로 두면 됩니다.

1
sed -i 's/register_long_arrays = Off/register_long_arrays = On/' /etc/php.ini

 

- 이제 수정된 결과가 다음과 일치하는지 확인하면 됩니다.

1
grep -P 'short_open_tag =|expose_php = |date.timezone =|register_globals =|register_long_arrays =|magic_quotes_gpc =|allow_call_time_pass_reference =|error_reporting =|display_errors =|display_startup_errors =' /etc/php.ini
short_open_tag = On
allow_call_time_pass_reference = On
expose_php = Off
error_reporting = E_ALL & ~E_NOTICE & ~E_DEPRECATED & ~E_USER_DEPRECATED
display_errors = On
display_startup_errors = On
register_globals = On
register_long_arrays = Off
magic_quotes_gpc = On
date.timezone = "Asia/Seoul"

 

3. Apache 시작

- Apache 웹서버를 시작합니다.

1
/etc/init.d/httpd start

 
- Apache 웹서버를 부팅시 자동 시작되도록 합니다.

1
/sbin/chkconfig httpd on

 
- 이제 웹브라우저에서 서버 IP를 입력하여, 테스트 웹페이지가 열리는지 확인하면 됩니다.
만약 테스트 웹페이지가 열리지 않는다면, 안전한 CentOS를 위한 방화벽을 확인해보시면 됩니다.
 

4. MySQL 설정 및 시작

- 먼저 설정 파일을 백업합니다.

1
cp -av /etc/my.cnf /etc/my.cnf.ori

 

- 서버 메모리가 2GB 이상이라면, 1~2GB 에 최적화된 설정 파일로 교체합니다.

1
cp -av /usr/share/mysql/my-huge.cnf /etc/my.cnf

 

- 설정 파일에서 차기 버전에서 변경되어 에러 가능성이 있는 항목을 미리 변경해 둡니다.

1
sed -i 's/skip-locking/skip-external-locking/' /etc/my.cnf

 

- MySQL DB서버를 시작합니다.

1
/etc/init.d/mysqld start

 

- MySQL DB서버를 부팅시 자동 시작되도록 합니다.

1
/sbin/chkconfig mysqld on

 

- MySQL 보안 설정을 시작합니다. mysql root 비밀번호만 입력하고, 나머지는 모두 엔터만 입력하면 기본값(불필요한 권한 및 DB 삭제)으로 처리됩니다.

1
/usr/bin/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 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.

Set root password? [Y/n] 
New password: *** 여기서 mysql root 비밀번호 입력 ***
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.

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.

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.

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.

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!

 

- 입력했던 mysql root 비밀번호로 접속되는지 확인하면 모든 작업이 완료됩니다.

1
mysql -uroot -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 5.1.69-log Source distribution

Copyright (c) 2000, 2013, 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
+--------------------+
2 rows in set (0.00 sec)

mysql> quit

 
이상입니다.

다음에는 솔루션 설치를 위한 Apache VirtualHost(가상 호스트) 설정, MySQL DB 계정 생성 등을 해보겠습니다.


출처 : http://www.php79.com/92

TAG •
?

공부 게시판

공부에 도움되는 글을 올려주세요.

List of Articles
번호 분류 제목 글쓴이 날짜 조회 수
공지 [공지] 공부 게시판 입니다. 처누 2003.08.18 927881
1806 유닉스/리눅스 Xmanager CentOS 설정 : CentOS 4.x, 5.x, 6.x JaeSoo 2014.05.27 1401
1805 유닉스/리눅스 리눅스에서 일반 계정으로 httpd 80포트 실행하기 file JaeSoo 2014.05.26 1332
1804 유닉스/리눅스 Xmanager에서 CentOS 5.X 원격Xwindow 띄우기 JaeSoo 2014.05.26 1498
1803 웹서버,WAS Apache 서버에서 확장자 .htm 파일 내의 php 코드가 실행되지 않는 문제 해결 방법 JaeSoo 2014.05.26 2170
1802 유닉스/리눅스 Apache 파일시스템 권한 설정 JaeSoo 2014.05.26 1619
1801 유닉스/리눅스 vi 명령어, vi 단축키, vi(Visual Editer), vim JaeSoo 2014.05.26 1325
1800 유닉스/리눅스 리눅스 파일의 소유자, 소유그룹 변경하기 JaeSoo 2014.05.26 1357
1799 유닉스/리눅스 CentOS 방화벽 설정 하기 JaeSoo 2014.05.26 1551
1798 유닉스/리눅스 Apache HTTP Server, Rewrite가 안되는 경우 JaeSoo 2014.05.26 1680
1797 유닉스/리눅스 CentOS - samba 자동실행 JaeSoo 2014.05.26 1480
1796 유닉스/리눅스 vsftp에서 500 OOPS: cannot change directory 오류가 나올 때 JaeSoo 2014.05.26 1236
1795 유닉스/리눅스 CentOS samba 공유 폴더 생성하기 JaeSoo 2014.05.26 1255
1794 유닉스/리눅스 CentOS Samba Server 설정 file JaeSoo 2014.05.26 1384
1793 유닉스/리눅스 CentOS Samba 설치 및 설정 JaeSoo 2014.05.26 1192
1792 유닉스/리눅스 안전한 CentOS를 위한 방화벽, 보안 설정 file JaeSoo 2014.05.26 1294
» 유닉스/리눅스 CentOS 에 APM 설치하기 JaeSoo 2014.05.26 1179
1790 유닉스/리눅스 Xshell 한글 깨짐 file JaeSoo 2014.05.26 1382
1789 유닉스/리눅스 CentOS 5.2 + Xmanager 설정 방법 file JaeSoo 2014.05.26 1235
1788 유닉스/리눅스 CentOS X Window + Gnome Desktop 설치 JaeSoo 2014.05.26 1635
1787 유닉스/리눅스 [VMware] CentOS 6.5 설치 (64bit) - GUI(GNOME) file JaeSoo 2014.05.26 1836
Board Pagination Prev 1 ... 29 30 31 32 33 34 35 36 37 38 ... 124 Next
/ 124


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너