WEB开发网
开发学院操作系统CentOS CentOS5.2 Apache搭建系统开发环境 阅读

CentOS5.2 Apache搭建系统开发环境

 2010-05-21 20:19:56 来源:WEB开发网   
核心提示:对大家推荐很好使用的CentOS5.2 Apache系统之前,像让大家对CentOS5.2 Apache系统有所了解,CentOS5.2 Apache搭建系统开发环境,然后对CentOS5.2 Apache系统全面讲解介绍,CentOS Linux的特点和版本CentOS社区的Linux发行版本被称为CentOS Li

对大家推荐很好使用的CentOS5.2 Apache系统之前,像让大家对CentOS5.2 Apache系统有所了解,然后对CentOS5.2 Apache系统全面讲解介绍,CentOS Linux的特点和版本CentOS社区的Linux发行版本被称为CentOS Linux,由于使用了由RHEL的源代码重新编译生成新的发行版本,CentOS Linux具有与RHEL产品非常好的兼容性,并且与生俱来地拥有RHEL的诸多优秀特性。希望对大家有用。CentOS5.2 Apache下搭建Ruby on Rails开发环境 最近看上了Ruby on Rails的敏捷开发技术了,虽然早已不是什么新鲜玩意了,不过看着它越来越流行了,还是想看一看里面的究竟啊, 先从搭建Ruby on Rails的环境入手吧。

1.CentOS5.2 Apache下安装Ruby
rails框架也是Ruby做的,自然要先安装Ruby了,yum install ruby -y确认一下Ruby -v

2.CentOS5.2 Apache下安装RubyGems
RubyGems是Ruby函数库的管理系统在此之前先要导入dlutter软件仓库[[email protected] ~]# vi /etc/yum.repos.d/dlutter.repo修改成[dlutter]name=Unsupported RHEL5 packages (lutter)baseurl=http://people.redhat.com/dlutter/yum/rhel/5/$basearch/enabled=0gpgcheck=0确认[[email protected] ~]# yum --enablerepo=dlutter list然后直接用命令安装RubyGems [[email protected] ~]# yum --enablerepo=dlutter -y install rubygems.noarch 确认版本[[email protected] ~]# gem --version1.2.0安装好应该是1.2.0的版本,最新是1.3.0的,有兴趣的朋友可以用源码编译升级

3.rails框架的导入
这个比较简单,直接用RubyGems来安装[[email protected] ~]# gem install rails

4.最关键也是比较复杂的一步是CentOS5.2 Apache下 Web服务器的导入
关于Web服务器的选择,通常有很多争议,就Ruby on Rails而言,很多都是采用lighttpd当作Web Server,当作FastCGI应用程序来跑,但是lighttpd还是很难代替CentOS5.2 Apache的地位,特别是Rails程序以外还有其他Web程序的时候、不大可能完全移植到lighttpd上的,所以在这里,只是Rails程序跑在lighttpd上,对Rails程序的请求通过CentOS5.2 Apache下转送过来。先安装FastCGI
[[email protected] ~]# wget http://www.fastcgi.com/dist/fcgi-2.4.0.tar.gz
[[email protected] ~]# tar zxvf fcgi-2.4.0.tar.gz
[[email protected] ~]# cd fcgi-2.4.0
[[email protected] fcgi-2.4.0]# ./configure
[[email protected] ~]# gem install fcgi
[[email protected] fcgi-2.4.0]# make
[[email protected] fcgi-2.4.0]# make install
[[email protected] fcgi-2.4.0]# cd
[[email protected] ~]# rm -rf fcgi-2.4.0*

下面用RubyGems把Ruby的FastCGI的包导进来接下去就要安装lighttpd服务器了,先导入RPMforge 软件仓库
[[email protected] ~]# wget http://dag.wieers.com/packages/rpmforge-release/rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[[email protected] ~]# rpm -Uhv rpmforge-release-0.3.6-1.el5.rf.i386.rpm
[[email protected] ~]# vi /etc/yum.repos.d/rpmforge.repoenabled = 1enabled = 0
[[email protected] ~]# wget http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt
[[email protected] ~]# rpm --import RPM-GPG-KEY.dag.txt
确认[[email protected] ~]# yum --enablerepo=rpmforge list

