Thursday, October 30, 2014

Virtualhost config for using wordpress and rails app on same server and under same domain

To host wordpress and rails app on same server you have to install wordpress in public folder of your rails app.

Below config are done by placing "/en/blog" and "/es/blog" in public folder of your rails app which are two wordpress setup in blog folder

      ServerName example.yourdomain.com
      # !!! Be sure to point DocumentRoot to 'public'!
   
      DocumentRoot /var/www/example/public
   
      #RailsEnv production    
   
         # This relaxes Apache security settings.
         AllowOverride all
         # MultiViews must be turned off.
         Options -MultiViews
   
   
   
         PassengerEnabled off
       
           RewriteEngine On
           RewriteBase /es/blog/
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteRule . /es/blog/index.php [L]
       
   
     
   
         PassengerEnabled off
       
           RewriteEngine On
           RewriteBase /en/blog/
           RewriteCond %{REQUEST_FILENAME} !-f
           RewriteCond %{REQUEST_FILENAME} !-d
           RewriteRule . /en/blog/index.php [L]
       
using this you will be able to access your wordpress sites install in folder "/public/es/blog" and "/public/en/blog" by using below urls:-

example.yourdomain.com/en/blog
example.yourdomain.com/es/blog


Happy Coding:)

Tuesday, September 23, 2014

Domain mapping for apache-tomcat-7.0.54 using virtual host

1) Add below host to your server.xml file
    for me it was on /usr/local/apache-tomcat-7.0.54/conf/server.xml  path you might find it on location to which you have install your apache-tomcat-7.0.54

<host appbase="/usr/local/apache-tomcat-7.0.54/webapps/health" autodeploy="true" name="yourdomain.com" unpackwars="true">
<Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
prefix="localhost_access_log." suffix=".txt"
pattern="%h %l %u %t &quot;%r&quot; %s %b" />
</host>

 2) Add your Domain name in host name field
     2.1 appBase is the path from were this host (a virtual server) is going to look for .war files
     2.2 To have our application accessible by hitting @root of the domain yourdomain.com keep your war file name as "ROOT.war"

 3) So when you start your server this will create a folder with your domain name yourdomain.com in below path

  /usr/local/apache-tomcat-7.0.54/conf/Catalina/yourdomain.com

inside which you will find a ROOT folder which has your application
Happy Coding:)