您的位置:首页 > 编程语言 > Ruby

在ubuntu操作系统中安装ruby,rails,mysql的详细步骤(一)

2012-12-30 20:48 666 查看
Ruby语言现在正在成为社会的主流语言之一,因为他全部采用面向对象的思想,使得变成比起其他语言要来得方便,本人亲自试过,一个相同的功能用ruby和java来写,明显可以看到ruby只要写java的一半就可以实现了。
好了,废话不多说了,一开始接触ruby的时候是比较烦恼的,以为他有诸多的配置要安装,接下来我来给大家讲述一下详细的安装步骤:

第一:安装ruby(推荐大家用rvm安装ruby)

先讲讲选择rvm的原因:RVM的主要作用是方便的管理系统中的多个ruby版本而不至于混乱,如果是其他安装就只能够安装一种版本,但是对于ruby开发人员来说一种版本是远远不够的。

第一步:安装rvm需要curl,首先要先看一下ubuntu系统里面有没有安装curl,使用命令dpkg-scurl检查一下。


如果出现以下显示说明已经有了curl:

proper@ubuntu:~$dpkg-scurl
Package:curl
Status:installokinstalled
Priority:optional
Section:web
Installed-Size:364
Maintainer:UbuntuDevelopers<ubuntu-devel-discuss@lists.ubuntu.com>
Architecture:i386
Version:7.21.3-1ubuntu1.5
Replaces:curl-ssl
Provides:curl-ssl
Depends:libc6(>=2.7),libcurl3(>=7.16.2-1),zlib1g(>=1:1.1.4)
Description:GetafilefromanHTTP,HTTPSorFTPserver
curlisaclienttogetfilesfromserversusinganyofthesupported
protocols.Thecommandisdesignedtoworkwithoutuserinteraction
oranykindofinteractivity.
.
curloffersabusloadofusefultrickslikeproxysupport,user
authentication,ftpupload,HTTPpost,filetransferresumeandmore.
Homepage:http://curl.haxx.se
Original-Maintainer:RamakrishnanMuthukrishnan<rkrishnan@debian.org>


如果出现以下显示说明还没有curl:

proper@ubuntu:~$dpkg-scurl
Package`curl'isnotinstalledandnoinfoisavailable.
Usedpkg--info(=dpkg-deb--info)toexaminearchivefiles,
anddpkg--contents(=dpkg-deb--contents)tolisttheircontents.


那我们就必须要执行命令:sudoapt-getinstallcurl安装curl软件包(附带卸载curl的方法:sudoapt-getremovecurl),安装完成后我们就可以安装rvm了


执行命令:curl-Lget.rvm.io|bash-sstable安装rvm,安装完成后会显示如下:

proper@ubuntu:~$curl-Lget.rvm.io|bash-sstable
%Total%Received%XferdAverageSpeedTimeTimeTimeCurrent
DloadUploadTotalSpentLeftSpeed
100109561001095600110900:00:090:00:09--:--:--6873
DownloadingRVMfromwayneeseguinbranchstable
%Total%Received%XferdAverageSpeedTimeTimeTimeCurrent
DloadUploadTotalSpentLeftSpeed
1001243k1001243k007609700:00:160:00:16--:--:--138k
InstallingRVMto/home/proper/.rvm/
RVMPATHlinefoundin/home/proper/.bashrc/home/proper/.zshrc.
RVMsourcinglinefoundin/home/proper/.bash_profile/home/proper/.zprofile.
#RVM:Shellscriptsenablingmanagementofmultiplerubyenvironments.
#RTFM:https://rvm.io/
#HELP:http://webchat.freenode.net/?channels=rvm(#rvmonirc.freenode.net)
#Cheatsheet:http://cheat.errtheblog.com/s/rvm/
#Screencast:http://screencasts.org/episodes/how-to-use-rvm
#Incaseofanyissuesreadoutputof'rvmrequirements'and/or'rvmnotes'
InstallationofRVMin/home/proper/.rvm/isalmostcomplete:
*TostartusingRVMyouneedtorun`source/home/proper/.rvm/scripts/rvm`(这边提示我们接下来我们应该要运行这一命令,请看下面)
inallyouropenshellwindows,inrarecasesyouneedtoreopenallshellwindows.
#proper,
#
#ThankyouforusingRVM!
#IsincerelyhopethatRVMhelpstomakeyourlifeeasierand
#moreenjoyable!!!
#
#~Wayne

显示内容中提示我们要运行命令:source/home/proper/.rvm/scripts/rvm(这行命令千万不能直接复制我的,一定要到自己的上面显示的内容里面找到对应的,千万不能照搬,要不然会出大事的)
现在可以查看自己安装的rvm的版本:
通过命令:rvm-v
得到如下显示:
proper@ubuntu:~$rvm-v
rvm1.17.6(stable)byWayneE.Seguin<wayneeseguin@gmail.com>,MichalPapis<mpapis@gmail.com>[https://rvm.io/]
我的版本是1.17.6的。

接下来看似不重要其实是非常之重要的,要不然你会在以后安装的时候出错的,通过rvmrequirements命令,可以察看安装各版本时候的前提条件。
显示如下:
proper@ubuntu:~$rvmrequirements
RequirementsforLinux"Ubuntu11.04"
NOTE:'ruby'representsMatz'sRubyInterpreter(MRI)(1.8.X,1.9.X)
Thisisthe*original*/standardRubyLanguageInterpreter
'ree'representsRubyEnterpriseEdition
'rbx'representsRubinius
bash>=4.1required
curlisrequired
gitisrequired(>=1.7forruby-head)
patchisrequired(for1.8rubiesandsomeruby-head's).
Toinstallrbxand/orRuby1.9head(MRI)(eg.1.9.2-head),
thenyoumustinstallanduservm1.8.7first.
AdditionalDependencies:
#ForRuby/RubyHEAD(MRI,Rubinius,&REE),installthefollowing:
ruby:/usr/bin/apt-getinstallbuild-essentialopenssllibreadline6libreadline6-devcurlgit-corezlib1gzlib1g-devlibssl-devlibyaml-devlibsqlite3-devsqlite3libxml2-devlibxslt-devautoconflibc6-devncurses-devautomakelibtoolbisonsubversionpkg-config(其中这句是需要关注的。这是安装依赖的第三方包,没有这个安装不成功岂不是很悲剧?因此接下来就是要安装这个安装包,当然和前面一样,不要拷贝我的,要找到你自己对应的,如果不安装,之后就无法安装rails,会很蛋疼的,而且找不到错误所在)
#ForJRuby,installthefollowing:
jruby:/usr/bin/apt-getinstallcurlg++openjdk-6-jre-headless
jruby-head:/usr/bin/apt-getinstallantopenjdk-6-jdk
#ForIronRuby,installthefollowing:
ironruby:/usr/bin/apt-getinstallcurlmono-2.0-devel
#ForOpal,installthefollowing:
opal:/usr/bin/apt-getinstallnodejsnpm

因此接下来就应该是安装上面所说的第三方包:sudo/usr/bin/apt-getinstallbuild-essentialopenssllibreadline6libreadline6-devcurlgit-corezlib1gzlib1g-devlibssl-devlibyaml-devlibsqlite3-devsqlite3libxml2-devlibxslt-devautoconflibc6-devncurses-devautomakelibtoolbisonsubversionpkg-config
(一定要对应好了哟,千万别忘了开头的sudo)

这样一来,安装ruby的准备工作就完成了。接下来就是要安装ruby了,请看《在ubuntu操作系统中安装ruby,rails,mysql的详细步骤(二)》

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: