zoukankan      html  css  js  c++  java
  • 使用Debian 10下安装Ruby on Rails与NGINX 应用程序

    借鉴文章:

    https://cloud.tencent.com/developer/article/1338342

    系统Debian 10  内核版本  查看命令  uname -r

    Debian 10  系统查看

    cat /etc/issue

    首先安装RVM Ruby-2.7.2 Gems Bundle 等组件  

    使用官方RVM安装脚本:

    curl -sSL https://get.rvm.io | bash -s stable --ruby

    安装过程 等着跑就好, 如果有相关依赖没有安装,根据提示进行排错。

    没有source 是识别不到命令的

    解决办法:

    安装过程将输出必须在使用RVM之前运行的命令:

    source  /home/tony/.bashrc

    source  /home/tony/.bash_profile

    source /etc/profile

    source /home/tony/.rvm/scripts/rvm

     sudo rvm requirements

     

     使用rvm 安装ruby-2.7.2

     cd 到用户的home目录下

     

    cd /home/tony/

    然后在.rvmrc 文件中添加一行内容:

    To ignore this error add rvm_silence_path_mismatch_check_flag=1 to your ~/.rvmrc file.

    rvm_silence_path_mismatch_check_flag=1

    安装ruby 2.7.2  完成后的界面如下:

     设置ruby 2.7.2 默认版本:

    使用rvm 并用rvm 安装ruby-2.7.2  并设置为默认的命令:

    sudo rvm install ruby-2.7.2 rvm --default use ruby-2.7.2

    生产环境下的secret_key_base ,命令如下

    RAILS_ENV=production rake secret 

    将生成的随机字符串拷贝到config/secret.yml 文件中, 

    如果要运行  生产环境的 rails 程序 需要在程序目录下 运行:

    RAILS_ENV=production rails s&

    数据库也需要  使用 RAILS_ENV=production rails db:migrate

    rails 程序的 database配置文件路径是 在项目 目录下的 config目录下的./config/database.yml

    以守护进程方式启动rails   直接在 命令后面加&

     通过database.yml 文件来配置 rails 程序连接数据库 

    在我的环境中是连接的是 Ali 的 RDS 数据库

    production:
    <<: *default
    url: mysql2://xxxxx.mysql.rds.aliyuncs.com
    database: database_production
    adapter: mysql2
    encoding: utf8
    port: 3306
    username: cxxx
    password: <%= ENV['xxxx_DATABASE_PASSWORD'] %>

    配置好database之后 启动 rails 项目 没有报错说明启动成功了。

    执行db migrate 没有报错截图如下:

    博文阅读密码felix
  • 相关阅读:
    记一次动态依赖包版本过高解决过程
    Centos8更改国内源阿里云
    记一次vs2019安装GDB实现Cmake远程linux调试
    Tu te prends pour qui?
    中国高等教育是个啥:官僚主义的垄断黑洞
    关闭ThinkPad HDD APS Logging Service
    python Tlinter按钮接收多个参数
    第一章
    IE7的一个边界BUG
    让LumaQQ.NET支持接收群自定义表情和贴图
  • 原文地址:https://www.cnblogs.com/Enzoo/p/15642518.html
Copyright © 2011-2022 走看看