前言
蒲公英,維護后把我上傳的包清除了,所以想自己搭建一個用下。
步驟
項目用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的版本的就跑起來了
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;
}
總結
整個部署起來,其實難度不大,不過解析包有點慢,下載的時候也有點慢(服務器網絡原因),如果可以接入外部存儲就好咯