Ruby安装包 PVFLinux联盟
下载地址:http://www.ruby-lang.org/en/downloads/ PVFLinux联盟
ruby-1.8.6-p111.tar.gz PVFLinux联盟
解压并安装: PVFLinux联盟
tar -xvzf ruby-1.8.6-p111.tar.gz PVFLinux联盟
cd ruby-1.8.6-p111 PVFLinux联盟
./configure -prefix=/opt/modules/ruby PVFLinux联盟
make PVFLinux联盟
make install PVFLinux联盟
操作系统PATH路径: PVFLinux联盟
export PATH=/opt/modules/ruby/bin:$PATH PVFLinux联盟
rails远程安装: PVFLinux联盟
gem下载地址:http://rubyforge.org/projects/rubygems/ PVFLinux联盟
解压并安装: PVFLinux联盟
tar xzvf rubygems-1.0.1.tgz PVFLinux联盟
cd rubygems-1.0.1/ PVFLinux联盟
ruby setup.rb PVFLinux联盟
ruby/bin/gem install rails --remote PVFLinux联盟
mysql_ruby驱动安装 PVFLinux联盟
下载地址:http://www.tmtm.org/en/mysql/ruby/ PVFLinux联盟
解压并安装: PVFLinux联盟
tar -xvzf mysql-ruby-2.7.4.tar.gz PVFLinux联盟
cd mysql-ruby-2.7.4 PVFLinux联盟
ruby extconf.rb --with-mysql-dir=/opt/modules/mysql/ PVFLinux联盟
make && make install PVFLinux联盟
fast-cgi安装: PVFLinux联盟
下载地址:http://www.fastcgi.com/dist/ PVFLinux联盟
解压并安装: PVFLinux联盟
tar xzvf fcgi-2.4.0.tar.gz PVFLinux联盟
cd fcgi-2.4.0 PVFLinux联盟
./configure --prefix=/opt/modules/fcgi PVFLinux联盟
make && make install PVFLinux联盟
安装ruby的fcgi支持库: PVFLinux联盟
tar xzvf ruby-fcgi-0.8.7.tar.gz PVFLinux联盟
cd ruby-fcgi-0.8.7 PVFLinux联盟
ruby install.rb config -- --with-fcgi-include=/opt/modules/fcgi/include --with-fcgi-lib=/opt/modules/fcgi/lib PVFLinux联盟
ruby install.rb setup PVFLinux联盟
ruby install.rb install PVFLinux联盟
Lighttpd安装: PVFLinux联盟
下载地址:http://www.lighttpd.net/download/ PVFLinux联盟
注意: 安装前要检查linux中的pcre,在RedHat中会默认安装pcre-4.5-3.2.RHEL4,这个版本不支持lighttpd. PVFLinux联盟
必须下载另外两个rpm,grep-2.5.1-32.2.i386.rpm和pcre-devel-4.5-3.2.SEL4.i386.rpm, PVFLinux联盟
下载地址:http://scientificlinux.physik.uni-muenchen.de/mirror/scientific/43/i386/errata/fastbugs/RPMS/grep-2.5.1-32.2.i386.rpm PVFLinux联盟
下载地址: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 PVFLinux联盟
安装命令为:rpm -ivh rpm包名 PVFLinux联盟
解压并安装: PVFLinux联盟
tar xzvf lighttpd-1.4.18.tar.gz PVFLinux联盟
./configure --prefix=/opt/modules/lighttpd PVFLinux联盟
make && make install PVFLinux联盟
配置环境: PVFLinux联盟
1.将lighttpd的配置文件放到/etc/lighttpd/ PVFLinux联盟
cp doc/sysconfig.lighttpd /etc/sysconfig/lighttpd PVFLinux联盟
mkdir /etc/lighttpd PVFLinux联盟
cp doc/lighttpd.conf /etc/lighttpd/lighttpd.conf PVFLinux联盟
2.将启动服务器的启动文件放入到用户的目录中 PVFLinux联盟
cp doc/rc.lighttpd.redhat /etc/init.d/lighttpd PVFLinux联盟
编辑此文件: PVFLinux联盟
LIGHTTPD_BIN=/usr/sbin/lighttpd PVFLinux联盟
改为 PVFLinux联盟
LIGHTTPD_BIN=/usr/local/lighttpd/sbin/lighttpd PVFLinux联盟
希望服务器启动的时候就启动lighttpd,那么: PVFLinux联盟
chkconfig lighttpd on PVFLinux联盟
配置Lighttpd PVFLinux联盟
修改/etc/lighttpd/lighttpd.conf PVFLinux联盟
1)server.modules PVFLinux联盟
取消需要用到模块的注释,mod_rewrite,mod_access,mod_fastcgi,mod_simple_vhost,mod_cgi,mod_compress,mod_accesslog是一般需要用到的。 PVFLinux联盟
2)server.document-root, server.error-log,accesslog.filename需要指定相应的目录 PVFLinux联盟
3)用什么权限来运行lighttpd,默认将使用root用户进行运行。 PVFLinux联盟
server.username = "nobody" PVFLinux联盟
server.groupname = "nobody" PVFLinux联盟
从安全角度来说,不建议用root权限运行web server,可以自行指定普通用户权限。 PVFLinux联盟
4)静态文件压缩 PVFLinux联盟
compress.cache-dir = "/tmp/lighttpd/cache/compress" PVFLinux联盟
compress.filetype = ("text/plain", "text/html","text/javascript","text/css") PVFLinux联盟
可以指定某些静态资源类型使用压缩方式传输,节省带宽,对于大量AJAX应用来说,可以极大提高页面加载速度。 PVFLinux联盟
安装过程中遇到的一些问题:(安装花绪) PVFLinux联盟
1.在安装rails的过程中,由于需要远程安装rails的时候,但是安装不成功, PVFLinux联盟
命令提示: PVFLinux联盟
ERROR: While executing gem ... (Gem::RemoteFetcher::FetchError) PVFLinux联盟
getaddrinfo: Temporary failure in name resolution (SocketError) PVFLinux联盟
getting size of http://gems.rubyforge.org/Marshal.4.8 PVFLinux联盟
原因是此服务器没设置DNS,不能对外访问网络。 PVFLinux联盟
解决方法: PVFLinux联盟
#>vi /etc/resolv.conf
nameserver 202.106.46.151
nameserver 202.106.196.115
nameserver 211.98.2.4
nameserver 211.98.4.1 |
2.安装lighttpd时,由于原来的pcre包不支持此服务,需要安装一个linux内核包pcre-devel-4.5-3.2.SEL4.i386.rpm, PVFLinux联盟
但是不能正常安装。 PVFLinux联盟
命令提示: PVFLinux联盟
warning: pcre-devel-4.5-3.2.SEL4.i386.rpm: V3 DSA signature: NOKEY, key ID 652e84dc PVFLinux联盟
error: Failed dependencies: PVFLinux联盟
pcre = 4.5-3.2.SEL4 is needed by pcre-devel-4.5-3.2.SEL4.i386 PVFLinux联盟
原因是此安装包不能直接进行安装,必须安装另一个grep的rpm包,才能正常安装。 PVFLinux联盟
解决方法: PVFLinux联盟
#>rpm -ivh grep-2.5.1-32.2.i386.rpm
#>rpm -ivh pcre-devel-4.5-3.2.SEL4.i386.rpm |
3.lighttpd的配置,服务不能正常启动,启动步骤如下: PVFLinux联盟
#>/etc/init.d/lighttpd status PVFLinux联盟
命令提示: PVFLinux联盟
lighttpd dead but pid file exists PVFLinux联盟
在配置过程中由于对配置文件的内容不是很熟悉,所以只好拿可以运行的配置比对,经过调试发现有几处需要调整, PVFLinux联盟
1)server.pid-file = "/var/run/lighttpd.pid" PVFLinux联盟
此处是当前项目运行时的PID; PVFLinux联盟
2)compress.cache-dir = "/opt/modules/lighttpd/compress" PVFLinux联盟
经处是的目录需要手动建立,否则加载会失败! PVFLinux联盟
3)fastcgi.server = ( PVFLinux联盟
".fcgi" => ( PVFLinux联盟
"rails" => ( PVFLinux联盟
"socket" => "/tmp/lighttpd/socket/rails.socket", PVFLinux联盟
"bin-path" => "/opt/pptv-data/pptvCMS/public/dispatch.fcgi", PVFLinux联盟
"bin-environment" => ("RAILS_ENV" => "development"), PVFLinux联盟
"min-procs" => 10, PVFLinux联盟
"max-procs" => 10 PVFLinux联盟
) PVFLinux联盟
) PVFLinux联盟
) PVFLinux联盟
上述代码为新增该服务访问的项目路径。此项目会启动10个进程,会建立10个rails.socket,保证socket建立的所在目录存在。 PVFLinux联盟
项目所在的物理地址是否正确(/opt/pptv-data/pptvCMS/public/dispatch.fcgi)。 PVFLinux联盟
4)index-file.names = ( "dispatch.fcgi","index.php","index.html","index.htm", "default.htm" ) PVFLinux联盟
新增"dispatch.fcgi"作为访问页面。 PVFLinux联盟
5)查看项目对应的public/dispatch.fcgi中的第一行是否为当前服务器的ruby安装路径。 PVFLinux联盟
ruby安装路径:/opt/modules/ruby PVFLinux联盟
dispatch.fcgi中的第一行:#!/opt/modules/ruby/bin/ruby PVFLinux联盟
需要修改的文件包括:dispatch.cgi,dispatch.rb,dispatch.fcgi PVFLinux联盟
4 lighttpd的配置正确,服务正常启动,项目不能正常访问: PVFLinux联盟
命令提示: PVFLinux联盟
错误访问号500,页面不存在, PVFLinux联盟
问题的原因,在environment.rb文件中需要指定rails的版本号, PVFLinux联盟
如: PVFLinux联盟
RAILS_GEM_VERSION = '1.2.6' unless defined? RAILS_GEM_VERSION PVFLinux联盟
查看版本发现rails的版本是2.0.2,由于开发时采用的版本为1.2.6,所以需要卸载当前的2.0.2版本,安装1.2.6版本。 PVFLinux联盟
解决方法: PVFLinux联盟
gem uninstall rails PVFLinux联盟
gem install rails --version '=1.2.6' PVFLinux联盟
重新启动服务,一切OK。 PVFLinux联盟