部署出现❌:
terminal输入:
ssh root@xx.xx.xx.xx进入root目录
root@iZ8vb9z1vsb31g6zoqqt0bZ:~# pwd
/root
但这“/”才是真正的根目录。
如/var/log/nginx/error.log这是告诉我var目录是在“/”目录下的.
所以:
root@iZ8vb9z1vsb31g6zoqqt0bZ:~# cd / root@iZ8vb9z1vsb31g6zoqqt0bZ:/# ls bin etc initrd.img.old lost+found opt run sys var boot home lib media proc sbin tmp vmlinuz dev initrd.img lib64 mnt root srv usr vmlinuz.old
忘记配置:
执行 cap install
,这会新增一些配置档案。
编辑 Capfile
:
Capfile
require "capistrano/scm/git"
install_plugin Capistrano::SCM::Git
+ require 'capistrano/rails'
+ require 'capistrano/passenger'
再试出现新的❌!
Gem::Ext::BuildError: ERROR: Failed to build gem native extension. 。。。略。。 An error occurred while installing sassc (1.12.1), and Bundler cannot continue. Make sure that `gem install sassc -v '1.12.1' --source 'https://gems.ruby-china.com/'` succeeds before bundling. In Gemfile: font-awesome-sass was resolved to 5.2.0, which depends on sassc bundle stderr: Nothing written ** DEPLOY FAILED ** Refer to log/capistrano.log for details. Here are the last 20 lines: `block (2 levels) in <top (required)>' /home/deploy/Trello/shared/bundle/ruby/2.5.0/gems/rake-12.3.1/exe/rake:27:in `<main>' Tasks: TOP => lib/libsass.so (See full trace by running task with --trace) rake failed, exit code 1 Gem files will remain installed in /home/deploy/Trello/shared/bundle/ruby/2.5.0/gems/sassc-1.12.1 for inspection. Results logged to /home/deploy/Trello/shared/bundle/ruby/2.5.0/extensions/x86_64-linux/2.5.0/sassc-1.12.1/gem_make.out An error occurred while installing sassc (1.12.1), and Bundler cannot continue. Make sure that `gem install sassc -v '1.12.1' --source 'https://gems.ruby-china.com/'` succeeds before bundling. In Gemfile: font-awesome-sass was resolved to 5.2.0, which depends on sassc
无法确认问题的出处,准备重装。
避开程序,
- 换一个简单的程序。
拖拉的网页:先使用Heroku试一下。是否正常上线
新问题:
输入:cap production deploy
00:16 deploy:assets:precompile 01 bundle exec rake assets:precompile 01 Yarn executable was not detected in the system. 01 Download Yarn at https://yarnpkg.com/en/docs/install 01 I, [2018-10-29T19:59:49.506978 #22896] INFO -- : Writing /home/deploy/vue-todolist/release… 01 I, [2018-10-29T19:59:49.507644 #22896] INFO -- : Writing /home/deploy/vue-todolist/release… 01 I, [2018-10-29T19:59:49.539748 #22896] INFO -- : Writing /home/deploy/vue-todolist/release… 01 I, [2018-10-29T19:59:49.540210 #22896] INFO -- : Writing /home/deploy/vue-todolist/release… 01 sh: 1: 01 node: not found 01 01 Webpacker requires Node.js >= 6.0.0 and you are using 4.2.6 01 Please upgrade Node.js https://nodejs.org/en/download/
我的app,安装了yarn, 但是服务器没有安装yarn;
sudo apt-get update && sudo apt-get install yarn
参考:
https://github.com/yarnpkg/yarn/issues/2821
安装nodejs
官网 ,选择Ubuntu连接进入git
Node.js v10.x: # Using Ubuntu curl -sL https://deb.nodesource.com/setup_10.x | sudo -E bash - sudo apt-get install -y nodejs
参考:
https://blog.csdn.net/well2049/article/details/79138045
上一个问题通过:又遇到新的问题:
00:12 deploy:assets:precompile 01 bundle exec rake assets:precompile 01 yarn install v1.10.1 01 [1/4] Resolving packages... 01 [2/4] Fetching packages... 01 info fsevents@1.2.4: The platform "linux" is incompatible with this module. 01 info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Excluding i… 01 [3/4] Linking dependencies... 01 warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@… 01 warning " > vue-loader@14.2.2" has unmet peer dependency "css-loader@*". 01 warning " > webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 || ^3.0.0". 01 warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer dependency "web… 01 [4/4] Building fresh packages... 01 success Saved lockfile. 01 Done in 161.28s. 01 Webpacker is installed 🎉 🍰 01 Using /home/deploy/vue-todolist/releases/20181029131732/config/webpacker.yml file for setti… 01 Compiling… 01 Compiled all packs in /home/deploy/vue-todolist/releases/20181029131732/public/packs ✔ 01 deploy@47.92.202.0 186.048s 03:18 deploy:assets:backup_manifest 01 mkdir -p /home/deploy/vue-todolist/releases/20181029131732/assets_manifest_backup ✔ 01 deploy@47.92.202.0 0.093s 02 cp /home/deploy/vue-todolist/releases/20181029131732/public/assets/.sprockets-manifest-dd3a… ✔ 02 deploy@47.92.202.0 0.097s 03:18 deploy:migrate [deploy:migrate] Run `rake db:migrate` 03:19 deploy:migrating 01 bundle exec rake db:migrate 01 rake aborted! 01 ActiveRecord::NoDatabaseError: FATAL: database "rails_recipes" does not exist 01 /home/deploy/vue-todolist/shared/bundle/ruby/2.5.0/gems/activerecord-5.2.1/lib/active_recor… 01 /home/deploy/vue-todolist/shared/bundle/ruby/2
发现错误❌!!,没改!!
production: adapter: postgresql pool: 25 database: rails_recipes host: localhost username: postgres password: xxxxxxxxxx
数据库操作。
https://itbilu.com/database/postgre/410auo8xZ.html
新问题:
执行 sudo service nginx restart
Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.
server { listen 80; server_name 47.92.82.116; # 用你自己的服务器 IP 位置 root /home/deploy/rails-recipes/current/public; # 用你自己的项目名称位置 passenger_enabled on; passenger_min_instances 1; location ~ ^/assets/ { expires 1y; add_header Cache-Control public; add_header ETag ""; break; } :} #多输入了一个冒号!
最后成功部署,不过又有新的问题!
显示<body></body> 内是空的!!!
也就是说vue.js没有部署到位!
这是因为vue.js的单页面应用需要部署。
一上午浏览网上,能够教vue.js部署的帖子。并没有现成的解决方案!
第一,部署方面的了解。几乎都不了解。所以网上的一些相关知识点,比较懵圈。
第二,关于vue-cli有部署的实例,但我没有学习vue-cli。和我目前要解决的问题,也不相关。
想法:
学习部署已经2天了,遇到不少坑,也挣扎爬出来。到vue方面的部署,我暂时不能解决。
所以,暂时停下来,先看一些其他相关知识点。
- 了解一下webpack。
- GoRails有教用Heroku的视频看一下。
- Linux基本运维知识,学习一下。
- 目前最重要的事情是什么应该这2天赶紧了!
使用passwd命令修改密码
参考man passwd
在root下输入:passwd xxx, 就可以修改xxx的密码了!
01:54 deploy:assets:precompile 01 bundle exec rake assets:precompile 01 yarn install v1.12.1 01 [1/4] Resolving packages... 01 [2/4] Fetching packages... 01 info fsevents@1.2.4: The platform "linux" is incompatible with this module. 01 info "fsevents@1.2.4" is an optional dependency and failed compatibility check. Ex… 01 [3/4] Linking dependencies... 01 warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "cani… 01 warning " > vue-loader@14.2.2" has unmet peer dependency "css-loader@*". 01 warning " > webpack-dev-server@2.11.2" has unmet peer dependency "webpack@^2.2.0 |… 01 warning "webpack-dev-server > webpack-dev-middleware@1.12.2" has unmet peer depend… 01 [4/4] Building fresh packages...
网上的找的一个方法,没有成功仍然会报告❌。
网上找到一篇 Nginx 教程 (中英)
https://www.oschina.net/translate/nginx-tutorial-basics-concepts?cmp
尝试使用其他方式部署,尝试一下。还是找不到解决办法,暂时搁置!
尝试action cable的部署:
输入cap production deploy,走到 bundler:install时,❌:
在bunder之前先安装gem install sassc -v '1.12.1 ?
An error occurred while installing sassc (1.12.1), and Bundler cannot continue.
Make sure that `gem install sassc -v '1.12.1' --source
'https://gems.ruby-china.com/'` succeeds before bundling.
gem 'font-awesome-sass' 有问题,移除它并去掉asset中的require ..后,运行cap production deploy即可成功。