Powered by Typecho)))
Optimized by EAimTY
近期各大美国空间商纷纷打出了降价的大旗,有不少朋友也盘算着给自己购置一款合适的美国空间,我参考了WordPress.org.cn上yculer的一篇文章,结合自己的一些经验,并做了些修改,以更适合新手阅读,写了这篇“购买美国空间的常见误区”,希望对即将购买美国空间的朋友有一点帮助,能够多少了解一点美国空间背后的一些知识。
在国外的IDC市场,服务器、IP地址和网站之间并不是一对一的关系,一台服务器可以同时拥有几十个IP地址,一个网站也可能有几个IP地址,而且目前出于安全方面的原因,IDC会在一台服务器动态分配很多IP地址,所以通过IP地址反向查询同一IP上的其他网站,并不能说明服务器负载。此外,目前提供 IP反向查询的网站,技术并不严谨,准确率较低。
答案当然是NO,无限空间只在容量,流量,建站数量上无限,在其他方面,比如CPU资源,总文件数量,Apache Threads最长运行时间,每小时E-mail数量等等很多方面都做了限制,这些在官方的TOS中都明确的标出,但地方都很不起眼。一旦你的站点超标,HostGator一般会停你几分钟的站点运行时间,而DreamHost有直接封站的危险,这点最要命。所以,无限空间是最不值得够买的一类空间,当然,如果是新手,玩玩是可以的。
木桶原理大家都知道,一只木桶盛水的多少,取决于桶壁上最短的那块。空间、流量就像是桶壁上较高的木块、那些写在TOS中的不起眼的使用限制就是桶壁上较低的木块。你的站点运行效率的高低恰恰取决于此。
购买过美国空间的朋友对这两个词应该是熟悉的。
什么是OverSell(超售)和OverLoad(过载)用上面的无限空间为例,谁都明白,哪有什么无限空间,硬盘再大也有个头不是?无限说白了就是个噱头,这和OverSell有什么关系呢,比如我们有个 500GB硬盘空间的服务器,出售无限空间,并对每个账户做资源方面的限制,比如CPU,文件数量之类,但这个限制是很模糊的,你说你上传五万个PHP文件是五万个文件,你上传五万首MP3也是五万个文件,所以说,IDC对于这个限制的根据就是自己的经验,这一来准确率就很难保证,比如这块500GB硬盘预估50个站点,CPU限制为7%,每小时最大不超过20%,好了,来了50个站长,这50个站长都很规矩维护着自己的网站,服务器运行起来很轻松,IDC发现有很大一部分空间和资源没人用,整理一下,接着出售,但这时来了个家伙,买了空间做电影论坛,并上传了很多高清电影做下载服务器(无限空间和流量嘛),日IP3000,这下完蛋了,虽然对每个账户的资源做了限制但整个服务器的运行效率就下来了。一旦数量和资源超过服务商的预估,服务器已经无法支持已存在的这些站点高效运行时,这就叫OverLoad(过载)。
目前的IDC对于Reseller(代理商)OverSell(超售)的态度分三种,
一,允许OverSell(超售);
二,加钱允许 OverSell(超售);
三,不允许OverSell(超售)。
JS嘛,总希望自己利益最大话,所以目前无论是商家还是代理商都会OverSell(超售),这就是为什么刚买的空间开始速度还行,后来速度就慢了的原因,其实OverSell(超售)不一定就OverLoad(过载),如果碰到的JS有点良心,能够严格控制站点数量和资源的分配,这是最好的。一旦碰到一个“利益最大话”的Reseller那就傻叉了。
所以,OverSell(超售)是普遍现象,OverSell(超售)不等于OverLoad(过载),能够严格控制站点数量的JS是不错的。有人说我买那些不允许OverSell(超售)的主机不就结了,一般不允许OverSell(超售)的空间价格都非常高,快赶上VPS了,但别忘了你的空间除了容量和流量还有CPU等资源的限制,在购买不允许OverSell(超售)的主机你得看看空间在其他方面的负载来综合考虑。
很多人在选择虚拟主机(Virtual Hosting)或者VPS的时候因为备案,网络审查,外贸等原因都倾向于把主机放在美国。美国作为互联网的中心,有个分布最密集的光纤网络,带宽等成本因为规模庞大,竞争激烈等因素也是全球最低的。
正是嗅到了美国主机的商机,海外主机代购也自然而然蓬勃发展起来了。考虑美国主机,除了选择何种类型的主机(虚拟主机还是VPS亦或是主机合租), 主机商自身的信誉,服务,价格,稳定些等之外,如果你的网站受众主要还是来自大陆,主机所在的机房位置也是一个重要的考虑因素。
中美之间的网络电话等数据传输毫无疑问得通过跨域太平洋的海底光缆来进行。目前中美之间有两条直达海底光缆:
一条是China-US Cable Network,网络容量达到了80Gbps,中国大陆登陆点为崇明岛和汕头,美国登陆点为加州的San Luis Obispo(位于圣何塞与洛杉矶之间)。
还有一条即著名的Trans Pacific Cable,设计容量达到了惊人的5.12Tbps,大陆登陆点为上海(中国电信)和青岛(中国联通),美国登陆点为俄勒冈州的Nedonna沙滩。
两条光缆均已开通商用,但从目前我多次traceroute的结果来看,TPE似乎还没有向一般宽带用户开放。中美之间的带宽增长速度相当惊人,根据CNNIC的统计数据,截至2008年底中国电信与美国之间的带宽为203980MB,而中国网通为110456MB.目前中国电信在北美西海岸的节点有华盛顿州的西雅图,加州的圣何塞,洛杉矶和帕拉阿图。
Taylor Swift 和 Coldplay 都是我非常崇拜的歌手和乐队。都是可以堪称天才的人物。Taylor的Love Story我尤其喜欢,那种Country + pop的风格感觉很爽,外加Taylor的美丽的声音和外表~ 。。。Coldplay 就不说了,如果你不知道他们,那我也无话可说。。
偶然在某个网站上看到的,挺不错。钢琴家Jon Schmidt与大提琴家Steven Sharp Nelson改编的一首曲子,融合了Taylor Swift 的Love Story 和 Coldplay 的 Viva la vida,听了之后非常有感觉,于是贴出来分享一下。
安装编译所需要的库:
apt-get install libxml2-dev libmcrypt-dev libssl-dev libldap2-dev libmhash-dev libmysqlclient-dev libcurl4-openssl-dev libpng-dev libjpeg-dev libsasl2-dev
安装libevent
cd ~/src
wget http://monkey.org/~provos/libevent-1.4.13-stable.tar.gz
tar xf libevent-1.4.13-stable.tar.gz
cd libevent-1.4.13-stable
./configure --enable-shared
make
make installulimit -SHn 65535
安装pcre
wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.00.tar.gz
tar zxvf pcre-8.00.tar.gz
cd pcre-8.00/
./configure
make && make install
安装libunwind#否则无法安装Google-perftools
cd /libunwind-0.99
./configure --enableshared
make
make install
安装google-perftools#mysql和nginx需要(64位必须加--enable-frame-pointers)
wget http://google-perftools.googlecode.com/files/google-perftools-1.5.tar.gz
./configure --enableshared --enable-frame-pointers
make
make install
下载purge #清除缓存用的
wget http://labs.frickle.com/files/ngx_cache_purge-1.0.tar.gz
tar zxvf ngx_cache_purge-1.0.tar.gzwget http://nginx.org/download/nginx-0.8.32.tar.gz
tar zxvf nginx-0.8.32.tar.gz
cd nginx-0.8.32/
cd ../
./configure --prefix=/zh/nginx --user=www-data --group=www-data --with-rtsig_module --with-select_module --with-poll_module --with-ipv6 --with-http_ssl_module --with-http_realip_module --with-http_sub_module --with-http_flv_module --with-http_gzip_static_module --with-http_stub_status_module --http-client-body-temp-path=/tmp/nginx/client --http-proxy-temp-path=/tmp/nginx/proxy --http-fastcgi-temp-path=/tmp/nginx/fastcgi --with-google_perftools_module --add-module=/home/web_package/ngx_cache_purge-1.0
启动nginx错误解决办法
1:error while loading shared libraries: libpcre.so.0: cannot open shared object file: No such file or directory
解决方法,在/lib中创建一个symbol link到/usr/local/pcre/lib/libpcre.so.0
sudo ln -s /usr/local/pcre/lib/libpcre.so.0 /lib
2:error while loading shared libraries: libprofiler.so.0: cannot open shared object file: No such file or directory
安装ImageMagick
cd ~/src
apt-get build-dep imagemagick
wget ftp://ftp.imagemagick.org/pub/ImageMagick/ImageMagick.tar.gz
tar xf ImageMagick.tar.gz
cd ImageMagick-6.5.8-6/
./configure
make
aptitude install libperl-dev
make installapt-get build-dep php
wget http://cn2.php.net/get/php-5.3.1.tar.bz2/from/this/mirror
tar xf php-5.3.1.tar.bz2
#下载imagick
cd ~/src
wget http://pecl.php.net/get/imagick-2.3.0.tgz
tar xf imagick-2.3.0.tgz
cp -R imagick-2.3.0 php-5.3.1/ext/imagick
cd php-5.3.1
./buildconf --force
#下载php-fpm
apt-get install batch
wget http://launchpad.net/php-fpm/master/0.6/+download/php-fpm-0.6~5.3.1.tar.gz
$ tar -xzf php-fpm-0.6~5.3.1.tar.gz
$ php-fpm-0.6-5.3.1/generate-fpm-patch
$ patch -d php-5.3.1 -p1$ cd php-5.3.1
$ ./buildconf --force./configure --prefix=/zh/php5 --with-fpm --with-libxml-dir=/usr --with-fpm-bin=/zh/php5/fpm --with-fpm-conf=/zh/php5/etc --with-fpm-user=www-data --with-fpm-group=www-data --with-layout=GUN --with-config-file-path=/zh/php5/etc --with-config-file-scan-dir=/zh/php5/etc --with-openssl --with-zlib --enable-bcmath --enable-calendar --with-curl --with-curlwrappers --enable-exif --enable-ftp --disable-rpath --with-gd --with-jpeg-dir --with-png-dir --enable-gd-native-ttf --with-gettext --with-mhash --with-imagick --with-imap --with-imap-ssl --with-ldap --enable-mbstring --with-mcrypt --with-mysql=mysqlnd --enable-mbregex --with-mysql-sock --with-mysqli --with-pdo-mysql --with-pdo-sqlite --enable-soap --enable-sockets --enable-sqlite-utf8 --enable-sysvsem --with-xmlrpc --enable-zip --without-pear --enable-shmop --enable-pcntl --with-libevent=shared --with-kerberos
make
make install
安装记录
molyx:/home/web_package/php-5.3.1# make install
Installing PHP SAPI module: fpm
Installing PHP CLI binary: /zh/php5/bin/
Installing PHP CLI man page: /zh/php5/man/man1/
Installing build environment: /zh/php5/lib/php/build/
Installing header files: /zh/php5/include/php/
Installing helper programs: /zh/php5/bin/
program: phpize
program: php-config
Installing man pages: /zh/php5/man/man1/
page: phpize.1
page: php-config.1
/home/web_package/php-5.3.1/build/shtool install -c ext/phar/phar.phar /zh/php5/bin
ln -s -f /zh/php5/bin/phar.phar /zh/php5/bin/pharupdate-rc.d php-fpm defaults
sed -i "s/nobody/www-data/g" /etc/php-fpm.conf
/etc/init.d/php-fpm start
make install
cp php.ini-dist /zh/php5/etc/php.ini
ln -s /zh/php5/sbin/php-fpm /etc/init.d/php-fpm
update-rc.d -f php-fpm defaults
编译后的php安装在/opt/php下面,php的配置文件是/opt/php/lib/php.ini
和其他Linux下不同,在Debian下这时候启动php-fpm会失败,原因是在Debian下php-fpm的配置文件中必须指定运行时的用户才行。
优化php-fpm
编辑php-fpm的配置文件/etc/php-fpm.conf,
* 去掉display_errors参数的注释,修改参数值为1
* 去掉sendmail_path参数的注释
* 去掉user,group参数的注释
* 修改max_children参数的值为10
安装php加速器eAccelerator
tar jxf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
apt-get install -y autoconf
/zh/php5/bin/phpize
./configure --with-php-config=/zh/php5/bin/php-config --enable-eaccelerator --enable-shared
make
make install
mkdir /tmp/php/eaccelerator_cache
然后重启php-fpm,在phpinfo()页面中应该能看到eaccelerator的信息了。
附录:
memcache模块安装:
/zh/php5/bin/phpize
./configure --enable-memcache --enable-shared --with-php-config=/zh/php5/bin/php-config
make
make install
Suhosin模块安装:
/zh/php5/bin/phpize
./configure --with-php-config=/zh/php5/bin/php-config --enable-shared --enable-suhosin
make
make install
extension_dir = "/zh/php5/lib/php/extensions/no-debug-non-zts-20090626"
;suhosin module
[suhosin]
extension=suhosin.so
;memcache module
[memcache]
extension=memcache.so
;eaccelerator module
[eaccelerator]
;zend_extension="/zh/php5/lib/php/extensions/no-debug-non-zts-20090626/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/tmp/php/eaccelerator_cache"
eaccelerator.enable="1"
eaccelerator.optimizer="1"
eaccelerator.check_mtime="1"
eaccelerator.debug="0"
eaccelerator.filter=""
eaccelerator.shm_max="0"
eaccelerator.shm_ttl="3600"
eaccelerator.shm_prune_period="3600"
eaccelerator.shm_only="0"
eaccelerator.compress="1"
eaccelerator.compress_level="9"
错误解决
1:utf8_mime2text() has new signature, but U8T_CANONICAL is missing
安装c-client
apt-get install libc-client-dev
2:configure: error: libevent.a could not be found. Stop.
使用参数--with-libevent=shared
3:This c-client library is built with Kerberos support.
添加 --with-kerberos to your configure line. Check config.log for details
This article shows how to install ffmpeg, ffmpeg-PHP, Mplayer, Mencoder, flv2tool, LAME MP3 Encoder, and Libog from source. It should work on most systems, however may need some tweaking from system to sytem.
cd /usr/local/src
Download source tarballs:
wget http://rubyforge.org/frs/download.php/9225/flvtool2_1.0.5_rc6.tgz
wget http://easynews.dl.sourceforge.net/sourceforge/lame/lame-3.97.tar.gz
wget http://superb-west.dl.sourceforge.net/sourceforge/ffmpeg-php/ffmpeg-php-0.5.0.tbz2
wget http://downloads.xiph.org/releases/ogg/libogg-1.1.3.tar.gz
wget http://downloads.xiph.org/releases/vorbis/libvorbis-1.1.2.tar.gz
wget http://www4.mplayerhq.hu/MPlayer/releases/codecs/essential-20061022.tar.bz2
Extract the tarballs:
tar zxvf lame-3.97.tar.gz
tar zxvf libogg-1.1.3.tar.gz
tar zxvf libvorbis-1.1.2.tar.gz
tar zxvf flvtool2_1.0.5_rc6.tgz
tar jxvf essential-20061022.tar.bz2
tar jxvf ffmpeg-php-0.5.0.tbz2
tar zxvf flvtool2_1.0.5_rc6.tgz
Make a directory to store all the codecs:
mkdir /usr/local/lib/codecs/
Install any necessary packages:
yum install gcc gmake make libcpp libgcc libstdc++ gcc4 gcc4-c++ gcc4-gfortran
yum install subversion ruby ncurses-devel
svn checkout svn://svn.mplayerhq.hu/ffmpeg/trunk ffmpeg
svn checkout svn://svn.mplayerhq.hu/mplayer/trunk mplayer
cd /usr/local/src/mplayer
svn update
cd /usr/local/src
Copy codecs for mplayer:
mv /usr/local/src/essential-20061022/* /usr/local/lib/codecs/
chmod -R 755 /usr/local/lib/codecs/
If you are using secure tmp:
mkdir /usr/local/src/tmp
chmod 777 /usr/local/src/tmp
export TMPDIR=/usr/local/src/tmp
Installing Lame:
cd /usr/local/src/lame-3.97
./configure
make && make install
Installing Libogg:
cd /usr/local/src/libogg-1.1.3
./configure && make && make install
Installing libvorbis:
cd /usr/local/src/libvorbis-1.1.2
./configure && make && make install
Installing flvtool2:
cd /usr/local/src/flvtool2_1.0.5_rc6/
ruby setup.rb config
ruby setup.rb setup
ruby setup.rb install
cd /usr/local/src/mplayer
./configure && make && make install
Installing ffmpeg:
cd /usr/local/src/ffmpeg/
./configure –enable-libmp3lame –enable-libogg –enable-libvorbis –disable-mmx –enable-shared
make && make install
ln -s /usr/local/lib/libavformat.so.50 /usr/lib/libavformat.so.50
ln -s /usr/local/lib/libavcodec.so.51 /usr/lib/libavcodec.so.51
ln -s /usr/local/lib/libavutil.so.49 /usr/lib/libavutil.so.49
ln -s /usr/local/lib/libmp3lame.so.0 /usr/lib/libmp3lame.so.0
ln -s /usr/local/lib/libavformat.so.51 /usr/lib/libavformat.so.51
Installing ffmpeg-php:
cd /usr/local/src/ffmpeg-php-0.5.0/
phpize
./configure
make
make install
Note: Make sure this is the correct php.ini for this server.
echo ‘extension=/usr/local/lib/php/extensions/no-debug-non-zts-20020429/ffmpeg.so’ >> /usr/local/Zend/etc/php.ini
Restart apache:
service httpd restart
You should be ready to go now!
Note: up2date can be used if you don’t have yum installed.