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

  • Home
  • SEARCH
  • 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
I wrote an application that loops through a set of records and prints two
In my Rails application, I have two models, Articles and Projects, which are both
I'm creating two related Rails applications, and I'm noticing a lot of non-DRY work.
I have a Java application set up as a service to do data-mining against
I'm changing our application from one set of code & one database to one
Platform: Windows XP Development Platform: VB6 When trying to set an application title via
I have set up a Django application that uses images. I think I have
How do you set your Cocoa application as the default web browser? I want
I am running an application through gdb and I want to set a breakpoint

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.