分类目录归档:Linux

install php zend optimizer with yum on centos

Contents: atomic.repo

# Name: Atomic Rocket Turtle RPM Repository for CentOS / Red Hat Enterprise Linux 5 –
# URL: http://www.atomicrocketturtle.com/
[atomic]
name = CentOS / Red Hat Enterprise Linux $releasever – atomicrocketturtle.com
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic/centos-5-$basearch
#mirrorlist = http://www.atomicorp.com/channels/atomic/centos/5/mirrors-atomic
enabled = 1
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1

# Almost Stable, release candidates for [atomic]
[atomic-testing]
name = CentOS / Red Hat Enterprise Linux $releasever – atomicrocketturtle.com – (Testing)
mirrorlist = http://www.atomicorp.com/mirrorlist/atomic-testing/centos-5-$basearch
enabled = 0
priority = 1
protect = 0
gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
gpgcheck = 1

# Untested, Unstable, known buggy, and incomplete packages.
#[atomic-bleeding]
#name = CentOS / Red Hat Enterprise Linux $releasever – atomicrocketturtle.com – (Bleeding)
#baseurl = http://www.atomicorp.com/channels/atomic-bleeding/centos/5/$basearch/
#enabled = 0
#priority = 1
#protect = 0
#gpgkey = file:///etc/pki/rpm-gpg/RPM-GPG-KEY.art.txt
#gpgcheck = 1

yum install php-zend-optimizer

解决Apache的Mod_Security和svn模块冲突

今天svn突然不能提交了,给777都没用,一直报错

Command: Commit
Error: Commit failed (details follow):
Error: access to ‘/!svn/vcc/default’ forbidden
Finished!:

Google了好一阵子,解决方案如下:

在svn对应的虚拟主机的</VirtualHost>之前插入这样一段

<IfModule mod_security2.c>
SecRuleRemoveByID 960032
SecRuleRemoveByID 960015
SecRuleRemoveByID 960904
SecRuleRemoveByID 960010
SecRuleRemoveByID 960035
SecRule REQUEST_METHOD “^(PROPFIND|PROPPATCH)$” allow
SecRule REQUEST_METHOD “^(REPORT|OPTIONS)$” allow
SecRule REQUEST_METHOD “^(MKACTIVITY|CHECKOUT)$” allow
SecRule REQUEST_METHOD “^(PUT|DELETE|MERGE)$” allow
SecRule REQUEST_METHOD “^(MKCOL)$” allow
</IfModule>

完成后重启apache就可以了。

原因:mod_security过于严格=。-

多级缓存架构相当的给力

Mon.itor.us的检测结果表明,我的烂博客首页加载速度已经稳定在100ms左右的- –
目前博客逻辑架构是这样的:
前端:squid,跑在直连网通的xeex网络后,硬件是个小vps,128内存,xen架构,2G/150G,6刀一个月
后端:nginx反代httpd,同时nginx做部分静态文件服务器,硬件同样是个小vps,256内存,openvz架构,25G/250G,4刀一个月
数据库:mysqld,跑在上面那个256内存的vps上。
整个架构:squid>nginx>httpd>mysqld
用ab跑100个并发测试打开1000次首页,10多秒钟就搞定,服务器负载最多时候到了1- –
monitorus检测结果:
Test HTTP johnliu.info_http
12:23 676 OK US
12:53 105 OK US
13:23 116 OK US
13:53 1052 OK US
14:23 766 OK US
14:53 98 OK US
15:23 89 OK US
参考:
www.google.com_http 29

ab结果:
Server Software: nginx/0.8.53
Server Hostname: johnliu.info
Server Port: 80

Document Path: /others/kuai_fan_yuan_quakkfan_chong_xin_fa_bu/
Document Length: 15534 bytes

Concurrency Level: 100
Time taken for tests: 19.676012 seconds
Complete requests: 1000
Failed requests: 980
(Connect: 0, Length: 980, Exceptions: 0)
Write errors: 0
Total transferred: 16043778 bytes
HTML transferred: 15577247 bytes
Requests per second: 50.82 [#/sec] (mean)
Time per request: 1967.601 [ms] (mean)
Time per request: 19.676 [ms] (mean, across all concurrent requests)
Transfer rate: 796.25 [Kbytes/sec] received

Connection Times (ms)
min mean[+/-sd] median max
Connect: 11 90 98.4 96 3011
Processing: 32 1787 1663.1 1327 9043
Waiting: 11 252 340.5 110 1906
Total: 62 1878 1642.5 1420 9060

Percentage of the requests served within a certain time (ms)
50% 1420
66% 1565
75% 1663
80% 1791
90% 5181
95% 6338
98% 7419
99% 7650
100% 9060 (longest request)

几只VPS的Unix Benchmark跑分结果

最近在选择vps上折腾的很惨,还遇到莫名其妙的数据丢失,幸好有backup,只丢失了不到3天的数据,今天有点时间,就把自己能控制的5只vps拖出来遛遛,跑了下分。

unix benchmark download here: http://members.dslextreme.com/users/andylee/unixbench-4.1.0-wht.tar.gz

排名不分先后- –

1.PhotonVps的 warp.5, Xen,128内存,2G/150G,equal share CPU*2,5.96 USD/M

BYTE UNIX Benchmarks (Version 4.1-wht.2)
System — Linux xx 2.6.18-164.10.1.el5xen #1 SMP Thu Jan 7 20:28:30 EST 2010 x86_64 x86_64 x86_64 GNU/Linux
/dev/sda1              2064208   1402560    556792  72% /

Start Benchmark Run: Wed Dec  8 17:09:26 CST 2010
17:09:26 up 18:28,  1 user,  load average: 0.76, 0.38, 0.15

End Benchmark Run: Wed Dec  8 17:20:11 CST 2010
17:20:12 up 18:39,  1 user,  load average: 15.18, 6.62, 2.98

INDEX VALUES
TEST                                        BASELINE     RESULT      INDEX

Dhrystone 2 using register variables        376783.7 11209023.1      297.5
Double-Precision Whetstone                      83.1     1232.6      148.3
Execl Throughput                               188.3     2877.5      152.8
File Copy 1024 bufsize 2000 maxblocks         2672.0    71659.0      268.2
File Copy 256 bufsize 500 maxblocks           1077.0    20144.0      187.0
File Read 4096 bufsize 8000 maxblocks        15382.0   646709.0      420.4
Pipe Throughput                             111814.6   418053.8       37.4
Pipe-based Context Switching                 15448.6   135425.6       87.7
Process Creation                               569.3     6445.8      113.2
Shell Scripts (8 concurrent)                    44.8      807.1      180.2
System Call Overhead                        114433.5   487160.8       42.6
=========
FINAL SCORE                                                     140.0

2.AlienVPS的UFO1,OpenVZ,256内存,25G/250G,633.352Mhz CPU*4,4USD/M
BYTE UNIX Benchmarks (Version 4.1-wht.2)
System — Linux xxxx 2.6.18-194.26.1.el5.028stab070.14 #1 SMP Thu Nov 18 16:34:01 MSK 2010 i686 i686 i386 GNU/Linux
/dev/simfs            26214400    826760  25387640   4% /

Start Benchmark Run: Wed Dec  8 12:09:39 MSK 2010
12:09:39 up 17:59,  1 user,  load average: 0.31, 0.17, 0.06

End Benchmark Run: Wed Dec  8 12:23:33 MSK 2010
12:23:33 up 18:13,  1 user,  load average: 11.43, 5.49, 2.73

INDEX VALUES
TEST                                        BASELINE     RESULT      INDEX

Dhrystone 2 using register variables        376783.7  4801749.6      127.4
Double-Precision Whetstone                      83.1     1265.4      152.3
Execl Throughput                               188.3     3901.9      207.2
File Copy 1024 bufsize 2000 maxblocks         2672.0   110789.0      414.6
File Copy 256 bufsize 500 maxblocks           1077.0    57634.0      535.1
File Read 4096 bufsize 8000 maxblocks        15382.0   864323.0      561.9
Pipe-based Context Switching                 15448.6   230704.3      149.3
Pipe Throughput                             111814.6   745289.8       66.7
Process Creation                               569.3    11623.7      204.2
Shell Scripts (8 concurrent)                    44.8      566.3      126.4
System Call Overhead                        114433.5   617815.2       54.0
=========
FINAL SCORE                                                     181.3

3.PhotonVPS的WARP 2,XEN,1024内存,50G/900G,equal share CPU*8,26USD/M

BYTE UNIX Benchmarks (Version 4.1-wht.2)
System — Linux xxxxxx 2.6.18-194.11.3.el5xen #1 SMP Mon Aug 30 16:55:32                                                                                                             EDT 2010 x86_64 GNU/Linux
/dev/sda1             51606140   2336820  46647880   5% /

Start Benchmark Run: Wed Dec  8 17:14:26 CST 2010
17:14:26 up 21:14,  4 users,  load average: 0.08, 0.02, 0.01

End Benchmark Run: Wed Dec  8 17:24:46 CST 2010
17:24:46 up 21:25,  4 users,  load average: 15.14, 6.49, 2.84

INDEX VALUES
TEST                                        BASELINE     RESULT      INDEX

Dhrystone 2 using register variables        376783.7 16047095.6      425.9
Double-Precision Whetstone                      83.1     1227.7      147.7
Execl Throughput                               188.3     4436.1      235.6
File Copy 1024 bufsize 2000 maxblocks         2672.0   142113.0      531.9
File Copy 256 bufsize 500 maxblocks           1077.0    41767.0      387.8
File Read 4096 bufsize 8000 maxblocks        15382.0  1397184.0      908.3
Pipe Throughput                             111814.6  1011631.5       90.5
Pipe-based Context Switching                 15448.6   248391.6      160.8
Process Creation                               569.3    12219.2      214.6
Shell Scripts (8 concurrent)                    44.8     2136.9      477.0
System Call Overhead                        114433.5   965631.9       84.4
=========
FINAL SCORE                                                     258.8

4.TP的某VPS,未知架构,1024内存,60G/xxG,equal share CPU*8,50USD/M左右

跑分过程中掉线一次,restart再次掉线,第三次成功

BYTE UNIX Benchmarks (Version 4.1-wht.2)
System — Linux xxxxxxxxx 2.6.18-194.17.4.el5 #1 SMP Mon O                                                                                                            ct 25 15:51:07 EDT 2010 i686 i686 i386 GNU/Linux
/dev/hda3             59871508   2880884  53909124   6% /

Start Benchmark Run: Wed Dec  8 04:43:33 CST 2010
04:43:33 up 10 days,  1:38,  2 users,  load average: 0.83, 0.31, 0.75

End Benchmark Run: Wed Dec  8 04:54:18 CST 2010
04:54:18 up 10 days,  1:49,  1 user,  load average: 14.49, 6.31, 3.17

INDEX VALUES
TEST                                        BASELINE     RESULT      INDEX

Dhrystone 2 using register variables        376783.7 12468250.3      330.9
Double-Precision Whetstone                      83.1     1301.4      156.6
Execl Throughput                               188.3     6711.3      356.4
File Copy 1024 bufsize 2000 maxblocks         2672.0    95072.0      355.8
File Copy 256 bufsize 500 maxblocks           1077.0    36518.0      339.1
File Read 4096 bufsize 8000 maxblocks        15382.0  1170137.0      760.7
Pipe-based Context Switching                 15448.6   366710.1      237.4
Pipe Throughput                             111814.6   982225.3       87.8
Process Creation                               569.3    20016.5      351.6
Shell Scripts (8 concurrent)                    44.8     1408.5      314.4
System Call Overhead                        114433.5  1446043.0      126.4
=========
FINAL SCORE                                                     267.1

5.Amazon的EC2 Micro Instance,XEN,7864内存,50G/900G,equal share 2659.99Mhz *1,1USD/M左右(省省跑可以免费用的,就是到国内的网络太糟糕了)

BYTE UNIX Benchmarks (Version 4.1-wht.2)
System — Linux xxxxxx 2.6.16-xenU #1 SMP Mon May 28 03:41:49 SAST 2007                                                                                                             i686 i686 i386 GNU/Linux
/dev/sda1             10321208   5017136   4779784  52% /

Start Benchmark Run: Wed Dec  8 17:15:46 CST 2010
17:15:46 up 6 days, 19:10,  1 user,  load average: 0.08, 0.02, 0.01

End Benchmark Run: Wed Dec  8 17:37:16 CST 2010
17:37:16 up 6 days, 19:31,  1 user,  load average: 15.04, 7.11, 3.96

INDEX VALUES
TEST                                        BASELINE     RESULT      INDEX

Dhrystone 2 using register variables        376783.7  3913846.7      103.9
Double-Precision Whetstone                      83.1     1502.8      180.8
Execl Throughput                               188.3     1176.4       62.5
File Copy 1024 bufsize 2000 maxblocks         2672.0     2082.0        7.8
File Copy 256 bufsize 500 maxblocks           1077.0    10448.0       97.0
File Read 4096 bufsize 8000 maxblocks        15382.0    10464.0        6.8
Pipe Throughput                             111814.6   365033.6       32.6
Pipe-based Context Switching                 15448.6     3227.7        2.1
Process Creation                               569.3      105.6        1.9
Shell Scripts (8 concurrent)                    44.8       12.0        2.7
System Call Overhead                        114433.5   284563.4       24.9
=========
FINAL SCORE                                                      17.6
(不得不说便宜没好货,贵的不一定好)

5分钟完成配置CentOS+Apache+MySQL+PHP5+Webmin+PPTP VPN+Subversion+etc

嗯,今天实在不知道的写什么,就只有把老本拿出来了:自己折腾了N台vps后整理出的快速配置centos的脚本,只要打开terminal一行行的粘进去回车就完事。
正常情况下是可以在5分钟内完成一台新vps的配置的,如果遇到非正常情况。。就。。。。。。
跑poptopd的前提是你的vps是xen架构,否则免谈

#安装epel+rpmforge
rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
wget http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt http://quattor.web.lal.in2p3.fr/packages/os/sl520-x86_64/base/RPM-GPG-KEYs/RPM-GPG-KEY-CentOS-5 http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.i386.rpm
rpm –import RPM-GPG-KEY.dag.txt
rpm –import RPM-GPG-KEY-CentOS-5
rpm -Uhv rpmforge-release-0.5.1-1.el5.rf.i386.rpm

#更新系统
yum -y update
yum -y upgrade
#install php 5.2+ on centos5
vim /etc/yum.repos.d/CentOS-Testing.repo

[c5-testing]
name=CentOS-5Testing
baseurl=http://dev.centos.org/centos/$releasever/testing/$basearch/
enabled=1
gpgcheck=1
gpgkey=http://dev.centos.org/centos/RPM-GPG-KEY-CentOS-testing
includepkgs=php*

#安装lamp和subversion+其他一些东西
yum -y install perl-Net-SSLeay gcc-c++ patch zlib-devel openssl-devel readline-devel mysql-devel mysql-server httpd-devel apr-devel iptables php-common php-gd php-mcrypt php-pear php-mhash php-mysql php-xml php-mbstring traceroute bind-utils setuptool mod_dav_svn subversion sqlite-devel ntp

#poptopd pptp vpn server
rpm -Uvh http://poptop.sourceforge.net/yum/stable/fc7/pptp-release-current.noarch.rpm
yum -y –enablerepo=poptop-stable install pptpd

vim /etc/pptpd.conf (修改localip、remoteip)
vim /etc/ppp/options (修改ms-dns),
vim /etc/ppp/chap-secrets (创建用户名、密码,指定ip)
vim /etc/sysctl.conf
#修改
net.ipv4.ip_forward = 1
echo 1 > /proc/sys/net/ipv4/ip_forward
iptables -t nat -A POSTROUTING -s 内网ip段(eg. 192.168.100.0/24) -j SNAT –to 服务器的任意ip(eg. 1.2.3.4)
/etc/init.d/iptables save
/etc/init.d/iptables restart

#webmin图形化的web管理界面,减少命令行的折腾程度
wget http://prdownloads.sourceforge.net/webadmin/webmin-1.520-1.noarch.rpm
rpm -i webmin-1.520-1.noarch.rpm

#subversion
svnadmin create /path/to/repo
chmod 777 -R /path/to/repo
htpasswd -c /path/to/svn/password username#下面这段丢给httpd.conf

DocumentRoot /path/to/svn/repo
ServerName svn.yourname.com

DAV svn
SVNPath /data/svn
AuthType Basic
AuthName “Subversion”
AuthUserFile /path/to/svn/password
Require valid-user

#大功告成^_^