Ubuntu 下搭建、部署 Ruby on rails
1、安装必要的三方库
$ sudo apt-get install -y wget vim build-essential openssl libreadline6 libreadline6-dev libmysqlclient-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev libxml2-dev libxslt-dev libcurl4-openssl-dev autoconf automake libtool imagemagick libmagickwand-dev libpcre3-dev nodejs libpq-dev2、安装 RVM
- $ curl -L https://get.rvm.io | bash -s stable
- $ echo '[[ -s "$HOME/.rvm/scripts/rvm" ]] && . "$HOME/.rvm/scripts/rvm"' >>~/.bashrc
- $ source ~/.bashrc
- $ rvm -v
- $ rvm pkg install readline openssl
- $ rvm install 2.4
- $ rvm use 2.4 --default
- $ ruby -v
- ruby 2.4.0p0 (2016-12-24 revision 57164) [x86_64-linux]
$ gem sources --remove https://rubygems.org/
$ gem sources -a https://ruby.taobao.org/
$ gem sources -l
*** CURRENT SOURCES ***
https://ruby.taobao.org # 请确保只有 ruby.taobao.org
- $ gem install rails
- $ rails -v
- Rails 4.0.0
rails -v 验证5、建立第一个rails程序
rails new demo
cd demo
rails server ,注意这个命令stop以后就自己停了,最好加&
准备开始hello world吧
rails generate controller Say hello
命令后会有如下提示
create app/controllers/say_controller.rb
route get 'say/hello'
invoke erb
create app/views/say
create app/views/say/hello.html.erb
invoke test_unit
create test/controllers/say_controller_test.rb
invoke helper
create app/helpers/say_helper.rb
invoke test_unit
invoke assets
invoke coffee
create app/assets/javascripts/say.coffee
invoke scss
create app/assets/stylesheets/say.scss
系统会自动生成这些文件,进入到app/views/say/hello.html.erb,随便改点
http://localhost:3000/say/hello
就可以啦
app/views/say/hello.html.erb
最新内容
- Linux系统下systemctl常用命令以及service文件配置
- CI PHP7 session 不能读取的问题
- centos 7.4 基本配置
- mysqldump导入导出数据库总结
- Linux下的tar压缩解压缩常用命令
- 查看 SELinux状态、临时关闭SELinux、永久关闭SELinux
- centos6.8 yum安装mysql 5.6
- CentOS之7与6的区别2
- CentOS之7与6的区别1
- Mysql 忘记root密码的完美解决方法
- 输入密码登录,Linux scp (rsync)设置nohup后台运行
- ubantu zabbix部署——安装配置zabbix agent详解
- Zabbix客户端(agent端口)安装配置
- CentOS 7添加开机启动服务/脚本
- 阿里云机器配置 centos 6.8