Æí¸®ÇÑ È£½ºÆà ¹Ì¼ÒIDC

   
 
 
 

      1Â÷ ³×ÀÓ¼­¹ö :
      ns1.misoidc.com
      101.79.73.101

      2Â÷ ³×ÀÓ¼­¹ö :
      ns2.misoidc.com
      101.79.73.105

      ¾îÁ¦ : 348 ,¿À´Ã : 9
      Àüü : 1,156,521


     

 

 
ÀÛ¼ºÀÏ : 12-01-13 16:39
[¸®´ª½º/NGINX] CentOs 5.7 64bit ¿¡¼­ NGINX + PHP + MYSQL + memcache ¼³Ä¡ Çϱâ
 ±Û¾´ÀÌ : ½ÑÀ¥È£½ºÆÃ
Á¶È¸ : 83,974  
¸¶Ä§ ¼­ºñ½º ¿î¿µÁß nginx + php + mysql + memcached ¸¦ ¼³Ä¡ÇÒ ±âȸ°¡ »ý°å±â¿¡, ±ÛÀ» ¿Ã¸°´Ù.

<¼³Ä¡È¯°æ>
CentOs 5.7 64bit
nginx 1.0.11
php 5.2.17
php-5.2.17-fpm-0.5.14

## mysql Àº ¼öµ¿À¸·Î ¼³Ä¡ (°æ·Î /usr/local/mysql ±âÁØ)

1. [NGINX ¼³Ä¡]

$ cd /usr/local/src
$ wget http://nginx.org/download/nginx-1.0.11.tar.gz
$ tar xvfzp nginx-1.0.11.tar.gz
$ cd /usr/local/src/nginx-1.0.11
$ ./configure --prefix=/usr/local/nginx --with-http_ssl_module
$ make
$ make install


¼³Ä¡°¡ ¿Ï·á µÇ¾úÀ¸¸é, ¾Æ·¡ ½ºÅ©¸³Æ®¸¦ ¹Þ¾Æ¼­,
¼­¹ö¿¡ ÀúÀåÇÑ ÈÄ, /etc/init.d/nginx ¿Í °°ÀÌ ¼¼ÆÃÇÑ´Ù.


$ mv nginx.txt /etc/init.d/nginx
$ chmod 755 /etc/init.d/nginx


nginx ¸¦ ±¸µ¿Çغ¸ÀÚ.
$ /etc/init.d/nginx start
Starting nginx:

$ netstat -lnp
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 30164/nginx.conf


À§¿Í °°ÀÌ nginx ¸¦ ±¸µ¿ÇßÀ»¶§ 80Æ÷Æ®°¡ º¸´Â°Í°ú °°ÀÌ ³ª¿À¸é µÈ´Ù.

ÀÎÅͳݺê¶ó¿ìÀú â¿¡¼­, http://¼³Ä¡¼­¹öIP ¸¦ ÀÔ·ÂÇغ¸¸é

Welcome to nginx!

À§¿Í °°ÀÌ ³ª¿À´Âµ¥, ÀÌ·¸°Ô ³ª¿À¸é, nginx ¼³Ä¡°¡ ¿Ï·á µÈ °ÍÀ¸·Î º¸¸é µÈ´Ù.

2. php + php-fpm ¼³Ä¡

$ cd /usr/local/src
$ wget http://kr2.php.net/get/php-5.2.17.tar.gz/from/this/mirror
$ wget http://php-fpm.org/downloads/php-5.2.17-fpm-0.5.14.diff.gz
$ tar xvfzp php-5.2.17.tar.gz
$ gzip -cd php-5.2.17-fpm-0.5.14.diff.gz | patch -d php-5.2.17 -p1
$ cd php-5.2.17


¾Æ·¡ configure ÆÄÀÏÀ» ¹Þ¾Æ¼­, µ¿ÀÏÇÏ°Ô ¼³Ä¡ ÇÑ´Ù.

