Deploy Ubuntu 18.04 Bionic Beaver Discussion
@leopauld The service is probably already running. Did you try running the systemctl status nginx
to see if it's already running and what the output is?
when I write that I have this result :
nginx.service - A high performance web server and a reverse proxy se
rver
Loaded: loaded (/lib/systemd/system/nginx.service; enabled; vendor preset: en
abled)
Active: failed (Result: exit-code) since Tue 2019-07-23 16:13:07 C
EST; 16h ago
Docs: man:nginx(8)
Process: 18148 ExecStartPre=/usr/sbin/nginx -t -q -g daemon on; master_process
on; (code=exited, status=203/EXEC)
In /usr/bin I don't have nginx ...
Hello,
I have a problem to deploy, I configured rbenv-vars correctly with my database and my secret key but when I launch cap production deploy, the execution doesn't work...
deploy@1.2.3.4.0's password:
00:00 git:wrapper
01 mkdir -p /tmp
✔ 01 deploy@1.2.3.4.0 0.137s
Uploading /tmp/git-ssh-myapp-production-username.sh 100.0%
02 chmod 700 /tmp/git-ssh-myapp-production-username.sh
✔ 02 deploy@1.2.3.4.0 0.173s
00:00 git:check
01 git ls-remote git@github.com:UserName/myapp.git HEAD
01 Permission denied (publickey).
01 fatal: Could not read from remote repository.
01
01 Please make sure you have the correct access rights
01 and the repository exists.
Hmmm tried this from a fresh rails 6 app.
cap production deploy
is failing with
/home/userme/.rbenv/versions/2.6.3/lib/ruby/gems/2.6.0/gems/sshkit-1.20.0/lib/sshkit/runners/parallel.rb:15:in `rescue in block (2 levels) in execute': Exception while executing as userme@123.456.789.10: rake exit status: 1 (SSHKit::Runner::ExecuteError)
$HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
Compiling…
Compilation failed:
error Command "webpack" not found.
Webpacker docs is saying Make sure you have public/packs and node_modules in :linked_dirs
for capistrano deployments. Then If you have node_modules added to :linked_dirs you'll need to run yarn install before deploy:assets:precompile
and they have a snippet to add to your deploy.rb
...
before "deploy:assets:precompile", "deploy:yarn_install"
namespace :deploy do
desc "Run rake yarn install"
task :yarn_install do
on roles(:web) do
within release_path do
execute("cd #{release_path} && yarn install --silent --no-progress --no-audit --no-optional")
end
end
end
end
Testing this now to see if it works... 10 mins later... nope... still busted... will try again later :/
I believe I may need to add capistrano-npm
to my Gemfile so npm install
can be run in the capistrano deploy scripts.
Ubuntu 18.04, Digitalocean
rbenv getting error with information that it can be installed with apt package.
root@testinghttp:~# git clone https://github.com/rbenv/rbenv-vars.git ~/.rbenv/plugins/rbenv-vars
Cloning into '/root/.rbenv/plugins/rbenv-vars'...
remote: Enumerating objects: 97, done.
remote: Total 97 (delta 0), reused 0 (delta 0), pack-reused 97
Unpacking objects: 100% (97/97), done.
root@testinghttp:~# exec $SHELL
Command 'rbenv' not found, but can be installed with:
apt install rbenv
root@testinghttp:~# rbenv install 2.6.5
Command 'rbenv' not found, but can be installed with:
rbenv cloned.
-rw------- 1 root root 1057 Dec 21 13:58 .bash_history
-rw-r--r-- 1 root root 3222 Dec 21 13:57 .bashrc
drwx------ 2 root root 4096 Dec 21 13:53 .cache/
-rw-r--r-- 1 root root 0 Dec 21 13:37 .cloud-locale-test.skip
drwxr-xr-x 3 root root 4096 Dec 21 14:08 .gem/
-rw-r--r-- 1 root root 148 Aug 17 2015 .profile
drwxr-xr-x 5 root root 4096 Dec 21 14:07 .rbenv/
drwx------ 2 root root 4096 Dec 21 13:37 .ssh/
-rw------- 1 root root 761 Dec 21 14:09 .viminfo
.bashrc
# enable programmable completion features (you don't need to enable
# this, if it's already enabled in /etc/bash.bashrc and /etc/profile
# sources /etc/bash.bashrc).
#if [ -f /etc/bash_completion ] && ! shopt -oq posix; then
# . /etc/bash_completion
#fi
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
export PATH="$HOME/.rbenv/plugins/ruby-build/bin:$PATH"
please give it a fresh install test :thumbsup
Hello. Thanks for this valuable tutorial. I'm at the last stage. I'm just getting a error message.
ERROR MESSAGE:
The application encountered the following error: ActiveSupport::MessageEncryptor::InvalidMessage (ActiveSupport::MessageEncryptor::InvalidMessage)
Sounds like you're simply missing the RAILS_MASTER_KEY env var. Set that up so that Rails can decrypt the credentials and you will be set.
Have no idea what happened yet, I didn't set RAILS_MASTER_KEY env var but just commented on the RAILS_MASTER_KEY line in the <.rbenv-vars> file.
Now the production site works.
Anyway thanks.
I have used for recent installation with ubuntu 20.04 and ruby 2.6.6
at some point nginx get unresolved dependencies, and you have to get a new repo:
deb https://oss-binaries.phusionpassenger.com/apt/passenger focal main
in the end the problem is phusion passenger doesn't start automatically. How can I fix that?
I use Passenger's pre-start feature. You have to define it OUTSIDE of a server block, like this:
server {
listen 433 ssl http2;
server_name www.example.com;
[other NGINX server block code goes here]...
}
passenger_pre_start https://www.example.com;
Now every time Nginx restarts, it'll also restart the www.example.com site. This works pretty well for the single server setup in the deploying to production guide. It's more tricky if you have a cluster and/or are using the proxy_protocol.
Hey Chris. Thank you so much for this guide, it always works. I have just one question, how would I access Rails console in my droplet? Using "rails c -e p" or "rails c" doesn't seem to work.
Hey Thuba, I've created some aliases to add in my droplet so I can run just after the ssh:
nano .bashrc
alias rails_console='cd ~/myapp/current && bundle exec rails c -e produciton'
alias tail_production_log='tail -f -n 250 ~/myapp/current/log/production.log'
alias tail_nginx_log='sudo tail -f -n 250 /var/log/nginx/error.log'
I am getting an error with this method when deploy via capistrano: 01 bash: /home/deploy/.rbenv/bin/rbenv: No such file or directory. Any ideas on how to fix?
Please help! I've successfully completed this tutorial and now have a fully functional DB up and running online.
Now I've just updated my rails app for the first time on my local machine and pushed these updates to my git repo, yet I'm not seeing these updates in production.
How do I update my production application?
Thanks in advance for your time and consideration!
Correct, every time you want to update your application in production you will have to run the command cap production deploy
Capistrano is not an automated deployment solution in the sense that just pushing updates to git will trigger a deployment.
Having trouble getting past the following error on 'cap production deploy'... please help!
00:05 deploy:migrating
01 $HOME/.rbenv/bin/rbenv exec rake db:migrate
01 /home/ubuntu/.rbenv/versions/2.5.1/lib/ruby/2.5.0/rubygems/resolver.rb:231:in `search_for'
01 :
01 Unable to resolve dependency: user requested 'did_you_mean (= 1.2.0)'
01 (
01 Gem::UnsatisfiableDependencyError
01 )
This could be a few things--but first, did you make sure to include the bundler plugin for Capistrano? It should be fetching all of your gems for you on the server during deployment. It's part of the setup instructions, so as long as you copied what was in the setup steps then you should be fine.
Do you have the gem 'did_you_mean' in your gemfile as only needed in Development or just not available in production?
Hi guys, how is it going? I'm facing a problem after deploy following this tutorial. After I hit the domain URL into the browser, I see the message "This site can’t be reached mydomain.com refused to connect.". I already deployed this code many times in different VPSs just fine. In this new one, I don't know what's happening. I already tail the logs and I got no clues there. Can you guys help me with some insights?
Also I'm facing this problem with letsencrypt:
~/letsencrypt$ ./letsencrypt-auto
Requesting to rerun ./letsencrypt-auto with root privileges...
[sudo] password for deploy:
Skipping bootstrap because certbot-auto is deprecated on this system.
./letsencrypt-auto has insecure permissions!
To learn how to fix them, visit https://community.letsencrypt.org/t/certbot-auto-deployment-best-practices/91979/
Your system is not supported by certbot-auto anymore.
Certbot cannot be installed.
Please visit https://certbot.eff.org/ to check for other alternatives.
I tried to install on Ubuntu 20.04 and I had no luck. any thoughts?
(this comment would belong to this post https://gorails.com/guides/free-ssl-with-rails-and-nginx-using-let-s-encrypt)
I have the same problem, but I find this on DigitalOcean
I don't know if this is the best way.
I hope this works for you.
Hi guys, i have some problems with the "SECRET_KEY_BASE" in 'cap production deploy' any idea what i'm doing wrong, by the way thank you for the help!
00:25 deploy:assets:precompile
01 $HOME/.rbenv/bin/rbenv exec bundle exec rake assets:precompile
01 rake aborted!
01 ArgumentError: Missing secret_key_base
for 'production' environment, set this string with rails credentials:edit
01 /home/workb/workb/shared/bundle/ruby/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:588:in validate_secret_key_base'
secret_key_base'
01 /home/workb/workb/shared/bundle/ruby/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:423:in
01 /home/workb/workb/shared/bundle/ruby/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:177:in key_generator'
message_verifier'
01 /home/workb/workb/shared/bundle/ruby/2.7.0/gems/railties-6.0.3.4/lib/rails/application.rb:201:in
thank you very much. Unfortunately, ruby doesnt show with ruby -v
but does locally or globally with rbenv.
This is my .bashrc
...
if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliasesval "$(rbenv init -)"
fi
...
export PATH="$HOME/.rbenv/bin:$PATH"
eval "$(rbenv init -)"
Even I am newbie... can you elaborate what do you mean by "shared folder", and create the master.key file and then add it to the list of files to symlink every deploy.. 2ndly I want to know, is it not possible to deploy simply copying our project folder to ec2 instance and run rails env=production? instead so many steps.... Sorry in advance, if it is a baseless question... Can you please clarify about secretkey, masterkey and credentials.. which one to use...
Glad I saw this post. Thank you for sharing this. I’ve been searching a lot lately. While I was searching I found this https://stickmanhook.io
Nice post! Thank you for your video! I have decided my problem while read it. I think you should create tiktok profile and post your video on tiktok. If you want you can get some followers from here Https://soclikes.com