CentOS 5 VPS的nginx+php+mysql解决方案之一
在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。
本方案的缺点有:
- php和mysql都是centos自带的版本,不是最新版本,万一用到php最新版本的某些特性则就不行了。
- spawn-fcgi的性能不如php-fpm,如果想用php-fpm,请参考http://rashost.com/blog/centos5-vps-nginx-solution2
安装Nginx
到 [http://rashost.com/download](http://rashost.com/download "http://rashost.com/download") 下载``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正常工作了!
安装MySQL
`yum install -y mysql-server
chkconfig –list mysqld
chkconfig mysqld on
/etc/init.d/mysqld start`
运行mysql -u root命令,应该可以正常连接到MySQL
安装PHP
yum install -y php-cgi php-mysql
安装spawn-fcgi
到 [http://rashost.com/download](http://rashost.com/download) 下载 spawn-fcgi-1.6.2-1.32.x86_64.rpm
`rpm -ivh spawn-fcgi-1.6.2-1.32.x86_64.rpm
`
By admin
read more