$ make; make install
Installing PHP SAPI module: cgi
Installing PHP CGI binary: /usr/local/php-fpm/bin/
Installing FPM config: /usr/local/php-fpm/etc/php-fpm.conf
(installing as php-fpm.conf.default)
Installing init.d script: /usr/local/php-fpm/sbin/php-fpm
Installing PHP CLI binary: /usr/local/php-fpm/bin/
Installing PHP CLI man page: /usr/local/php-fpm/man/man1/
Installing build environment: /usr/local/php-fpm/lib/php/build/
Installing header files: /usr/local/php-fpm/include/php/
Installing helper programs: /usr/local/php-fpm/bin/
program: phpize
program: php-config
Installing man pages: /usr/local/php-fpm/man/man1/
page: phpize.1
page: php-config.1
Installing PEAR environment: /usr/local/php-fpm/lib/php/
[PEAR] Archive_Tar - installed: 1.3.7
[PEAR] Console_Getopt - installed: 1.2.3
[PEAR] Structures_Graph- installed: 1.0.3
[PEAR] XML_Util - installed: 1.2.1
[PEAR] PEAR - installed: 1.9.1
Wrote PEAR system config file at: /usr/local/php-fpm/etc/pear.conf
You may want to add: /usr/local/php-fpm/lib/php to your php.ini include_path
Installing PDO headers: /usr/local/php-fpm/include/php/ext/pdo/

¼³Ä¡°¡ ¿Ï·á µÇ¾úÀ¸¸é, php.ini ¸¦ º¹»çÇÑ ÈÄ, php-fpm À» ½Éº¼¸¯¸µÅ©¸¦ °É¾î, À§Ä¡¿¡ ÀúÀåÇÑ´Ù.

$ cd /usr/local/src/php-5.2.17
$ cp -a php.ini-dist /usr/local/php-fpm/lib/php.ini
$ cd /etc/init.d/
$ ln -s /usr/local/php-fpm/sbin/php-fpm php-fpm
$ /etc/init.d/php-fpm start
Starting php_fpm Jan 04 10:01:30.274536 [ERROR] fpm_unix_conf_wp(), line 124: please specify user and group other than root, pool 'default'
................................... failed


php-fpm À» ±¸µ¿½ÇÇà ÇÏ¿´´õ´Ï ´ÙÀ½°ú °°ÀÌ ¿¡·¯°¡ ¹ß»ýÇÑ´Ù. ÀÌ´Â, »ç¿ëÇÏ´Â user ¿Í group ÀÌ Á¤»óÀûÀ¸·Î ¼³Á¤µÇÁö ¾Ê¾Ò´Ù´Â ÀÇ¹Ì ÀÌ´Ù. php-fpm.conf ÆÄÀÏ¿¡ 62¹ø ~66¹ø ¶óÀÎÀ» ¾Æ·¡¿Í °°ÀÌ ¼öÁ¤ÇÑ´Ù.

$ vi /usr/local/php-fpm/etc/php-fpm.conf
<!-- Unix user of processes -->
<value name="user">nobody</value>

<!-- Unix group of processes -->
<value name="group">nobody</value>

¼öÁ¤ ÈÄ, ´Ù½Ã ½ÇÇàÇØ º»´Ù.

$ /etc/init.d/php-fpm start
Starting php_fpm done
$ netstat -lnp | grep php
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 26544/php-cgi

Á¤»óÀûÀ¸·Î php-fpm ÀÌ ±¸µ¿µÈ°ÍÀÌ È®ÀÎ µÇ¾ú´Ù.

3. zend ¼³Ä¡
Áö±Ý ¼³Ä¡ÇÏ´Â°Ç 64bit ¿¡ ¼³Ä¡ÇÏ´Â °ÍÀ̱⿡, 64bit ¸¦ ´Ù¿î·Îµå ¹Þ¾ÒÁö¸¸, 32bit ÀÎ °æ¿ì, 32bit ¸¦ ´Ù¿î¹ÞÀ¸¸é µÇ°Ú´Ù.

64bit ÀÎ °æ¿ì
$ cd /usr/local/src
$ wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz

