I have a 1and1 Linux VPS server and we are not permitted to use third party applications like Github to push our code to the server. I realise that this is silly but nevertheless.
Is it actually possible to get a Rails app running by FTPing it over to a Linux server?
Sure, this is possible. You'd copy all the files over. Only a couple tricky points:
Setting environmental variables might be difficult
Depends on what application server 1&1 provides to you. Apache by itself isn't good enough, you'll need something to run the Ruby code, like Passenger, Mongrel (old but possibly available), or Unicorn (unlikely).
Also --- you have a VPS server, so you probably have SSH access and can use ssh to copy files up, rather than FTP.
Capistratno setup:
set :repository, "."
set :scm, :none
set :deploy_via, :copy
Related
According to this description I have to set a repository in the deploy.rb file.
set :application, "my_app_name"
set :repo_url, "git#example.com:me/my_repo.git"
I assume this is the source code of my app, is that correct? At the moment I have my app repository on a cloud9 server. To deploy the app I type cap production deploy on the development system. So, do I have to put in the url and path of the cloud9 server? That seems weird, because I deploy from that server. Or is this file transferred to the production system that then pulls the data from the development environment? Does this mean, I need a passwordless ssh connection from a cloud 9 server to the production server or vice versa? Or do I need to push my data to a third system?
According to the docs, repo_url must be set appropriately and the deployed server must be able to connect to it. The reason is that by defaut, capistrano will try to pull code from the repo to the deployed server instead of pushing your code directly.
Simple question, I do all my work on my local at home computer and then I git push to my repo on github, and then on my Ubuntu Server I do a git pull to get the content, but this causes inconsistencies because it pulls in development mode which I always have to go in and change. Is there a way to make it so I can work in development mode but push it to the repo production mode? Thanks.
This isn't a git problem. Rails environments ('production', 'development', 'test') affect how the code runs, but the code isn't changed.
When you run rails server on your development machine, the application starts in development mode because that is the default for that command.
You probably aren't using the same command to host your site on WEBrick on your server, but rather using something like Phusion Passenger, which can (should) be configured to boot your application in Production mode.
If the environment is set correctly, the config/environments/#[RAILS_ENV}.rb file is correctly selected upon loading the app, and the correct database sources are selected from config/database.yml.
Rails apps default to development unless you set the RAILS_ENV variable to production. Git doesn't really factor in to this. On your production machine, you'll want to set RAILS_ENV.
Where to do this depends on your production deployment environment, and how your server is configured. Things like Passenger default to production mode, and configuring that depends on your server (Apache, nginx). If you're manually starting the server from the command line (via rails s thin or something along those lines), then you can configure it in your shell's startup file (.profile or something similar, depending on your shell). thin also optionally takes an environment argument like -e production.
If you provide more details on how your production environment works, you might get a more specific answer for where to set RAILS_ENV.
Here is the code in deploy.rb
set :application, "myapp"
server "10.15.169.45", :web, :app, :db, :primary => true
What's the URL accessing the web app after deployment? Tried http://10.15.169.45 and http://10.15.169.45/myapp and none of them worked. http://10.15.169.45 displayed "Welcome to nginx".
Any suggestions? thanks.
Capistrano just posts the files to the server, and runs some additional tasks (if you tell it to). It is not responsible for serving the page. Given that you said that you have passenger + nginx setup, I would go there first for troubleshooting. Assuming you configured everything properly according to the passenger instructions, with the standard setup the app should be available on 10.15.169.45.
The message you are getting indicates that nginx is installed correctly, but either passenger is not configured properly, or your rails app has not been started. You should check the nginx logs, and walk back through your configuration steps to see if there is anything that you missed.
You should also check out the passenger documentation on integrating with capistrano:
http://modrails.com/documentation/Users%20guide%20Nginx.html#capistrano
Do you have a Rails application server installed? What does your Nginx configuration look like?
In case you haven't set something like this up already, I would highly recommend Phusion Passenger. It works with Apache or Nginx, is well documented, and is easy to install and configure.
You'll have to bear with me as I'm not a Ruby dev, but have inherited a Ruby system.
I need to deploy some changes to the app from my repository to the server. I've been instructed to run cap deploy and told that that script will get the latest code from my repository and deploy it to the server.
My problem is that I have to VPN to get to the production server and the VPN client then blocks access to my local network, cutting off the repository. So my question is, how can I change my deploy.rb so that I can deploy from my local machine instead? Or is there a better way.
If you need to see the deploy.rb, please let me know.
Thanks
Dave
The solution I've used before means adding:
set :deploy_via, :copy
However, it may be better to read more about this at:
http://www.capify.org/index.php/Understanding_Deployment_Strategies#Deploy_Strategy_:copy
I am getting ready to deploy to a true production environment. When I say true I mean that my current production environment will now be staging because there is other crap on the server and I am creating a new larger slice for what will actually be my production machine.
The capistrano-ext gem has made separating the deploy recipes quite easy. However, one issue I run into is getting my code from one slice to another. I have a git repo set up on my staging slice that I will be using for production. The flow will be:
Develop locally
Test locally
Push from local to stage
Test on stage
Push from stage to production
...
Therefore I obviously need a way to establish a secure connection between staging and production. When deploying to production, I get a "Permission denied (publickey)." error because this is not set up. How can I establish this connection? Do I need to generate keys on my production server and put the public on my staging? How do I know what user on my production server is trying to connect to my staging server?
Branches and capistrano multistage are your friends.
To solve the production not having access to the git repo issue, try…
set :deploy_via, :copy
…this deploys by checking out locally, and pushing a tar ball.
I find that branching or version tagging works much better for differentiating staging vs. production when using Capistrano.
For example, set up a 'staging' and 'production' branch for your application and use your source control tools to manage migrating changes from one to the next. During deployment simply deploy as you usually would, but with a particular branch instead of the main one.
It's not necessary to promote directly from staging to production, and in fact, this may be considered a bad idea since anyone with access to the staging machine potentially has access to the production server. In most environments a staging server is treated much more casually than the production site, so the security profile is usually quite different.
Do I need to generate keys on my production server and put the public on my staging?
Yes.
How do I know what user on my production server is trying to connect to my staging server?
The productionuser will be whatever user you connect with (see :user). The staginguser will be from the git url (see :repository).
When you use
set :deploy_via, :remote_cache
(which is the default), two ssh connections are actually occurring. The first one is from your local machine to production, and it uses the 'user' as configured in your recipe.
set :user, 'www-data'
The second ssh connection is made by that user, on production, to your git origin. So if git origin is on staging, the production user is trying to connect back to staging to pull code from git.
set :repository, "staginguser#staging.com:project.git"
Try this: ssh to production as the user. Then run the failing command by hand. You'll see the "permission denied" and maybe a prompt for a password. Add the public key of the staging server user to the production box and things should work better.
There's also:
set :gateway, 'staging server ip'
which should allow you to tunnel all the way through to your firewalled production box. But if you're deploying from staging you need to set up keys on the staging box if you're going to go through it that way.
On a side note, it's important to be able to do this whole process from your home box, staging really shouldn't need to have a capistrano gem, the hope is that you can do the whole process without ever having to actually log into a server. That includes logging in to your staging server. :)
If there's an issue of data pushing between the two this could easily be added onto just the production config so that it automatically takes data from staging and rsync's it over.