开始安装
[[email protected] ~]# yum --enable=rpmforge install lighttpd
[[email protected] ~]# yum --enable=rpmforge install lighttpd-fastcgi一般系统已经有CentOS5.2 Apache下服务了,为了避免冲突,还要配置一下lighttpd,
[[email protected] ~]# vi /etc/lighttpd/lighttpd.conf#"mod_rewrite",#"mod_redirect",#"mod_alias","mod_rewrite","mod_redirect","mod_alias","mod_fastcgi","mod_fastcgi",
#server.port= 81server.port= 3000  ←端口设置成3000不要与CentOS5.2 Apache下的重复#server.bind= "127.0.0.1"server.bind= "localhost" 自启动[[email protected] ~]# chkconfig lighttpd on

Rails应用程序的基本设置
[[email protected] ~]# cd /srv/www/lighttpd
[[email protected]]# mkdir rails
[[email protected]]# rails ./rails

赋予lighttpd用户的权限
[[email protected] ~]# cd
[[email protected] ~]# chown -R lighttpd. /srv/www/lighttpd/rails
[[email protected] ~]# chmod +x /srv/www/lighttpd/rails/public/dispatch.*

CentOS5.2 Apache下的设
[[email protected] ~]# vi /etc/lighttpd/lighttpd.conf
加在末尾$HTTP["host"] =~ "ithurricane.dip.jp" {server.document-root = "/srv/www/lighttpd/rails/public"alias.url = ( "/" => "/srv/www/lighttpd/rails/public/" )server.indexfiles = ( "index.html", "dispatch.fcgi" )accesslog.filename = "/var/log/lighttpd/access.log"server.errorlog = "/var/log/lighttpd/server.log"server.error-handler-404 = "/dispatch.fcgi"
url.rewrite = ( "^/$" => "index.html", "^([^.]+)$" => "$1.html" )

fastcgi.server = (".fcgi" => ("localhost" => ("socket" => "/tmp/rails.fcgi.socket","bin-path" => "/srv/www/lighttpd/rails/public/dispatch.fcgi","bin-environment" => ("RAILS_ENV" => "production","RAILS_ROOT" => "/srv/www/lighttpd/rails"),"idol-timeout" => 10,"check-local" => "disable","min-procs" => 1,"max_procs" => 20)))}[[email protected] ~]# /etc/init.d/lighttpd start下面还要设置一下CentOS5.2 Apache下把对Rails的请求转发到lighttpd[[email protected] ~]# vi /etc/httpd/conf.d/virtualhost.conf
ServerName ithurricane.dip.jp
ProxyRequests Off
ProxyPreserveHost On
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://127.0.0.1:3000/
大功告成,重载一下设定即可[email protected] ~]# /etc/init.d/httpd reload最后导入图像处理库,和数据库SQLite3,这些都比较简单,一笔带过了,
[[email protected] ~]# yum install freetype
[[email protected] ~]# yum install libpng
[[email protected] ~]# yum install gd-devel
[[email protected] ~]# gem install ruby-gd -- --build-flag --with-freetype
[[email protected] ~]# gem install sqlite3-rubySelect which gem to install for your platform (i686-linux)
1. sqlite3-ruby 1.2.1 (ruby)
2. sqlite3-ruby 1.2.1 (mswin32)
3. sqlite3-ruby 1.2.0 (mswin32)
4. sqlite3-ruby 1.2.0 (ruby)
5. Skip this gem
6. Cancel installation> 1终于完成了,把rails的服务打开来,看看成果吧,注意跑的是CentOS5.2 Apache下的80端口

Tags:CentOS Apache 搭建

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接