{"id":1059,"date":"2010-02-27T11:56:00","date_gmt":"2010-02-27T03:56:00","guid":{"rendered":"\/?p=1059"},"modified":"2010-02-27T11:56:00","modified_gmt":"2010-02-27T11:56:00","slug":"1059","status":"publish","type":"post","link":"https:\/\/blog.vimge.com\/archives\/linux\/1059.html","title":{"rendered":"\u8f7b\u677e\u641e\u5b9aCentOS+Nginx+PHP+MySQL\u6807\u51c6\u751f\u4ea7\u73af\u5883"},"content":{"rendered":"

PHP 5.3.1<\/p>\n

MySQL 5.0.89<\/p>\n

Nginx 0.8.33 \u6216 0.7.65 \uff08\u53ef\u9009\uff09<\/p>\n

\u8fd9\u4e2a\u53ef\u6bd4\u7f51\u4e0a\u6d41\u4f20\u7684\u4ec0\u4e48\u4e00\u952e\u5b89\u88c5\u5305\u8981\u597d\u5f97\u591a\uff0c\u5f3a\u70c8\u63a8\u8350\u6b64\u6cd5\u5b89\u88c5\uff0c\u9002\u5408\u6240\u6709\u83dc\u9e1f\u548c\u9ad8\u624b\u3002\u6211\u670d\u52a1\u5668\u4e0a\u5168\u7528\u7684\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\uff0c\u4e5f\u597d\u4e0d\u5230\u54ea\u53bb\uff0c\u8fd8\u5f88\u8d39\u52b2\u3002\u6211\u8fd9\u4e2a\u88c5\u5b8c\u5df2\u7ecf\u5305\u542b php \u7684\u4e00\u4e9b\u5e38\u7528\u6269\u5c55\uff0c PDO\uff0ceaccelerator\uff0cmemcache\uff0ctidy\u7b49\u7b49\u3002<\/p>\n

CentOS \u6700\u5c0f\u5316\u5b89\u88c5\uff0c\u7136\u540e\u5148\u65b0\u5efa\u4e00\u4e2a repo<\/p>\n

# vi \/etc\/yum.repos.d\/centos.21andy.com.repo<\/p>\n

\u653e\u5165\u5982\u4e0b\u5185\u5bb9<\/p>\n\n\n\n
[21Andy.com]
name=21Andy.com Packages for Enterprise Linux 5 – $basearch
baseurl=http:\/\/www.21andy.com\/centos\/5\/$basearch\/
enabled=1
gpgcheck=0
protect=1<\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u542f\u7528 EPEL repo<\/p>\n

CentOS i386 \u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/p>\n

rpm -ihv http:\/\/download.fedora.redhat.com\/pub\/epel\/5\/i386\/epel-release-5-3.noarch.rpm<\/a><\/p>\n

CentOS x86_64 \u8f93\u5165\u5982\u4e0b\u547d\u4ee4<\/p>\n

rpm -ihv http:\/\/download.fedora.redhat.com\/pub\/epel\/5\/x86_64\/epel-release-5-3.noarch.rpm<\/a><\/p>\n

\u7136\u540e\u5bfc\u5165key<\/p>\n

rpm –import \/etc\/pki\/rpm-gpg\/RPM-GPG-KEY-EPEL<\/p>\n

\u590d\u5236\u4ee3\u7801<\/p>\n

OK\uff0c\u4e00\u952e\u5b89\u88c5\u5427<\/p>\n\n\n\n
yum -y install nginx mysql-server php-fpm php-cli php-pdo php-mysql php-mcrypt php-mbstring php-gd php-tidy php-xml php-xmlrpc php-pear php-pecl-memcache php-eaccelerator<\/font><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n

\u6700\u540e yum -y update \u4e00\u4e0b\uff0c\u5168\u662f\u6700\u65b0\u7684<\/p>\n

\u5982\u679c nginx \u4f60\u8981\u7528 0.7.65 \u6700\u65b0\u7a33\u5b9a\u7248\uff0c\u628a<\/p>\n

yum -y install nginx<\/p>\n

\u6362\u6210<\/p>\n

yum -y install nginx-stable<\/p>\n

\u5c31\u53ef\u4ee5\u4e86<\/p>\n

\u88c5\u5b8c\u4f60\u5df2\u7ecf\u53ef\u4ee5\u8fd9\u6837\u73a9\u4e86<\/p>\n

service mysqld start<\/p>\n

service php-fpm start<\/p>\n

service nginx start<\/p>\n

\u522b\u5fd8\u4e86\u8bbe\u7f6e\u5f00\u673a\u542f\u52a8<\/p>\n

chkconfig –level 345 mysqld on<\/p>\n

chkconfig –level 345 php-fpm on<\/p>\n

chkconfig –level 345 nginx on<\/p>\n

\u914d\u7f6e\u6587\u4ef6\u90fd\u5728 \/etc \u4e0b\u81ea\u5df1\u627e<\/p>\n

\u770b\u770b\u5b89\u88c5\u591a\u81ea\u52a8<\/p>\n\n\n\n
\n

  <\/font>Dependencies Resolved<\/font><\/p>\n

   ==========================================================
   Package Arch Version Repository Size
   ==========================================================
   Installing:
   mysql x86_64 5.0.89-1.el5 21Andy.com 3.5 M
   mysql-server x86_64 5.0.89-1.el5 21Andy.com 10 M
   nginx x86_64 0.8.33-3.el5 21Andy.com 422 k
   php-cli x86_64 5.3.1-2.el5 21Andy.com 2.4 M
   php-eaccelerator x86_64 2:0.9.6-1.el5 21Andy.com 118 k
   php-fpm x86_64 5.3.1-2.el5 21Andy.com 1.2 M
   php-gd x86_64 5.3.1-2.el5 21Andy.com 110 k
   php-mbstring x86_64 5.3.1-2.el5 21Andy.com 1.1 M
   php-mcrypt x86_64 5.3.1-2.el5 21Andy.com 27 k
   php-mysql x86_64 5.3.1-2.el5 21Andy.com 84 k
   php-pdo x86_64 5.3.1-2.el5 21Andy.com 91 k
   php-pear noarch 1:1.9.0-1.el5 21Andy.com 420 k
   php-pecl-memcache x86_64 2.2.5-3.el5 21Andy.com 44 k
   php-tidy x86_64 5.3.1-2.el5 21Andy.com 31 k
   php-xml x86_64 5.3.1-2.el5 21Andy.com 115 k
   php-xmlrpc x86_64 5.3.1-2.el5 21Andy.com 48 k
   Installing for dependencies:
   gmp x86_64 4.1.4-10.el5 base 201 k
   libXaw x86_64 1.0.2-8.1 base 329 k
   libXmu x86_64 1.0.2-5 base 63 k
   libXpm x86_64 3.5.5-3 base 44 k
   libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
   libmcrypt x86_64 2.5.8-4.el5.centos extras 105 k
   libtidy x86_64 0.99.0-14.20070615.el5 epel 140 k
   php-common x86_64 5.3.1-2.el5 21Andy.com 554 k
   sqlite2 x86_64 2.8.17-5.el5 21Andy.com 165 k
   t1lib x86_64 5.1.1-7.el5 epel 208 k
   Updating for dependencies:
   libevent x86_64 1.4.12-1.el5 21Andy.com 129 k<\/font><\/p>\n

   Transaction Summary
   ==========================================================
   Install 26 Package(s)
   Update 1 Package(s)
   Remove 0 Package(s)<\/font> <\/font><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/p>\n

\u4ee5\u4e0b\u5206\u522b\u6d4b\u8bd5\u6211\u672c\u5730\u7684\u865a\u62df\u673a\u548c VPS \u4e0a Nginx + php-fpm \u7684\u6027\u80fd<\/p>\n

\u6211\u7684\u672c\u673a\u865a\u62df\u673a\u6d4b\u8bd5\uff0c\u914d\u7f6e\u4e3aPD930 \u53cc\u68383.0G\uff0c2G\u5185\u5b58\uff0c\u7ed9\u865a\u62df\u673a\u5206\u914d\u7684\u662f 1G \u5185\u5b58\uff0c\u5b89\u88c5\u7684\u7cfb\u7edf\u4e3a CentOS 5.4 64bit<\/font><\/strong><\/p>\n

\u6d4b\u8bd5\u5185\u5bb9\u4e3a<\/strong><\/p>\n

\n
<?php phpinfo();?><\/div>\n<\/div>\n

500 <\/font><\/strong>\u5e76\u53d1\u6d4b\u8bd5\uff0cCPU\u4f7f\u7528\u7387\u5230\u4e8630%\uff0c\u7cfb\u7edf\u8d1f\u8f7d\u572810<\/font><\/strong>\u5de6\u53f3\uff0c\u9875\u9762\u6253\u5f00\u8fd8\u662f\u98de\u5feb<\/p>\n

\n

[root@localhost ~]# webbench -c 500 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/
500 clients, running 30 sec.<\/p>\n

Speed=223504 pages\/min<\/font><\/strong>, 21806556 bytes\/sec.
Requests: 111752 susceed, 0 failed.<\/p>\n<\/blockquote>\n

2000 <\/font><\/strong>\u5e76\u53d1\u6d4b\u8bd5\uff0cCPU\u4f7f\u7528\u738735%\uff0c\u7cfb\u7edf\u8d1f\u8f7d\u572818<\/font><\/strong>\u5de6\u53f3\uff0c\u9875\u9762\u6253\u5f00\u8fd8\u662f\u98de\u5feb<\/p>\n

\n

[root@localhost ~]# <\/font>webbench -c 2000 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/
2000 clients, running 30 sec.<\/p>\n

Speed=429494 pages\/min<\/font><\/strong>, 39004788 bytes\/sec.
Requests: 214747 susceed, 0 failed.<\/p>\n<\/blockquote>\n

5000 <\/font><\/strong>\u5e76\u53d1\u6d4b\u8bd5\uff0cCPU\u4f7f\u7528\u738730%\uff0c\u7cfb\u7edf\u8d1f\u8f7d\u5230\u4e8635<\/font><\/strong>\uff0c\u9875\u9762\u6253\u8fd8\u901f\u5ea6\u8fd8\u4e0d\u9519\uff0c\u770b\u4e86\u8fd9\u6570\u636e\uff0c\u524d\u4e9b\u5929\u8bf4\u7684\u90a3\u4e2a1500\u4e07PHP\u8bf7\u6c42\u4e5f\u6ca1\u5565\u4e86<\/p>\n

\n

[root@localhost ~]# webbench -c 5000 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/
5000 clients, running 30 sec.<\/p>\n

Speed=788986 pages\/min<\/font><\/strong>, 66952700 bytes\/sec.
Requests: 394493 susceed, 0 failed.<\/p>\n<\/blockquote>\n

\u8fd8\u4e0d\u8fc7\u763e\uff0c\u53d8\u6001\u4e00\u4e0b\uff0c10000\u5e76\u53d1<\/p>\n

10000 <\/font><\/strong>\u5e76\u53d1\uff0cCPU\u4f7f\u7528\u8fd8\u662f\u4e0d\u523030%\uff0c\u7cfb\u7edf\u8d1f\u8f7d\u4ece60<\/font><\/strong>\u5de6\u53f3\u4e00\u76f4\u5347\u52301000<\/font><\/strong>\u5de6\u53f3\uff0c\u6655\u6b7b\uff01\u5c45\u7136\u8fd8\u80fd\u6253\u5f00\uff01\u53ea\u662f\u6709\u70b9\u5361\uff01\u8d1f\u8f7d\u5230600<\/font><\/strong>\u591a\u7684\u65f6\u5019\u5c45\u7136\u4e0d\u5361\uff01\u75af\u4e86\uff0c\u6211\u8fd9\u8fd8\u662f\u865a\u62df\u673a\uff0cwebbench \u8fd8\u662f\u5728\u81ea\u5df1\u673a\u4e0a\u5f00\u7684\uff0c\u6c57\uff0c\u592a\u5f3a\u4e86<\/p>\n

\n

[root@localhost ~]# webbench -c 10000 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/
10000 clients, running 30 sec.<\/p>\n

Speed=1513718 pages\/min<\/font><\/strong>, -17973622 bytes\/sec.
Requests: 756859 susceed, 0 failed.<\/p>\n<\/blockquote>\n

\u800c\u6211\u7684 VPS , 2G\u5185\u5b58\uff0c8\u6838CPU\u6d4b\u8bd5\uff0c\u4f46\u6211\u4e0d\u662f\u4f7f\u7528\u4e0a\u9762\u7684 yum \u5b89\u88c5\uff0c\u800c\u662f\u5168\u7528\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\u7684\uff0c\u6d4b\u8bd5\u7ed3\u679c\u5982\u4e0b\uff1a<\/p>\n

500\u5e76\u53d1\uff0cCPU\u4f7f\u7528\u738720%\uff0c\u8d1f\u8f7d2\u5de6\u53f3<\/p>\n

\n

# webbench -c 500 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/index.php
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/index.php
500 clients, running 30 sec.<\/p>\n

Speed=120520 pages\/min<\/font><\/strong>, -36244332 bytes\/sec.
Requests: 60260 susceed, 0 failed.<\/p>\n<\/blockquote>\n

2000\u5e76\u53d1\uff0cCPU\u4f7f\u7528\u738720%\u5de6\u53f3\uff0c\u8d1f\u8f7d2\u5de6\u53f3\uff0c\u6ca1\u5565\u53d8\u5316<\/p>\n

\n

webbench -c 2000 -t 30<\/font> <\/font><\/strong>http:\/\/127.0.0.1\/index.php
Webbench – Simple Web Benchmark 1.5
Copyright (c) Radim Kolar 1997-2004, GPL Open Source Software.<\/p>\n

Benchmarking: GET http:\/\/127.0.0.1\/index.php
2000 clients, running 30 sec.<\/p>\n

Speed=111454 pages\/min<\/font><\/strong>, -44285944 bytes\/sec.
Requests: 55727 susceed, 0 failed.<\/p>\n<\/blockquote>\n

\u5f00\u52303000\u5e76\u53d1\u4e5f\u4e00\u6837\uff0c\u4f46\u6253\u5f00\u9875\u9762\u8981\u7b49\u51e0\u79d2\uff0c\u7a81\u7136\u4e00\u4e0b\u51fa\u6765\uff0c\u8bf4\u660e\u6211\u8fdb\u7a0b\u5f00\u5c11\u4e86\uff0c\u8fd8\u6709\u4f59\u5730\u3002<\/p>\n

\u73b0\u5728\u6211\u660e\u767d\u4e86\u524d\u51e0\u5929\u90a3\u4e2a1500\u4e07PHP\u8bf7\u6c42\u8fd8\u80fd\u7a33\u5b9a\u8bbf\u95ee\u662f\u600e\u4e48\u56de\u4e8b\u4e86\uff0c\u54c8\u54c8\uff0c\u4f60\u53ea\u8981CentOS 5.4 64bit\uff0c\u518d\u6309\u6211\u4e0a\u9762\u7684 yum \u65b9\u6cd5\u5b89\u88c5\uff0c\u4e5f\u4e00\u6837\u80fd\u9876\u4f4f\u3002<\/p>\n

\u539f\u6587\u5f15\u7528\uff1a<\/strong>http:\/\/www.21andy.com\/blog\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"

PHP 5.3.1<\/p>\n

MySQL 5.0.89<\/p>\n

Nginx 0.8.33 \u6216 0.7.65 \uff08\u53ef\u9009\uff09<\/p>\n

\u8fd9\u4e2a\u53ef\u6bd4\u7f51\u4e0a\u6d41\u4f20\u7684\u4ec0\u4e48\u4e00\u952e\u5b89\u88c5\u5305\u8981\u597d\u5f97\u591a\uff0c\u5f3a\u70c8\u63a8\u8350\u6b64\u6cd5\u5b89\u88c5\uff0c\u9002\u5408\u6240\u6709\u83dc\u9e1f\u548c\u9ad8\u624b\u3002\u6211\u670d\u52a1\u5668\u4e0a\u5168\u7528\u7684\u6e90\u4ee3\u7801\u7f16\u8bd1\u5b89\u88c5\uff0c\u4e5f\u597d\u4e0d\u5230\u54ea\u53bb\uff0c\u8fd8\u5f88\u8d39\u52b2\u3002\u6211\u8fd9\u4e2a\u88c5\u5b8c\u5df2\u7ecf\u5305\u542b php \u7684\u4e00\u4e9b\u5e38\u7528\u6269\u5c55\uff0c PDO\uff0ceaccelerator\uff0cmemcache\uff0ctidy\u7b49\u7b49\u3002<\/p>\n

CentOS \u6700\u5c0f\u5316\u5b89\u88c5\uff0c\u7136\u540e\u5148\u65b0\u5efa\u4e00\u4e2a repo<\/p>\n

# vi \/etc\/yum.repos.d\/centos.21andy.com.repo<\/p>\n

\u653e\u5165\u5982\u4e0b\u5185\u5bb9<\/p><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[8],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1059"}],"collection":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/comments?post=1059"}],"version-history":[{"count":0,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/posts\/1059\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/media?parent=1059"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/categories?post=1059"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.vimge.com\/wp-json\/wp\/v2\/tags?post=1059"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}