Posted by zuzhihui in vps技术 on 2009/09/05 with No Comments
本文介绍在CentOS 5 VPS下的nginx php mysql的解决方案之二,本方案使用php-fpm作为fastcgi的进程管理器。
使用php-fpm就必须重新编译php,不能使用系统自带的php。我们的观点是尽量使用系统自带的,除非功能满足不了。本方案中MySQL是使用CentOS 5自带的,Nginx是我们自己编译的。
centos系统不带nginx,我们用的Nginx是自己编译的,Nginx版本是最新稳定版本0.7.61,到 http://rashost.com/download 下载nginx
,然后开始安装:
rpm -ivh nginx-0.7*.rpm
chkconfig --list nginx
chkconfig nginx on
/etc/init.d/nginx start
rpm -ql nginx
上面的rpm -ql nginx命令是看看nginx的文件都安装在哪些目录下面了,可以看到nginx的缺省网页目录应该是/usr/share/nginx/html/
通过浏览器访问,应该能看到nginx的缺省网页了,说明nginx正常工作了!
我们使用CentOS自带的MySQL,安装命令:
yum install -y mysql-server
chkconfig --list mysqld
chkconfig mysqld on
/etc/init.d/mysqld start
运行mysql -uroot命令,应该可以正常连接到MySQL
先安装php & php-fpm所依赖的一些库文件:
yum install libmhash libmcrypt libtool-ltdl libpng libjpeg curl
然后到 http://dl.rashost.com 下载我们自己编译的php-fpm,
并安装:
cd /opt
tar zxf php-fpm-5.2.10*.tar.gz
/opt/php/sbin/php-fpm start
然后编辑/etc/rc.local,在其中加入/opt/sbin/php-fpm start
首先在/usr/share/nginx/html目录下创建文件test.php,其内容很简单,只要下面一行:
<?phpinfo();?>
假设所在VPS的地址是centos5.rashost.com,这时通过浏览器访问http://centos5.rashost.com/test.php是得不到正确的显示结果的。
修改nginx的配置文件/etc/nginx/nginx.conf,在文件内搜索fastcgi_pass,修改该部分内容为:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
然后重启nginx:
/etc/init.d/nginx/restart
然后在浏览器中访问test.php页面,就应该能正确显示了,reboot VPS测试一下,各个模块应该都能自带启动。大功告成!
Posted by zuzhihui in Linux技术 on 2009/09/05 with No Comments
本文记录了在CentOS 5 VPS上编译打了php-fpm补丁的php 5.2.10的过程。
安装编译php需要的一些库文件
yum install libxml2-devel libmcrypt-devel openssl-devel curl-devel libjpeg-devel libpng-devel freetype-devel openldap-devel libmhash-devel mysql-devel libtool-ltdl-devel
如果是64位的系统,然后需要调整一下mysql的库文件,否则在64位系统下老去找32位的mysql库:
cd /usr/lib
mv mysql mysql.i386
ln -sf /usr/lib64/mysql mysql
给php打php-fpm补丁:
cd php-5.2.10
patch -p1 < ../php-5.2.10-fpm-0.5.13.diff
开始编译php,注意:如果是64位的系统,建议去掉 –with-ldap-sasl,否则有可能编译不过
./configure --prefix=/opt/php --with-iconv --with-zlib --enable-xml --disable-rpath --enable-discard-path --enable-safe-mode --enable-bcmath --enable-shmop --enable-sysvsem --enable-inline-optimization --with-curl --with-curlwrappers --enable-mbregex --enable-fastcgi --enable-fpm --enable-force-cgi-redirect --enable-mbstring --with-mcrypt --with-gd --enable-gd-native-ttf --with-openssl --with-mhash --enable-pcntl --enable-sockets --with-ldap --with-ldap-sasl --with-xmlrpc --enable-zip --enable-soap --without-pear --with-mysql --with-mysqli --enable-sqlite-utf8 --with-pdo-mysql --enable-ftp --with-jpeg-dir
--with-freetype-dir
--with-png-dir
make
当编译到php-5.2.10/ext/date/lib/parse_date.c的时候,挂了,好像不往下走了,这时候ctrl-c中断编译过程,把当前正在执行的语句复制粘贴到命令行单独执行,发现还是好像死循环一样不结束,再次ctrl-c中断,删除掉这个命令中的-O2参数,继续执行,这样这个命令很快就结束了,然后继续运行:
make
make install
cp php.ini-dist /opt/php/lib/php.ini
然后运行 /opt/php/sbin/php-fpm start 就可以启动php的fastcgi进程了,这些php fastcgi进程应该可以正常工作了。
编辑php-fpm的配置文件/opt/php/etc/php-fpm.conf,
tar jxf eaccelerator-0.9.5.3.tar.bz2
cd eaccelerator-0.9.5.3
yum install -y autoconf
/opt/php/bin/phpize
./configure --enable-eaccelerator --with-php-config=/opt/php/bin/php-config
make
make install
mkdir /opt/php/eaccelerator_cache
然后vim /opt/php/lib/php.ini,在文件末尾加入:
[eaccelerator]
zend_extension="/opt/php/lib/php/extensions/no-debug-non-zts-20060613/eaccelerator.so"
eaccelerator.shm_size="16"
eaccelerator.cache_dir="/opt/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"
然后重启php-fpm,在phpinfo()页面中应该能看到eaccelerator的信息了。
我们把/opt/php目录打包放到 http://dl.rashost.com/ 下面,供客户下载使用。
最后,安装好之后,记着在/etc/rc.local文件中加入自动启动php-fpm的语句:
/opt/php/sbin/php-fpm start
Posted by zuzhihui in Linux技术 on 2009/09/05 with No Comments
spawn-fcgi是一个小程序,这个程序的作用是管理fast-cgi进程,功能和php-fpm类似。
最初spawn-fcgi是lighttpd的一部分,2009年2月份,lighttpd的开发人员把spawn-fcgi单独拿出来成立了一个项目,详见 http://blog.lighttpd.net/articles/2009/02/18/prerelease-of-spawn-fcgi-1-6-0-rc1-r16 。spawn-fcgi的项目地址是 http://redmine.lighttpd.net/projects/spawn-fcgi/wiki ,目前的最新版本是1.6.2
spawn-fcgi是个新项目,很多Linux发行版都没有收录,我们瑞豪开源针对VPS常用的Linux发行版编译了spawn-fcgi,放在 供客户下载安装
Posted by zuzhihui in vps技术 on 2009/09/05 with 3 Comments
在CentOS5 VPS下的nginx php mysql的解决方案有多个,本文介绍其中的解决方案之一。
本文基于64位的CentOS 5 VPS,如果是32位的VPS,请在相应部分做修改。
本解决方案使用瑞豪开源自己编译的最新稳定版本的Nginx,fastcgi进程管理使用spawn-fcgi,还有CentOS 5自带的5.0.45版本的MySQL和5.1.6版本的php。
本方案的优点是使用CentOS5自带的php和mysql,扩展性好,php的各种扩展yum库里面都有,都可以直接使用;另外,由于使用系统自带的php和mysql,安全性要好一些,如果有什么漏洞都可以直接升级为centos官方的最新版本。由于使用spawn-fcgi,所以无须重新编译php。
本方案的缺点有:
到 http://dl.rashost.com/下载
nginx-0.7.61-1.x86_64.rpm
安装命令:
rpm -ivh nginx-0.7.61-1.x86_64.rpm
chkconfig --list nginx
chkconfig nginx on
/etc/init.d/nginx start
rpm -ql nginx
上面的rpm -ql nginx命令是看看nginx的文件都安装在哪些目录下面了,可以看到nginx的缺省网页目录应该是/usr/share/nginx/html/
通过浏览器访问,应该能看到nginx的缺省网页了,说明nginx正常工作了!
yum install -y mysql-server
chkconfig --list mysqld
chkconfig mysqld on
/etc/init.d/mysqld start
运行mysql -uroot命令,应该可以正常连接到MySQL
yum install -y php-cgi php-mysql
到http://dl.rashost.com/ 下载 spawn-fcgi-1.6.2-1.32.x86_64.rpm
rpm -ivh spawn-fcgi-1.6.2-1.32.x86_64.rpm
然后在/etc/rc.local里面加入spawn-fcgi的启动命令:
spawn-fcgi -C 10 -a 127.0.0.1 -p 9000 -u nginx -d /tmp -f php-cgi
其中的-C 10参数是指启动的php fastcgi的进程数目,这个数值可以根据网站的访问量和内存大小修改。
然后先手工启动一下php:
spawn-fcgi -C 10 -a 127.0.0.1 -p 9000 -u nginx -d /tmp -f php-cgi
首先在/usr/share/nginx/html目录下创建文件test.php,其内容很简单,只要下面一行:
<?phpinfo();?>
假设所在VPS的地址是centos5.rashost.com,这时通过浏览器访问http://centos5.rashost.com/test.php是得不到正确的显示结果的。
修改nginx的配置文件/etc/nginx/nginx.conf,在文件内搜索fastcgi_pass,修改该部分内容为:
location ~ \.php$ {
root html;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
include fastcgi_params;
}
然后重启nginx:
/etc/init.d/nginx/restart
然后在浏览器中访问test.php页面,就应该能正确显示了,reboot VPS测试一下,各个模块应该都能自带启动。大功告成,该来些瓶啤酒庆祝一下了!
Posted by zuzhihui in vps技术 on 2009/09/04 with 2 Comments
Nginx是个Web服务器新秀,CentOS5官方没有Nginx的RPM包,本文记录了在64位的CentOS5 VPS下怎样编译Nginx 0.7.61版本的RPM包。
要编译RPM包,首先要有SRPM包,也就是RPM包的源代码包。可以从Nginx官网下载Nginx的源代码然后自己制作Nginx的SRPM包,这比较麻烦。本文下载了fedora 10中自带的Nginx的SRPM包,稍做修改即可。
安装SRPM包:
rpm -ivh nginx-0.7.61-1.fc10.src.rpm
上面命令把源代码安装在了/usr/src/redhat目录下,要编译RPM,需要rpmbuild命令:
yum install -y rpm-build.x86_64
然后就可以开始build了:
cd /usr/src/redhat/SPECS
rpmbuild -bb nginx.spec
build报错了,少了几个必须的库文件,我们来安装:
yum install -y pcre-devel.x86_64 zlib-devel.x86_64 openssl-devel.x86_64 mod_perl-devel.x64_64
然后修改nginx.spec文件,将其中的
perl-devel修改成mod_perl-devel。继续build:
rpmbuild -bb nginx.spec
大功告成!build出来的RPM包就是
/usr/src/redhat/RPMS/x86_64/nginx-0.7.61-1.x86_64.rpm 。同样的方法,我们在32位的CentOS VPS下也编译了一份,然后把他们都放到http://dl.rashost.com/下供大家下载。
Posted by zuzhihui in 最新消息 on 2009/09/02 with No Comments
(注意:从2010/8/7起,本活动不再有效,最新活动请参考 http://rashost.com/blog/review-rashost-free-vps-memory )
我们欢迎各位客户在自己的网站上加上到瑞豪开源网站的链接,作为回报,我们给客户免费增加VPS内存。
可以选择如下几种方式,在您的网站上加入瑞豪开源网站的链接:
链接的目的地址必须是: http://rashost.com/usa-vps
客户加完链接之后,请提交服务单告诉我们,我们将给客户的VPS免费增加内存,免费增加的内存的多少会取决于链接页面的质量和数量等因素。
可以的,无论您的网站在什么地方,都可以参加这个活动!
Posted by zuzhihui in 常见问题 on 2009/09/01 with No Comments
今天有个老客户的美国VPS的DNS查询很慢,后来他自己修改成了OpenDNS的DNS服务器之后,DNS查询就非常快了。感谢这个客户把问题反映给我们。
OpenDNS的两个DNS服务器地址是:208.67.222.222 和 208.67.220.220 。我们推荐VPS客户使用OpenDNS的DNS服务器来做DNS解析,以后新开通的VPS也缺省使用这两个DNS服务器。
Linux VPS的DNS配置文件是/etc/resolv.conf,Windows VPS怎样配置DNS就不需要说了。
OpenDNS是美国的一家商业公司,这家公司提供免费的DNS服务器,他们的DNS服务器在安全方面做了很多工作。另外,不要以为他们的名字是以Open开头的,就以为这是个开源的产品,OpenDNS不是开源的。
近期评论