RadarURL

유닉스/리눅스
2014.05.26 10:26

CentOS 에 APM 설치하기

조회 수 5690 추천 수 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 2003651
2615 공지 대전, 인천, 세종 하수구 막힘 문제 해결 방법 new 정열적인코요테90 2026.10.05 1
2614 취미 <문경맥주> 구입 할 수 있는 곳은 새 창 열림 new 타오르는드래곤61 2026.10.05 1
2613 데이터베이스 강남건전지❤️OlO-8655-OO53❤️친절문의환영 #강남건전지 #강남유니콘 #선릉유니콘 #강남건전지위치 #선릉역건전지#대치동유니콘 #강남바커스 #선릉바커스 #선릉역바커스 #강남룸클럽 #선릉룸클럽 #강남베터리 #강남바데리 new 괴랄한재규어89 2026.10.05 1
2612 사무 소프트웨어 용인두피문신 고민? 만족 후기 보려면 new 날카로운꿩11 2026.10.05 1
2611 논문 카­톡 gusim8003 급전/내구제 (24시문의) 폰테크 소액대출 선불폰 가개통 new 타오르는켄타우로스86 2026.10.05 1
2610 윈도우즈 웨딩누브라, 완벽한 드레스 핏을 위한 선택 new 날카로운감시자22 2026.10.05 1
2609 인터넷 성공적인 중고화물차 선택, 현명한 가이드 new 붉은드래곤50 2026.10.05 2
2608 가상화 인천맛집 순위 new 차가운파편97 2026.10.05 2
2607 응용 프로그래밍 완벽한 웨딩드레스 핏의 비밀, 웨딩누브라 new 힘겨운암석76 2026.10.05 1
2606 카메라 파주누수업체, 신속 해결 전문가의 비결 new 차가운에메랄드79 2026.10.05 1
2605 u-E(통합센터) 올해의 핫플 선정 간석동 마블! 010&&8923&&0291 new 교활한감시자99 2026.10.05 1
2604 웹서버,WAS 손목터널증후군 치료, 현명한 선택 기준은? new 괴상한두루미52 2026.10.05 1
2603 u-E(통합센터) 손목터널증후군, 두팔로정형외과에서 해답을 찾다 new 눈부신백마법사86 2026.10.05 1
2602 응용 프로그래밍 골든타워 010 2817 0845 골타문의 편하게 알아보는 셔츠룸 new 속삭이는미노타우르93 2026.10.05 2
2601 u-E(TestBed) 특별한 기념품제작, 판촉물365 new 광기의태풍18 2026.10.05 1
2600 건강 대전누수 문제, 청년연합누수가 답이다 new 몽환적인삵34 2026.10.05 2
2599 u-E(법,정책) 양산싱크대막힘, 뚫자하수구에서 한 번에 해결 new 낙관적인유니콘42 2026.10.05 1
2598 가상화 최근 테헤란로 벤처 밸리의 핵심 리더들 사이에서 ‘클래스가 다른 정통 수질과 프라이빗 무드’로 소문 자자한 '선릉 룸싸롱' 기습 방문, 인공미를 거부하는 무결점 뉴페이스들과 심장을 마비시킨 사심 플러팅에 제대로 저격당하고 온 솔직 후기 new 희미한홍학99 2026.10.05 3
2597 웹서버,WAS 카­톡 gusim8003 급전/내구제 (24시문의) 선불폰 소액결제 일수 급전대출 new 황금빛섬광82 2026.10.05 2
2596 웹광고 해외선물 메타5 거래소와 GFS컴퍼니의 장점과 고려사항 new 울리는이구아나69 2026.10.05 2
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 131 Next
/ 131


즐겨찾기 (가족)

JAESOO's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

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

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

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

JServer.kr

제이서버 메타블로그

재수 티스토리


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

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너