Linux下rails环境安装(二)mysql+fcgi+lighttpd
2008-04-30 17:07Linux下rails环境安装(二)
4、安装ruby的数据库适配器
rails发行包中已经自带纯ruby的MySQL数据库适配器。
下载安装C版本的数据库适配器,以达到更好的性能。
下载mysql-ruby-2.7.5.tar.gz
http://www.tmtm.org/en/mysql/ruby/
具体下载页面
http://tmtm.org/downloads/mysql/ruby/
解开压缩
tar xzvf mysql-ruby-2.7.5.tar.gz
cd mysql-ruby-2.7.5
mysql默认安装在哪个目录?
cat /etc/my.cnf
whereis mysql
数据库目录
/usr/local/mysql5.1
ruby extconf.rb --with-mysql-dir=/usr/local/mysql5.1/
make && make install
注意--with-mysql-dir应该指向MySQL数据库的安装路径,如果数据库服务器和Web服务器不在同一台机器上,那么Web服务器上也必须安装MySQL软件,因为ruby的C版本MySQL适配器需要在编译的时候联接MySQL的系统库。
晕。发现需要安装mysql5以上。这个东东才支持。那么就换装mysql5.1吧。我以前是linux自带的4.1.7版本。
5、安装Ruby的FCGI支持
由于ruby的fcgi支持库需要在编译的时候联接FCGI的系统库,因此我们需要先安装FCGI库。
下载FCGI源代码发行包:
http://www.fastcgi.com/dist/
下载xzvf fcgi-2.4.0.tar.gz
解开压缩
tar xzvf fcgi-2.4.0.tar.gz
cd fcgi-2.4.0
./configure --prefix=/usr/local/fcgi
make && make install
将fcgi安装在自己指定的目录下
然后就可以安装ruby的fcgi支持库了
下载ruby-fcgi-0.8.7.tar.gz:
http://rubyforge.org/projects/fcgi/
下载地址
http://rubyforge.org/frs/?group_id=926&release_id=5851
ruby-fcgi-0.8.7.tar.gz
解开压缩
tar xzvf ruby-fcgi-0.8.7.tar.gz
cd ruby-fcgi-0.8.7
ruby install.rb config -- --with-fcgi-include=/usr/local/fcgi/include --with-fcgi-lib=/usr/local/fcgi/lib
ruby install.rb setup
ruby install.rb install
6、安装lighttpd Web Server
安装Lighttpd
确认操作系统已经安装pcre,即Perl兼容的规则表达式库:
rpm -qa |grep pcre
返回如下,表示我安装了的
pcre-4.5-3
如果没有,从Linux安装光盘里面安装。
然后下载lighttpd:
http://www.lighttpd.net/download/
lighttpd-1.4.19.tar.gz
解开压缩
tar xzvf lighttpd-1.4.19.tar.gz
cd lighttpd-1.4.19
./configure --prefix=/usr/local/lighttpd
安装时报错如下:
configure: error: pcre-config not found, install the pcre-devel package and build with --without-pcre
下载pcre-devel
http://www.pcre.org/
ftp://ftp.pbone.net/mirror/www.startcom.org/AS-4.0.0/os/i386/StartCom/RPMS/pcre-devel-4.5-3.2.SEL4.i386.rpm
rpm -ivh pcre-devel-4.5-3.2.SEL4.i386.rpm --nodeps
安装以后,再次输入rpm -qa |grep pcre
返回结果:
pcre-4.5-3
pcre-devel-4.5-3.2.SEL4
configure完毕以后,会给出一个激活的模块和没有激活模块的清单,可以检查一下,是否自己需要的模块都已经激活,在enable的模块中一定要有“mod_rewrite”这一项,否则重新检查pcre是否安装。然后编译安装:
make && make install
编译后配置:
cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd
mkdir /etc/lighttpd
cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf
如果你的Linux是RedHat,那么:
cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd
然后修改/etc/init.d/lighttpd,把
lighttpd="/usr/sbin/lighttpd"
改为
lighttpd="/usr/local/lighttpd/sbin/lighttpd"
此脚本用来控制lighttpd的启动关闭和重起:
/etc/init.d/lighttpd start
启动报错如下:
Starting lighttpd: 2008-05-01 01:27:36: (configfile.c.1136) base-docroot doesn't exist: /srv/www/htdocs/
2008-05-01 01:27:36: (server.c.591) setting default values failed
[FAILED]
/etc/lighttpd/lighttpd.conf这个配置文件中的配置
/srv/www/htdocs/ 这个路径是不存在的。
server.document-root = "/srv/www/htdocs/"
改为
server.document-root = "/var/www/html/"
再重新启动试试
/etc/init.d/lighttpd stop
/etc/init.d/lighttpd restart
如果你希望服务器启动的时候就启动lighttpd,那么:
chkconfig lighttpd on
这样lighttpd就安装好了,接下来需要配置lighttpd。