php 5.3.1
mysql 5.0.89
nginx 0.8.33 或0.7.65 (可選)
#這個可比網路上流傳的什麼一鍵安裝包包好得多,強烈推薦此法安裝,適合所有菜鳥和高手。我伺服器上全用的原始碼編譯安裝,也好不到哪裡去,還很費勁。我這個裝完已經包含 php 的一些常用擴展, pdo,eaccelerator,memcache,tidy等等。
centos 最小化安裝,然後先新建一個repo
# vi /etc/yum.repos.d/centos.21andy.com.repo
#放入如下內容
[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
啟用epel repo
centos i386 輸入以下指令
#rpm -ihv http:// download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-3.noarch.rpm
centos x86_64 輸入以下指令
##rpm -ihv http:/ /download.fedora.redhat.com/pub/epel/5/x86_64/epel-release-5-3.noarch.rpm##然後導入key
#rpm --import /etc/ pki/rpm-gpg/rpm-gpg-key-epel
複製程式碼
#ok,一鍵安裝吧
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
最後yum -y update 一下,全是最新的
如果nginx 你要用0.7.65 最新穩定版,把
yum -y install nginx
換成
yum -y install nginx-stable
就可以了
裝完你已經可以這樣玩了
service mysqld start
service php-fpm start
service nginx start
別忘了設定開機啟動
chkconfig --level 345 mysqld on
chkconfig --level 345 php-fpm on
chkconfig --level 345 nginx on
設定檔都在/etc 下自己找
看看安裝多自動
dependencies resolved
# ================================================= =========
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 42226_64 0.8.33-3.el5 21andy.com 422226_64 0.8.33-3.el5 21andy.com 422226_64 0.8.33-3.el5 21andy.com 42226_64 0.8.33-3.8 x 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-andy.5 5 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##卷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#1. .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
php-tidy x86_64 5.3.1
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 48c x86_64 5.3.1-2.el5 21andy.com 48c x86_64 5.3.1-2.el5 21.com 48c x86_64 5.3. 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 # libxmu x86_64 1.0.2-5 # libxmu x86_64 1.0.2-5 # 44 k
libedit x86_64 2.11-2.20080712cvs.el5 epel 80 k
libmcrypt x86_64 2.5.8-4.el5.centos extraslibmcrypt x86_64 2.5.8-4.el5.centos extras 105 k0105 15.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##el#of t1lib x86_6455. updating for dependencies:
libevent x86_64 1.4.12-1.el5 21andy.com 129 k
# transaction summary
================== ========================================
install 26 package(s)
update 1 package(s)
remove 0 package(s)
以下分別測試我本地的虛擬機器和vps 上nginx php-fpm 的效能
#我的本機和vps 上nginx php-fpm 的效能
#我的本機和vps 上nginx php-fpm
我的本機和vps 上nginx php-fpm 的效能
#虛擬機器測試,配置為pd930 雙核心3.0g,2g內存,分配給虛擬機器的是1g 內存,安裝的系統為
測試內容為
#500
並發測試,cpu使用率到了30%,系統負載在
10左右,頁面開啟還是快速 [root@localhost ~]# webbench -c 500 -t 30 http://127.0.0.1/ benchmarking: get http://127.0.0.1/ speed=##223504 pages/min, 21806556 bytes/sec. 2000 並發測試,cpu使用率35%,系統負載在18左右,頁面開啟還是飛快 [root@localhost ~]# webbench -c 2000 -t 30 http://127.0.0.1 / benchmarking: get http://127.0.0.1/#cli#2000 #cli#ents , running 30 sec. 429494 pages/min, 39004788 bytes/sec.requests: 214747 susceed, 0 failed. 5000 並發測試,cpu使用率30%,系統負載到了35,頁面打還速度還不錯,看了這數據,前些天說的那個1500萬php請求也沒啥了 webbench -c 5000 -t 30 http://127.0.0.1/webbench - simple web benchmark 1.5 5000 clients, running 30 sec. 788986 pages/min, 66952700 bytes/sec.requests: 394493 susceed, 0 failed. #10000 並發,cpu使用或不到30%,系統負載從60左右一直升到1000左右,暈死!居然還能打開!只是有點卡!負載到600多的時候居然不卡!瘋了,我這還是虛擬機,webbench 還是在自己機上開的,汗,太強了 webbench -c 10000 -t 30 http://127.0.0.1/webbench - simple web benchmark 1.5 10000 clients, running 30 sec. 1513718 pages/min, -17973622 bytes/sec.requests: 756859 susceed, 0 failed. 而我的vps , 2g內存,8核cpu測試,但我不是使用上面的yum 安裝,而是全用源代碼編譯安裝的,測試結果如下: 500並發,cpu使用率20%,負載2左右 # webbench -c 500 -t 30 http://127.0.0.1/index.php benchmarking: get http://127.0.0.1/index.php speed=120520 pages/min, -36244332 bytes/sec. 2000並發,cpu使用率20%左右,負載2左右,沒啥變化 webbench -c 2000 -t 30 http://127.0.0.1/index.php benchmarking: get http://127.0.0.1/index.php speed=111454 pages/min, -44285944 bytes/sec.
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.
500 clients, running 30 sec.
requests: 111752 susceed, 0 failed.
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.[root@localhost ~]#
還不過癮,變態一下,10000並發
copyright (c) radim kolar 1997-2004, gpl open source software.[root@localhost ~]#
copyright (c) radim kolar 1997-2004, gpl open source software.
requests: 756859 susceed, 0 failed.
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.
500 clients, running 30 sec.
requests: 60260 susceed, 0 failed.
webbench - simple web benchmark 1.5
copyright (c) radim kolar 1997-2004, gpl open source software.
##benchmarking: get http://127.0.0.1/index.php#cli#2000 ; , running 30 sec.
requests: 55727 susceed, 0 failed.
以上是CentOS+Nginx+PHP+MySQL標準生產環境如何配置的詳細內容。更多資訊請關注PHP中文網其他相關文章!