Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 742167
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T08:43:01+00:00 2026-05-14T08:43:01+00:00

My application is a set of two rails applications. Based on some parameters in

  • 0

My application is a set of two rails applications. Based on some parameters in first app. I need to setup the virtual host of the second app. I just need to change the ServerName and ServerAlias in apache VH and enable the site using a2ensite and then ‘apache2 reload ‘.

How can I do this from within a rails application?

Thanks,
Imran

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T08:43:02+00:00Added an answer on May 14, 2026 at 8:43 am

    First of all: be aware that enabling web-apps to change the server configuration is a security risk.

    #  First, open the config file
    fd=File.open('/etc/apache2/sites/yoursite', 'r+')
    #  read in the contents
    content=fd.read
    #  now replace the ServerName and ServerAlias lines with your new setting
    if content.gsub!(/ServerName(.*)/,"ServerName NewServerName") and content.gsub!(/ServerAlias(.*)/,"ServerAlias NewServerAlias")
      fd.rewind
      puts "\tsaving file"
      fd.write content
    end
    fd.close
    

    I did not test neither code nor the regular expressions, please load the relevant parts of your config file into rubular.com and roll your own regex.

    Maybe you should also make a backup before saving using

    File.copy(file,file+".bak",true)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on a Rails application where I have some a set of two
In some applications like Sparrow Mail are set two different application icons. The default
I have two virtual hosts on my server pointing towards two separate rails applications.
I wanted to set up a simple data communication between two C# applications, and
So I have a XNA application set up. The camera is in first person
I need my application installer set the program to auto-startup for all users. Then
In Rails 3 edge, I have set up two nested resources like this: config/routes.rb
Hey! I am trying to set up routes in a Rails application so that,
I'm trying to setup a rails application so that I can choose between different
I'm building a small personal web app in Ruby on Rails. I've set it

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.