ubuntu部署homeland
现在部署homeland可以使用docker部署,很方便,但是修改代码很麻烦,所以我打算自己部署
homeland git https://github.com/ruby-china/homeland
部署说明:
Please read this document: CONTRIBUTE GUIDE
sudo apt-get install memcached postgresql postgresql-contrib redis-server imagemagick ghostscript
安装Elasticsearch
curl -sSL https://git.io/vVHhm | bash
homeland就先到这里,我们先把nginx+passenger部署好在进行后续的homeland安装
nginx+passenger部署可参考官方文档
第一步:选择nginx
第二步: 选择开源passenger, passenger open source
第三步:准备环境
sudo apt-get update
sudo apt-get install -y curl gnupg build-essential
第四步:安装rvm和ruby,当如可以直接安装ruby,但ruby必须2.4版本以上
rvm我是之前按照官方文档安装好了
rvm安装好了使用rvm install x.x.x, 我安装的是2.4.2
安装好后设置为默认ruby环境
rvm --default use ruby-X.X.X
第四步: 安装bundler
gem install bundler --no-rdoc --no-ri
第五步:安装nodejs, 我也是参考官方文档安装的最新版本
第六步:安装nginx
sudo apt-get install nginx
第七步:安装passenger
sudo apt-get install -y dirmngr gnupg
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 561F9B9CAC40B2F7
sudo apt-get install -y apt-transport-https ca-certificates
sudo sh -c 'echo deb https://oss-binaries.phusionpassenger.com/apt/passenger xenial main > /etc/apt/sources.list.d/passenger.list'
sudo apt-get update
sudo apt-get install -y nginx-extras passenger
第八步:编辑nginx.conf
去掉include /etc/nginx/passenger.conf;前面的#
第九步:检查passenger,当然可以跳过
sudo /usr/bin/passenger-config validate-install
第十步:更新系统
sudo apt-get update
sudo apt-get upgrade
到此nginx+passenger安装完毕
配置postgresql
sudo su postgres
登陆数据库
psql
先为postgres设置密码
\password
退出
\q
新建一个用户并设置密码
sudo adduser myappuser
进入项目目录把代码拷贝下来
sudo -u myappuser -H git clone https://github.com/ruby-china/homeland.git code
使用新建的用户登陆系统
sudo -u myappuser -H bash -l
进入code
修改config目录下的database.yml.default和config.yml.default为自己的配置
修改log、public文件夹权限为777
运行./bin/setup
bundle install --deployment --without development test
bundle exec rake assets:precompile db:migrate RAILS_ENV=production
运行rails s看能否运行
接下来配置nginx和passenger
先运行
passenger-config about ruby-command
获取到passenger_ruby
然后进入nginx的site-enabled目录,修改default为default.conf
编辑default.conf,编辑想应的root和server_name,并注释掉localtion相关代码和index index.html index.htm
配置passenger
添加如下代码
passenger_enabled on;
passenger_ruby /path-to-ruby;
然后重启nginx
service nginx restart
重启之后运行我遇到了一个问题
[passenger_native_support.so] trying to compile for the current user (nobody) and Ruby interpreter
解决方法是在nginx的include /etc/nginx/passenger.conf;上面一行添加passenger_default_user adduser;
刚开始我没有注释default.conf里的location相关代码,结果是点击菜单报404错误
如果还有其他问题,更新下bundler和gem