APP——Ruby开源分发平台搭建

前言

蒲公英,维护后把我上传的包清除了,所以想自己搭建一个用下。

步骤

项目用ruby语言写的,部署起来也很简单支持源码和Docker部署

GitHub | https://github.com/pluosi/app-host

安装Ruby并配置为国内源

安装Ruby的包

# yum install ruby rubygems ruby-devel -y
# gem -v
2.7.8
# gem sources --add https://gems.ruby-china.com/ --remove https://rubygems.org/
https://gems.ruby-china.com/ added to sources
source https://rubygems.org/ not present in cache
# gem sources -l
*** CURRENT SOURCES ***

https://gems.ruby-china.com/

安装puma

# gem install puma

运行项目

# git clone https://github.com/pluosi/app-host.git /opt/app-host
# cd /opt/app-host
# cp config/settings.local.example.yml config/settings.local.yml
修改 config/settings.local.yml 中 `PROTOCOL` 和 `HOST` ,本地测试PROTOCOL可以为 http,生产环境必须设置为https,因为 iOS OTA 安装需要
bundle install
rails s 运行测试环境
关于部署到生成环境的话请参照一下 rails puma 部署等教程,需要修改一下 config/deply.rb 的部署地址
尝试访问 http://localhost:3000

期间遇到了一个错,ruby版本的问题,重新安装了2.5.1的版本的就跑起来了

Ruby——报错总结

Nginx配置

 if ($ssl_protocol = "") { return 301 https://$host$request_uri; }

  location / {
                                proxy_set_header Host $host:$server_port;
                                proxy_set_header  X-Real-IP $remote_addr;
                                proxy_set_header x-forwarded-for $remote_addr;
                                proxy_pass http://127.0.0.1:3000;
        }

  include /usr/local/nginx/conf/rewrite/none.conf;
  #error_page 404 /404.html;
  #error_page 502 /502.html;

  location ~ [^/]\.php(/|$) {
    #fastcgi_pass remote_php_ip:9000;
    fastcgi_pass unix:/dev/shm/php-cgi.sock;
    fastcgi_index index.php;
    include fastcgi.conf;
  }

  location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|flv|mp4|ico)$ {
     proxy_pass http://127.0.0.1:3000;
    expires 30d;
    access_log off;
  }
  location ~ .*\.(js|css)?$ {
     proxy_pass http://127.0.0.1:3000;
    expires 7d;
    access_log off;
  }

总结

整个部署起来,其实难度不大,不过解析包有点慢,下载的时候也有点慢(服务器网络原因),如果可以接入外部存储就好咯

猜你喜欢

转载自www.cnblogs.com/wangyang0210/p/11846157.html