32bit Àΰæ¿ì
$ cd /usr/local/src
$ wget http://downloads.zend.com/optimizer/3.3.9/ZendOptimizer-3.3.9-linux-glibc23-i386.tar.gz

¾ÐÃàÀ» ÇØÁ¦ÇÏ°í, php ¹öÀü¿¡ ¸Â´Â ZendOptimizer.so ÆÄÀÏÀ» º¹»çÇÑ´Ù.

$ tar xvfzp ZendOptimizer-3.3.9-linux-glibc23-x86_64.tar.gz
$ cd ZendOptimizer-3.3.9-linux-glibc23-x86_64/data
$ ls -al
drwxr-xr-x 2 root root 4096 Aug 24 2009 4_2_0_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 4_2_x_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 4_3_x_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 4_4_x_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 5_0_x_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 5_1_x_comp
drwxr-xr-x 2 root root 4096 Aug 24 2009 5_2_x_comp


ÇöÀç ¼³Ä¡ ÇÑ php ¹öÀüÀº 5.2.17 À̱⶧¹®¿¡ °¡Àå¹Ø¿¡ ÀÖ´Â 5_2_x_comp Æú´õ¿¡ ÀÖ´Â ZendOptimizer.so ¸¦ »ç¿ëÇÒ°ÍÀÌ´Ù.

$ cp -a /usr/local/src/ILAYA/SOURCE/ZendOptimizer-3.3.9-linux-glibc23-x86_64/data/5_2_x_comp/ZendOptimizer.so /usr/local/php-fpm/lib/


Zend ¼³Ä¡°¡ ¿Ï·á µÇ¾úÀ¸¸é, php.ini ¿¡ Zend °æ·Î¸¦ ÀúÀåÇÑ´Ù.

$ vi /usr/local/php-fpm/lib/php.ini
°¡Àå ÇÏ´Ü¿¡ ¾Æ·¡ ³»¿ë Ãß°¡
[Zend]
zend_extension=/usr/local/php-fpm/lib/ZendOptimizer.so

ÀúÀåÀÌ ¿Ï·á µÇ¾úÀ¸¸é, ÀÌÁ¦ nginx ¿Í php-fpm À» ¿¬µ¿ÇÑ´Ù.

$ vi /usr/local/nginx/conf/nginx.conf
¾à 63 ¶óÀÎÁ¤µµ¿¡ ÁÖ¼®À¸·Î ÀÖ´Â ¿É¼ÇµéÀÌ Àִµ¥, ÁÖ¼®³»¿ëÀº Áö¿öµµ ¹«¹æÇϸç, ÆÄÀÏ ³»¿ë¿¡ ¾Æ·¡ ¿É¼ÇÀ» Ãß°¡ÇÑ´Ù.
location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param scRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}


Ãß°¡°¡ ¿Ï·á µÇ¸é, ÀÌÁ¦ nginx ¿Í php-fpm À» À籸µ¿ÇØÁØ´Ù.

$ /etc/init.d/php-fpm stop;/etc/init.d/nginx stop
$ /etc/init.d/php-fpm start;/etc/init.d/nginx start

½ÇÁ¦ ¿¬µ¿ÀÌ µÇ¾ú´ÂÁö Å×½ºÆ®¸¦ Çغ¸ÀÚ.
nginx ÀÇ ±âº» Ȩ°æ·Î´Â /usr/local/nginx/html ÀÌ´Ù, (¾ÆÆÄÄ¡ÀÇ °æ¿ì´Â /usr/local/apache/htdocs)
ÇØ´ç °æ·Î¿¡ ±âº» phpinfo ÆÄÀÏÀ» »ý¼ºÇÑ´Ù.

$ cd /usr/local/nginx/html
vi test.php
< ?
phpinfo
?>

À§ÀÇ ³»¿ë Ãß°¡

ºê¶ó¿ìÀúâ¿¡¼­ È®ÀÎÇغ»´Ù. (mysql ¿¬µ¿±îÁö È®ÀÎ)

