Ranzit
Ranzit

Reputation: 1347

Unable to point website domain to rails app via virtual host + centos + apache

I have dedicated server web hosting in Hostgator. - CentOs 6 64bit - Dedicated Server - Apache I had an dedicated host IP where I have created "A" record with IP(domain hosting is in GoDaddy).

My problem is creating virtual host to point rails app to my domain. I am trying to configure domain. I didn't find conf file where default document root is configured. I tried changing conf file in etc/httpd/conf/httpd.conf, but no use. Some default document root(/usr/local/apache/htdocs) page is rendering. I need to find the document root virtual configuration and then need to point my domain to that. I need help regarding this.

Here is my default virtualhost setting in httpd conf file:

NameVirtualHost *
# Default vhost for unbound IPs
<VirtualHost *>
    ServerName examle_server_name
    DocumentRoot /usr/local/apache/htdocs
    ServerAdmin root@example_server
    <IfModule mod_suphp.c>
        suPHP_UserGroup nobody nobody
    </IfModule>
</VirtualHost>

Even if I change Server name to my domain name there is no chnage. Also if I remove those lines, it is showing default page which is in /usr/local/apache/htdocs.

How/Where can I change this to effect/point my rails app to domain.

Also I need Apache VirtualHost settings of rails app configuration which is running on rails 3000 port

Help me please.

Regards, Ranjit

Upvotes: 5

Views: 665

Answers (2)

Kudehinbu Oluwaponle
Kudehinbu Oluwaponle

Reputation: 1145

Was Apache installed with easyapache/Cpanel ? (Which is often the case with hostgator)
Then your apache main conf file will be located at /usr/local/apache/conf/httpd.conf. However, it is not recommended you make changes directly to to that file since it could be overwritten when apache rebuilds its conf files.
For changes not contained inside virtualhosts, use the pre and posts files whose location will be indicated in the main conf files.
For changes inside virtualhosts, use the file indicated for each domain in the conf file to make changes

Upvotes: 0

gsobrevilla
gsobrevilla

Reputation: 243

For deploying apps in a server I use this virtual host configuration

<VirtualHost *:80>
    ServerName mydomain.com
    DocumentRoot /path/to/rails/public/folder


    <Directory /path/to/rails/public/folder >
        Options Indexes FollowSymLinks
        AllowOverride all
        Require all granted
    </Directory>

</VirtualHost>

I creata a file in /etc/apache2/sites-enabled/mysite.conf, but I do it in Ubuntu servers. I donn't know if the location in CentOS is the same.

You can create another file like this for the 3000 port app.

I skipped the Passengger (https://www.phusionpassenger.com/) settings in the file. I use it for serving rails apps.

After any changes you will need to restart the server

sudo service apache2 restart

Upvotes: 2

Related Questions