• 使用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
  • 相关阅读:
    耐性4/21
    吃枸杞上火4/11
    metro style app 的程序构成 以c# 为例 GIS
    ListView 和 GridView ————转 GIS
    最大程度地利用像素,适应视图状态的变更___转 GIS
    metro style 里面的控件一览 以 Windows.UI.Xaml.Controls空间 GIS
    Windows 8里的标准化输入 GIS
    漫游应用程序数据 GIS
    FlipView 知识准备 GIS
    Data Binding Notifications绑定通知 GIS
  • 原文地址:https://www.cnblogs.com/Enzoo/p/15642518.html
Copyright © 2020-2023  润新知