À§¿Í °°ÀÌ µÇ¾úÀ¸¸é Á¤»óÀûÀ¸·Î ¿¬µ¿ µÈ°ÍÀÌ´Ù.

4. memcache ¼³Ä¡

memcached ´Â ¸Þ¸ð¸®¸¦ ij½Ã·Î »ç¿ëÇÏ´Â ºÐ»ê ¼Ö·ç¼ÇÀ¸·Î ¼­¹öºÎÇÏ°¡ ¸¹Àº »çÀÌÆ®¿¡ ¿î¿µÇϸé, È¿°ú¸¦ º¼ ¼ö ÀÖ´Ù.

1) libevent ¼³Ä¡

$ cd /usr/local/src
$ wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
$ tar xvfzp libevent-1.4.13-stable.tar.gz
$ cd libevent-1.4.13-stable
$ ./configure ; make ; make install

2) memcached ¼³Ä¡

$ cd /usr/local/src
$ wget http://memcached.googlecode.com/files/memcached-1.4.10.tar.gz
$ tar xvfzp memcached-1.4.10.tar.gz
$ cd memcached-1.4.10
$ LDFLAGS='-Wl,--rpath /usr/local/lib' ./configure --prefix=/usr/local --enable-64bit
$ make
$ make install
$ cd scripts
$ cp -a memcached.sysv /etc/init.d/memcached
$ chown root.root /etc/init.d/memcached
$ chmod 755 /etc/init.d/memcached
$ vi /etc/init.d/memcached
PORT=11211
USER=root
MAXConN=1024
CACHESIZE=512
OPTIonS=""
PATH="/usr/local/bin:$PATH"

À§¿Í °°ÀÌ Ãß°¡µÈ PATH ÀÇ °æ¿ì, memcached °¡ ¼³Ä¡µÇ¾î Àִ°æ·Î¸¦ "whereis memcached" ¸¦ ÀÔ·ÂÇÏ¿© ã¾Æ³½ °ª

$ mkdir /var/run/memcached
$ /etc/init.d/memcached start
$ netstat -lnp
tcp 0 0 0.0.0.0:11211 0.0.0.0:* LISTEN 24933/memcached

memcached °¡ Á¤»óÀûÀ¸·Î ¿Ã¶ó¿Ô´ÂÁö È®ÀÎ.

14:41:22 $ telnet localhost 11211
Trying 127.0.0.1...
Connected to localhost.localdomain (127.0.0.1).
Escape character is '^]'.
stats
STAT pid 24933
STAT uptime 2618
STAT time 1325655685
STAT version 1.4.10
STAT libevent 1.4.13-stable
STAT pointer_size 64
STAT rusage_user 0.000999
STAT rusage_system 0.011998
STAT curr_connections 5
STAT total_connections 7
STAT connection_structures 6
STAT reserved_fds 20
STAT cmd_get 0
STAT cmd_set 0
STAT cmd_flush 0
STAT cmd_touch 0
STAT get_hits 0
STAT get_misses 0
STAT delete_misses 0
STAT delete_hits 0
STAT incr_misses 0
STAT incr_hits 0
STAT decr_misses 0
STAT decr_hits 0
STAT cas_misses 0
STAT cas_hits 0
STAT cas_badval 0
STAT touch_hits 0
STAT touch_misses 0
STAT auth_cmds 0
STAT auth_errors 0
STAT bytes_read 29
STAT bytes_written 1040
STAT limit_maxbytes 536870912
STAT accepting_conns 1
STAT listen_disabled_num 0
STAT threads 4
STAT conn_yields 0
STAT hash_power_level 16
STAT hash_bytes 524288
STAT hash_is_expanding 0
STAT expired_unfetched 0
STAT evicted_unfetched 0
STAT bytes 0
STAT curr_items 0
STAT total_items 0
STAT evictions 0
STAT reclaimed 0
END



3) memcached client ¼³Ä¡

