Is it possible to run some PHP pages at "example.com" AND also run a rails application at say "test.example.com" on Dreamhost? Has anyone done this?
Or do I need to run rails apps on separate domains?
Thanks.
In the Dreamhost control panel menu, go to "Manage Domains" under "Domains".
Add the domain example.com as a fully hosted domain, and keep the default settings. PHP is set up on fully hosted domains by default, so you're good to go there.
Go back to the "Manage Domains" panel and set up the subdomain test.example.com. This time, check the box marked "Ruby on Rails Passenger (mod_rails)?" and fill in the form to specify the public folder of your Rails app. For full details on how to set up a Passenger app in DH, you should check out the relevant DH wiki article - the instructions are pretty straightforward.
Best of luck!
You can do it and I have done it. Not to sound like an advertisement, but their control panel makes it simple to do what you want.
Related
Before I start the process of building something from scratch I was curious if anyone else had come across a way of providing a first-time configuration wizard for a Rails application that allows the user (sysadmin) to configure aspects of the application such as the ActiveRecord configuration and the ActionMailer setup (SMTP, sender etc).
We'd like to provide a clean easy way for new installs to get setup, rather than asking clients to edit files, or run scripts on the command line.
Essentially you should be able to download the application, extract it, start it, and when you access it via the browser you're guided through the initial setup steps.
My question isn't so much around how to do this, but more has anyone already done this. My quick search for gems, plugins etc around this idea didn't turn up much.
Edit/Clarification
To clarify the scenario - this is to support "shrink-wrapped" products that are downloaded and installed on-premises by the customer's sys admin.
The first time they access our application after deploying it behind their firewall we want a friendly way of configuring the specific settings for their install, such as database etc.
An example of such a process is JIRA's setup wizard:
https://confluence.atlassian.com/display/JIRA/Running+the+Setup+Wizard
This isn't for reating new rails applications, or systemising our development process.
I like Rails Templater a lot. It is a command line tool to build a rails app. It asks you questions like "Would you like to use rspec? Pry instead of IRB?"
I have created a fork that adds authentication, twitter bootstrap and backbone.js and some other options. It is pretty easy to hack on if you have specific needs. I use it all the time and I would hate not having it.
It is of course a command line app and not usable via the browser but maybe it will still fit your needs. Or the codebase could be integrated into a client web application.
Update after comment
You may be able to bootstrap a sqlite database so the app can boot, then just using a form or a wizard to set up something that writes your database.yml and other configs, maybe by means of thor (makes appending/replacing text in files simple and is part of rails). You would need to somehow restart the rails app and migrate the database. You could keep the pg or mysql2 gem (or both) in your Gemfile or again use thor to edit them from your wizard/form.
I also recommend using rails_config as Michael suggested. With the above solution.
If I had more time to think about the problem, I may come up with something cleaner but this is how I would do it if I had to right now.
http://railswizard.org/ lets you select which gems to use. It's a very innovative use of the ui and the isotope gem to select the components. Similarly another viewpoint is this top 10 list: http://blog.teamtreehouse.com/10-must-have-ruby-gems
You'll never find a definitive list of gems as need change from person to person and over time, e.g. which database your company uses and which is the 'current' best authentication gem are both variable.
For configuration specific settings you can make the configuration less of a chore by using practices that reduce it. For example the database.yml file is usually one of the 'must be edited locally' files. Our approach for this to to exclude database.yml from source control by putting its name in our .gitignore file. We add an database.yml.example file which we copy locally to database.yml and in that file we use anchors (&) and references (*) as detailed here: http://blog.geekdaily.org/2010/08/advanced-yaml-tricking-out-your-databaseyml.html
More options for configuring other variables for each environment: http://kpumuk.info/ruby-on-rails/flexible-application-configuration-in-ruby-on-rails/
The rails config gem may also help you as detailed here: How to define custom configuration variables in rails
I recently discovered that Heroku now allows PHP which means that a wordpress blog can be hosted on it. I also found this project template: https://github.com/mhoofman/wordpress-heroku
I have a ruby on rails app which is to be hosted on heroku with a domain www.mysite.com, and in that app, i need a way for www.mysite.com/blog to show the wordpress blog.
Can someone help me out, with details on how I can do this?
Whilst I've not used the new PHP platform I don't think what you're asking for is going to be possible.
When you deploy an application to Heroku it detects the type of application during the push process and sets up the application accordingly, Heroku use Apache to host PHP as you can see from the output in this post http://tjstein.com/2011/09/running-wordpress-on-heroku-and-amazon-rds/ - there's not been any mention of mixing platforms in a single application yet so would imagine that it's not supported.
The nearest you'd get is hosting your site and your blog in two seperate applications with the blog on blog.mysite.com and then put a redirect on www.mysite.com/blog to the blog.mysite.com url.
Im Still working on this
the closest to getting a solution is using the reverse proxy gem
see the answer here:
How can I use a subdirectory instead of a subdomain?
Has anyone found a decent way to restart Passenger via a link? I need it for an admin so that they can just click a link (with a unique hash for protection) whenever our VPS provider has issues, if necessary.
I've tried having a secure link to a controller that just "touches" the tmp/restart.txt as well as writing to it, to no avail.
Any ideas?
You realize that this would need to be properly protected behind authentication and permission management right? Try using the FileUtils module from Ruby core.
You can use it by calling FileUtils.touch(filename) and its documentation is located here.
I have a client who wants to be able to add/delete/modify email addresses etc through cPanel, but I'd much rather add my own virtualhosts config for the actual site instead of a cPanel generated one. (A bunch of reasons. Don't want to install cPanel's ruby, would rather use passenger than mongrel, etc etc).
I don't have a whole lot of experience with cPanel, but by the look of things it takes over httpd.conf & auto-generates a virtualhost for the site - and overwrites stuff if I try to make any changes to the virtualhost settings. Is there a simple means to overwrite these settings without removing the rest of the site's functionality from cPanel?
Cheers...
You are correct in guessing that cPanel takes over a lot of things and auto-generates certain configs. To be honest, I have no idea what it does in regard to virtualhosts configs, but I do have recent experience in other areas which tends to confirm your suspicion:
So, to illustrate... cPanel comes stock with Rails 2.3.5. On the cPanel GemSet page, you can see Rails 3.0.6 shows as available, and even lets you install it via cPanel or SSH/BASH. This results in no error message at all (in fact, cPanel itself reports it as installed), but a rails --version command at SSH/BASH still shows version 2.3.5. After some research on on the cPanel forums, I discovered that this is because cPanel is hard coded for Mongrel support, and Mongrel doesn't support Rails past version 2.3.8. According to one of their moderators, they're looking at a possible Passenger solution, but it's still in the early stages of coding and months away.
So, while I realize my example doesn't specifically answer your question about virtualhosts, I think it confirms the validity of your suspicion that cPanel overrides certain settings, and may even be hard coded in ways that aren't immediately transparent...
I know this may seem trivial to some, other won't see the point, however - for me this would be great:
I am trying to work out how to quickly and efficiently commit updates to my Rails app, switch to an under construction style page while I restart the rails app and then test the changes, then when I am happy, switch back to the live public version.
At the moment, I follow the following pattern:
1, make changes to app
2, commit using Versions App for Mac to BeanstalkApp
3, deploy revision from BeanstalkApp to server
4, login to server and restart apache
5, wait a few seconds and then start to double check everything is A-OK
If it helps, I am using Passenger on a Turnkey Rails image VPS.
Thanks in advance for any advice, etc.
Thanks,
Danny
You have a few options:
Create a subdomain for 'testing' and deploy it to your production server and when it's vetted you can push it to your production code location.
You'll need to be able to add a subdomain to your DNS record to point to the same IP address as your main production server. You'll then also need to add a new VirtualHost with ServerName subdomain.host.com and DocumentRoot /data/host.com/testing/public so that it loads that code.
Using Passenger create a subfolder app. See section 3.2 of http://www.modrails.com/documentation/Users%20guide.html#_deploying_a_ruby_on_rails_application to see how to add RailsBaseURI directives to enable separate sites in subdirectories. This means you deploy your code to another directory and create the simlink.
I have personally done BOTH approaches. I prefer approach #1 but it's personal preference and the level of access you have to your hosts.