<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>琪埃信息系统（上海）有限公司 &#187; Ruby</title>
	<atom:link href="http://www.qiais.com/achives/category/ruby/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.qiais.com</link>
	<description>琪埃信息系统</description>
	<lastBuildDate>Tue, 11 Feb 2020 01:50:29 +0000</lastBuildDate>
	<language>zh-CN</language>
		<sy:updatePeriod>hourly</sy:updatePeriod>
		<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.0</generator>
	<item>
		<title>CentOS+Ruby on rails+Apache构建ruby的web程序</title>
		<link>http://www.qiais.com/achives/764/</link>
		<comments>http://www.qiais.com/achives/764/#comments</comments>
		<pubDate>Thu, 11 Sep 2014 08:04:40 +0000</pubDate>
		<dc:creator><![CDATA[sai]]></dc:creator>
				<category><![CDATA[CentOS]]></category>
		<category><![CDATA[Ruby]]></category>

		<guid isPermaLink="false">http://www.qiais.com/?p=764</guid>
		<description><![CDATA[关于Ruby是什么，Ruby on rails是什么，这里不做介绍，请参看官方网站。 这主要是讨论如何在Cen...]]></description>
				<content:encoded><![CDATA[<p>关于Ruby是什么，Ruby on rails是什么，这里不做介绍，请参看官方网站。</p>
<p>这主要是讨论如何在CentOS上架设Ruby on rails的web应用程序。</p>
<p>1. 如何安装CentOS，请参考<a href="http://www.qiais.com/achives/77/" title="安装Linux(Centos6)服务器" target="_blank">安装Linux(Centos6)服务器</a><br />
2. 如何安装Apache，请参考<a href="http://www.qiais.com/achives/92/" title="在Linux(CentOS6)上搭建Apache2+Mysql5+PHP5开发环境" target="_blank">在Linux(CentOS6)上搭建Apache2+Mysql5+PHP5开发环境</a><br />
3. 安装Ruby 2以及Rails 3<br />
   Linux上管理安装Ruby的最好方法莫过于RVM(Ruby Version Manager)了，RVM可以很轻松的管理Ruby的各个版本，方便的切换Ruby版本。<br />
   最新的RVM可以通过下面的命令获取，安装。请使用root登录导系统进行操作。</p>
<pre class="brush: plain; title: ; notranslate">
# curl -L get.rvm.io | bash -s stable 
# source /etc/profile.d/rvm.sh 
</pre>
<p>  安装RVM必要的包以及相关软件</p>
<pre class="brush: plain; title: ; notranslate">
rvm requirements 
</pre>
<p>  安装Ruby, 现时最新版本伟2.1.2</p>
<pre class="brush: plain; title: ; notranslate">
rvm install 2.1.2
</pre>
<p>  将2.1.2设置为默认使用版本</p>
<pre class="brush: plain; title: ; notranslate">
rvm use 2.0.0 --default
</pre>
<p>  安装Rails，这需要一定的时间，请耐心等待</p>
<pre class="brush: plain; title: ; notranslate">
gem install rails
</pre>
<p>  查看已安装Ruby以及Rails版本</p>
<pre class="brush: plain; title: ; notranslate">
# ruby -v
ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux]
# rails -v
Rails 3.2.13
#
</pre>
<p>4. 安装Phusion Passenger</p>
<p>  Phusion Passenger是一应用服务器，经常被用在Ruby的web应用程序上或网站上，以Ruby的gem的形式发布。</p>
<p>  安装Phusion Passenger gem</p>
<pre class="brush: plain; title: ; notranslate">
gem install passenger 
</pre>
<p>  安装Apache的两个包</p>
<pre class="brush: plain; title: ; notranslate">
yum install curl-devel httpd-devel 
</pre>
<p>编译Apache的Phusion Passenger模块</p>
<pre class="brush: plain; title: ; notranslate">
passenger-install-apache2-module  
</pre>
<p>编译过程中会出现类似于下面的信息，需要将其手动设置到/etc/httpd/conf/httpd.conf中</p>
<pre class="brush: plain; title: ; notranslate">
   LoadModule passenger_module /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.50/buildout/apache2/mod_passenger.so
   &lt;IfModule mod_passenger.c&gt;
     PassengerRoot /usr/local/rvm/gems/ruby-2.1.2/gems/passenger-4.0.50
     PassengerDefaultRuby /usr/local/rvm/gems/ruby-2.1.2/wrappers/ruby
   &lt;/IfModule&gt;
</pre>
<p>5. Rails简单程序</p>
<p>  准备</p>
<pre class="brush: plain; title: ; notranslate">
# yum install sqlite-devel
# cd /home/mokuzai
</pre>
<p> 创建站点</p>
<pre class="brush: plain; title: ; notranslate">
# rails new mokuzai-point 
# cd mokuzai-point
</pre>
<p>  执行bundle install命令</p>
<pre class="brush: plain; title: ; notranslate">
bundle install
</pre>
<p>  初始化数据库</p>
<pre class="brush: plain; title: ; notranslate">
rake db:migrate 
</pre>
<p>创建虚拟站点</p>
<pre class="brush: plain; title: ; notranslate">
  RackEnv development
&lt;VirtualHost *:80&gt; 
 ServerName mokuzai-point.hanbai.jp 
 # !!! Be sure to point DocumentRoot to 'public'! 
 DocumentRoot /home/mokuzai/mokuzai-point/public 
 &lt;Directory /home/mokuzai/mokuzai-point/public&gt; 
 # This relaxes Apache security settings. 
 AllowOverride all 
 # MultiViews must be turned off. 
 Options -MultiViews 
 &lt;/Directory&gt; 
&lt;/VirtualHost&gt;
</pre>
<p>  重启Apache</p>
<pre class="brush: plain; title: ; notranslate">
service httpd restart
</pre>
<p>确认<br />
<a href="http://mokuzai-point.hanbai.jp" title="http://mokuzai-point.hanbai.jp" target="_blank">http://mokuzai-point.hanbai.jp</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.qiais.com/achives/764/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
