Deploying Rails 4 in production on windows apache MySQL - mysql

We have deployed Rails 4.1.0 / Ruby 2.1.6 on a windows 12 server in development mode with MySQL, using the WeBrick web server. We are now looking to deploy the application to production environment with rails 4.1.0, ruby 2.1.6, windows 12 server, MySQL server 5.6, and apache with Mongrel or XAMPP
Could you point us to the steps / suggestions and ideas to help deploy our rails application to production

From experience: the best thing to do is to forget about windows deployment. If this is not an option, then maybe look into JRuby and Warbler. Just don't expect:
much help from the community (because "nobody" deploys on windows)
comfortable worfkflow
stuff that works out of the box
Also i don't see why you would need XAMPP?

If you are at your first attempts on deploying I'd recommend you Heroku.
 Heroku
The nice benefit is you can install addons (eg. a mysql database) in a matter of clicks:
- https://elements.heroku.com/
Steps are really easy:
https://devcenter.heroku.com/articles/getting-started-with-rails4#write-your-app
Briefly:
# Install the `Heroku Toolbelt`
# inside Gemfile: gem 'rails_12factor', group: :production
# [git init & commit]
$ heroku login
$ apps:create my-app-name # run `heroku create --help` for further help
$ heroku addons:create jawsdb # mysql addon for `heroku`
$ git push heroku master
$ heroku run rake db:schema:load
 AWS
After a while you may realize although it's easy to deploy you'll want more tuning and probably better pricing.
At that point usually comes AWS, which has a good balance of all this, I'd recommend you Elastic Beanstalk.
Install EB CLI 3
Setup git
$ eb init
$ eb use your-environment-name
$ eb deploy
$ eb ssh # to enter into the machine

Related

Running Google Cloud SQL Proxy on Raspberry

I'm getting an error while trying to connect raspberry running ubuntu mate to my Google Cloud SQL instance.
These are the step I did to install:
git clone https://github.com/GoogleCloudPlatform/cloudsql-proxy
cd cloudsql-proxy/
sudo sh download_proxy.sh
My instance is configured this way (I deleted some characters in the image and in the code):
I didn't set the network because I'll be using proxy
Then I download into the same folder my JSON key.
wget https://drive.google.com/file/d/my_key.json
And the start the proxy
sudo ./cloud_sql_proxy -instances=be - 21:us-central1:be =tcp:3306 \
-credential_file=./my_key.json &
But I'm getting the error:
pi#pi:~/cloudsql-proxy$ ./cloud_sql_proxy: 1: ./cloud_sql_proxy:
Syntax error: ")" unexpected
I've tried removing the .json and I was getting the same error before without credential, I think that the problem is in the setup.
My dir ls is:
Any help is appreciated :)
download_proxy.sh downloads the proxy compiled for the amd64 architecture of CPU (aka x86_64). Your raspberry Pi has a ARM CPU, so this binary cannot run on your machine.
Google does not provide pre-build ARM versions of the proxy. I don't even know if it is able to build on ARM CPU. If it is possible, this is how you must do it:
Install go, e.g. with apt-get install golang
Setup a GOPATH, as per https://github.com/golang/go/wiki/GOPATH
Run go get github.com/GoogleCloudPlatform/cloudsql-proxy/cmd/cloud_sql_proxy
Run the proxy with $GOPATH/cloud_sql_proxy -instances=...
Ok.
I'm sharing what I did to make it work, as David I don't know what version was I downloading.
I tried to avoid installing Go but it was the only way to get it installed.
sudo apt-get install golang-go
export GOPATH=$HOME/go
go get github.com/GoogleCloudPlatform/cloudsql-proxy/cmd/cloud_sql_proxy
cd $GOPATH/bin
wget your_key.json
sudo ./cloud_sql_proxy -instances=the_full_name_of_the_instance=tcp:3306 -credential_file=./your_key.json &
But I was getting a error because I already have mysql running localy in the same port
So now I'm using a unix soquet
sudo ./cloud_sql_proxy -instances=the_full_name_of_the_instance -credential_file=./your_key.json &
And then it's ready for connections :)
Thanks guys
I found issues with this when compiling SQL-proxy. I did, however, find the instructions here worked great on my raspberry pi 3. Have to make sure to remove all prior installations then reinstall it
wget https://storage.googleapis.com/golang/go1.9.linux-armv6l.tar.gz
sudo tar -C /usr/local -xzf go1.9.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin # put into ~/.profile`

Alternative ways to deploy code to Openshift

