RadarURL

유닉스/리눅스
2014.05.26 10:26

CentOS 에 APM 설치하기

조회 수 1180 추천 수 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 928246
2474 연애 폭소클럽 제36회 - 즉석미팅 1 (김제동) file JaeSoo 2003.08.18 18982
2473 연애 폭소클럽 제37회 - 즉석미팅 2 (김제동) file JaeSoo 2003.08.18 17809
2472 연애 폭소클럽 제38회 - 방학특집 연애특강 1 (김제동) 1 file JaeSoo 2003.08.18 16361
2471 연애 폭소클럽 제39회 - 방학특집 연애특강 2 (김제동) file JaeSoo 2003.08.18 17829
2470 연애 폭소클럽 제40회 - 방학특집 연애특강 3 (김제동) file JaeSoo 2003.08.18 16842
2469 웹 프로그래밍 이미지 특정 부분에 링크 만들기 처누 2003.08.24 15624
2468 웹 프로그래밍 게시판에 자신의 FTP 자료 올리기 3 처누 2003.08.25 13135
2467 동식물 고양이 클리닉 - 고양이 기르기 file JaeSoo 2003.10.10 13694
2466 동식물 고양이 클리닉 - 고양이 품종 file JaeSoo 2003.10.10 13427
2465 동식물 고양이 클리닉 - 2개월에서 4개월령 고양이 관리 file JaeSoo 2003.10.11 13429
2464 동식물 고양이 클리닉 - 4개월에서 9개월령 고양이 관리 file JaeSoo 2003.10.11 13133
2463 동식물 고양이 클리닉 - 다자란 고양이 file JaeSoo 2003.10.13 13922
2462 동식물 고양이 클리닉 - 나이든 고양이 file JaeSoo 2003.10.13 13680
2461 동식물 고양이 클리닉 - 고양이의 영양 file JaeSoo 2003.10.13 13429
2460 동식물 고양이 먹이와 주의사항 file JaeSoo 2003.10.13 13902
2459 동식물 아기 고양이의 식사 file JaeSoo 2003.10.13 11821
2458 동식물 고양이 사료 급여량 file JaeSoo 2003.10.13 12880
2457 기타 편지봉투 쓰는 법 file JaeSoo 2003.10.21 16993
2456 웹 프로그래밍 제로보드 로그인 실패시 이유를 메세지로 알려주기 처누 2003.11.04 8459
2455 웹 프로그래밍 최근 게시물 출력시 링크게시물에 스타일시트 적용하기 처누 2003.11.06 7928
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 124 Next
/ 124


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

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

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

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

JServer.kr

제이서버 메타블로그

재수 티스토리


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

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너