$ cd /usr/local/src
$ wget http://pecl.php.net/get/memcache-2.2.6.tgz
$ tar xvfzp memcache-2.2.6.tgz
$ cd memcache-2.2.6
$ /usr/local/php-fpm/bin/phpize
$ ./configure --with-php-config=/usr/local/php-fpm/bin/php-config
$ make
$ make install
$ vi /usr/local/php-fpm/lib/php.ini
extension_dir = "/usr/local/php-fpm/lib/php/extensions/no-debug-non-zts-20060613"
extension="memcache.so"
°ª Ãß°¡
$ /etc/init.d/php-fpm stop
$ /etc/init.d/nginx stop
$ /etc/init.d/php-fpm start
$ /etc/init.d/nginx start

ÀÛ¾÷ÀÌ ¿Ï·á µÇ¾úÀ¸¸é, phpinfo »ó¿¡ memcache °¡ Á¤»óÀûÀ¸·Î ¿Ã¶ó¿ÍÀÖ´ÂÁö È®ÀÎÇÑ´Ù.


À§¿Í °°ÀÌ ³ª¿À¸é Á¤»óÀûÀ¸·Î µÈ °ÍÀÌ´Ù.



 
 

Total 78
¹øÈ£ Á¦   ¸ñ ±Û¾´ÀÌ ³¯Â¥ Á¶È¸
33 ¿À¶óŬ Æú´õ ÆÛ¹Ì¼Ç ½ÑÀ¥È£½ºÆà 11-18 18859
32 Alteon L4½ºÀ§Ä¡ configuration ÃʱâÈ­ ¹× Dump ÀýÂ÷ ½ÑÀ¥È£½ºÆà 11-28 36458
31 ¿À¶óŬ ij¸¯ÅÍ ¼Â(CHARACTER SET) º¯°æÇϱâ(9i) ½ÑÀ¥È£½ºÆà 11-29 24375
30 Subversion/Trac ¹é¾÷ ¹× º¹±¸ ½ÑÀ¥È£½ºÆà 11-30 29655
29 SQL Server 2005¿¡¼­ DBCC SHRINKFILE ¹®À» »ç¿ëÇÏ¿© Æ®·£Àè¼Ç ¡¦ ½ÑÀ¥È£½ºÆà 12-07 22226
28 MySQL ·Î±×ÆÄÀÏ Á¤¸®Çϱ⠽ÑÀ¥È£½ºÆà 12-26 20768
27 php ÄÄÆÄÀϽà Cannot find libmysqlclient_r ¿À·ù ¹ß»ý.. ½ÑÀ¥È£½ºÆà 01-03 18889
26 [¸®´ª½º/NGINX] CentOs 5.7 64bit ¿¡¼­ NGINX + PHP + MYSQL + m¡¦ ½ÑÀ¥È£½ºÆà 01-13 83975
25 CentOS - Apache + SVN + Trac ¿¬µ¿ ½ÑÀ¥È£½ºÆà 02-16 196552
24 HP¼­¹ö Çϵåµð½ºÅ©ÀÇ »óź¸±â ½ÑÀ¥È£½ºÆà 02-20 71032
23 HP ProLiant ¼­¹ö¿¡ RAID 1À¸·Î Ubuntu 10.4 LTS , HP Sotware ¡¦ ½ÑÀ¥È£½ºÆà 02-22 51186
22 29Trac & Subversion ¹é¾÷ ¹× º¹±¸ ½ÑÀ¥È£½ºÆà 02-24 18039
21 CentOS 5.5 VNC ¼³Á¤ ¹× »ç¿ë¹æ¹ý (1) ½ÑÀ¥È£½ºÆà 03-28 131347
20 ¸®´ª½º ƯÁ¤ ³¯Â¥ ÀÌÈÄ º¯°æ ÆÄÀÏ Ã£±â ½ÑÀ¥È£½ºÆà 03-31 18962
19 Trac ¼³Ä¡ ¹× ¼³Á¤ ¸Þ´º¾ó ½ÑÀ¥È£½ºÆà 05-07 108948
 1  2  3  4  5  6