I am trying to setup Travis CI to deploy my repository to Openshift on a successful build. Is there a way to deploy a repository besides using Git?
Git is the official mechanism for how your code is update, however depending on the type of application that you are deploying you may not need to deploy your entire code base.
For example Java application (war, ear, etc) can be deployed to JBoss or Tomcat servers, by simply taking the built application and checking it into the OpenShift git repositories, webapps or deploy directories.
An alternative to this (and it will be unsupported), is to scp your application to the gear using the SSH key. However any time the application is moved or updated (with git) this content stands a good chance of getting deleted(cleaned), by the gear.
We're working on direct binary deploys ("push") and "pull" style deploys (Openshift downloads a binary for you. The design/process is described here:
https://github.com/openshift/openshift-pep/blob/master/openshift-pep-006-deploy.md
You can do a SCP to the app-root/dependencies/jbossews/webapps directory direcly. I was able to do that successfully and have the app working. Here is the link
Here is the code which I had in the after_success blck
after_success:
- sudo apt-get -y install sshpass
- openssl aes-256-cbc -K $encrypted_8544f7cb7a3c_key -iv $encrypted_8544f7cb7a3c_iv
-in id_rsa.enc -out ~/id_rsa_dpl -d
- chmod 600 ~/id_rsa_dpl
- sshpass scp -i ~/id_rsa_dpl webapps/ROOT.war $DEPLOY_HOST:$DEPLOY_PATH
Hope this helps

about mysql installation in a LAMP environment

When I build a LAMP environment in ubuntu-12.10,
first I installed mysql by mysql-5.5.12.tar.gz,but it told me that it can not find configure
file,it was here:
root#tryandchange-QTH6:/usr/local/src# cd mysql-5.5.12
root#tryandchange-QTH6:/usr/local/src/mysql-5.5.12# ./configure --prefix=/usr/local/mysql
bash: ./configure: 没有那个文件或目录(not exists the document or the file)
who can tell me why?Or tell me that a good way to build a LAMP environment,
but not 'apt-get install'.
XAMPP has downloadable Linux binaries, you just download, extract and run /path/to/xampp/xampp start - I'd recommend those as the easiest way to set up a LAMPP stack.
Link to XAMPP for Linux
Obviously by eschewing the use of apt, you are working with the knowledge that your apache/php/mysql will become obsolete and you will have to work to keep them secured and up-to-date.

How to install Ruby on Rails with mysql and get it working, a step by step guide?

Some time ago I managed to get RoR working on Windows XP.
I've been trying to get it working on Windows 7 for 2 days but there's just no way, there's always a problem, one that google can't answer, no matter what I try.
Can someone give me a guide or something to get it working on Windows 7 or XP ? Even Ubuntu but I'd rather not go through that maze again.
I figure I'm going to install Windows XP on a virtual machine and start from there.
I need RoR and mysql - what versions, where do I download them from and what steps do I take ?
On a side note, how do you install mysql2 (version < 0.3) on rails 3.0.7 ? Because it automatically tries something over 0.3 which doesn't work on rails 3.0.7 and if I try the gemfile bundle trick with 0.2.7 I don't know how to specify configuration options and of course it doesn't work if I don't give it the location of mysql lib and include directories.
Also I tried using rails 3.1 beta and everything goes smoothly until I start the server and the website never loads on localhost:3000.
This is basically what I do to install on Windows 7:
Download and install latest mysql from http://dev.mysql.com/downloads/mysql/
Install Ruby http://rubyinstaller.org/downloads/ (check the box to update PATH)
Install Ruby Devkit http://rubyinstaller.org/downloads/ (for example extract to C:\DevKit)
Setup Devkit
cd [MY_DEVKIT_INSTALL_DIR]
ruby dk.rb init
ruby dk.rb install
Copy libmysql.dll from your mysql/bin install to C:\Ruby192\bin
gem install rails
gem install mysql2 -v 0.2.6
rails new my_test_app -d mysql
To setup Rails on windows, just download and click:
http://railsinstaller.org/
Take a look at http://rubyinstaller.org/ it should get you up and running.
I like Aptana Studio 3 for developping with RoR on Windows 7. The book "Agile Web Development with Rails" is also full of good advices.
Here are the steps I followed:
1- Installing Ruby via RubyInstaller
2- Install MySQL (follow #Reuben Mallaby instructions)
3- Install Rails
With the Built-in Terminal, make dev' easy. You should take a look: Aptana Studio

push Rails3 on Heroku. can not find mysql gem

i'm getting an error when pushing to heroku using rails 3. I'm on windows with ruby 1.8.7
Administrator#WIN-DQC3IH63U7C ~/nasha (master)
$ heroku rake db:migrate
rake aborted!
no such file to load -- mysql
/disk1/home/slugs/280561_9c64ba2_1741/mnt/Rakefile:4
(See full trace by running task with --trace)
(in /disk1/home/slugs/280561_9c64ba2_1741/mnt)
Heroku doesn't use the database you use for running your application locally.
Heroku uses PostgreSQL (http://docs.heroku.com/database)
Did you freeze Rails into vendor? This problem usually appears with Heroku when you freeze Rails. You must leave Heroku use it's own Rails based on your .gems file. You can read more about this here http://docs.heroku.com/gems#heroku-gem-manifest
If this is not the problem, did you follow the instructions regarding Heroku and Rails 3 applications? You can read about it here http://docs.heroku.com/rails3 Please notice that you must setup the Bamboo Stack for your Rails 3 application to work correctly.
You need have the mysql gem in your Gemfile
gem "mysql"