Difference between revisions of "Talk:Web Application Redirect Tutorial"

From SME Server
Jump to navigationJump to search
(Alternative redirection method)
m
Line 119: Line 119:
 
Works OK for me. Only tested with a Virtual Domain and joomla as the webapp. Generates a standard VirtualHost entry in httpd.conf, but with just the DocumentRoot changed. The Content db setting of joomla shows up in server-manager, but a modify then ignores it and reverts to setting options for available ibays. Obviously the Content property needs to be set to the directory name under /opt where the web application resides.
 
Works OK for me. Only tested with a Virtual Domain and joomla as the webapp. Generates a standard VirtualHost entry in httpd.conf, but with just the DocumentRoot changed. The Content db setting of joomla shows up in server-manager, but a modify then ignores it and reverts to setting options for available ibays. Obviously the Content property needs to be set to the directory name under /opt where the web application resides.
  
I haven't tested it, but I assume if you had no VirtualDomains defined and set the Primary Domain to be redirected you would still get the standard VirtualHost entry created and therefore still have access to server-manager etc.
+
I haven't tested it, but I assume if you had no VirtualDomains defined and set the Primary Domain to be redirected you would still get the standard VirtualHost entry created and therefore still have access to server-manager etc. - [[User:Timn|Timn]] 12:54, 15 February 2010 (UTC)

Revision as of 13:54, 15 February 2010

This page isn't a good idea, this method has problems

http://wiki.contribs.org/Web_Application_RPM#Webserver_templates

>> note this causes side effects, another method is needed

the side effects, were odd things happening to the primary domain, which was difficult to define


a better method may be to create a whole new VirtualHost section, copy an existing section and see what needs to be changed.


<VirtualHost 0.0.0.0:80>
   ServerName NewDomain.net
   DocumentRoot         /opt/thingy/html
 <snip>

server-manager issue

My test showed that it disables server-manager (minor side effect), at least from the standpoint of following it to a tee, so its not valid solution as of this point in time, from the tests here. So it's possible that folks might invoke this and not know server-manager is effected. Might be why some post the usual "Can't access server-manager" in the forum. BTW it also effects server-manager at the console, with no way to access server-manager, the only way to regain server-manager at that point was to delete the template and restart. Although it's on the right track it needs a better method as was stated.

Alternative Method

I have done the following and all appears to work OK.

Created a Virtual Domain vdomain.com in server-manager panel then

db domains setprop vdomain.com Content joomla
db domains setprop vdomain.com WebApp yes

Created a new template fragment

mkdir -p /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts
cd /etc/e-smith/templates-custom/etc/httdp/conf/httpd.conf/VirtualHosts
cp /etc/e-smith/templates/etc/httpd/conf/httpd.conf/VirtualHosts/20IbayContent 20IbayContent

Now edit and change the file 20IbayContent. Lines marked + have been added

 {
     use esmith::AccountsDB;
     my $accounts = esmith::AccountsDB->open_ro; 
 
     use esmith::DomainsDB;
     my $domains = esmith::DomainsDB->open_ro; 

     $OUT = "";

     my $ibay = $virtualHostContent;

+    if (( $domains->get_prop($virtualHost, 'WebApp') || 'no') eq 'yes') {
+        my $basedir = "/opt/$ibay";
+        $OUT .= "    DocumentRoot        $basedir\n";
+     }
+     else {
         my $basedir = "/home/e-smith/files/ibays/$ibay";
         my $cgiBin = $accounts->get_prop($ibay, "CgiBin") || "";
 
         $OUT .= "    DocumentRoot         $basedir/html\n";
 
         if ($cgiBin)
         {
             $OUT .= "    ScriptAlias /cgi-bin $basedir/cgi-bin\n";
         }
         else
         {
             $OUT .=
                     "    # To add cgi-bin ScriptAlias for this i-bay, run:\n"
                   . "    #   /sbin/e-smith/db accounts setprop $ibay CgiBin "
                             . "enabled\n"
                   . "    #   /sbin/e-smith/signal-event console-save\n";
         }  
         $OUT .= "    Alias       /files   $basedir/files\n";
+    }

     if (($domains->get_prop($virtualHost, 'SystemPrimaryDomain') || 'no')
          eq 'yes')
     {
         my @ibays = $accounts->ibays;
         foreach my $ibay (@ibays)
         {
             my $key = $ibay->key;
             next if $key eq $virtualHostContent;
             my $basedir = "/home/e-smith/files/ibays/$key";
             my $cgiBin = $ibay->prop("CgiBin") || "";
             my $name = $ibay->prop("Name") || "";

             $OUT .= "\n";
             $OUT .= "    # $key ibay ($name)\n";
             $OUT .= "\n";

             if ($cgiBin)
             {
                 $OUT .= "    ScriptAlias /$key/cgi-bin $basedir/cgi-bin\n";
             }
             else
             {
                 $OUT .=
                     "    # To add cgi-bin ScriptAlias for this i-bay, run:\n"
                     . "    #   /sbin/e-smith/db accounts setprop $key CgiBin "
                                 . "enabled\n"
                     . "    #   /sbin/e-smith/signal-event console-save\n";
             }
 
             $OUT .= "    Alias       /$key/files   $basedir/files\n";

             # Make sure this one is last since it's a prefix of the above
             # aliases. If we put it first, it would get expanded before the
             # other aliases, creating problems.

             $OUT .= "    Alias       /$key        $basedir/html\n";
         }
         $OUT .= "    # No ibays in system\n" unless @ibays;
     }
 } 

Expand the template and restart httpd

expand-template /etc/httpd/conf/httpd.conf
sv t httpd-e-smith

Works OK for me. Only tested with a Virtual Domain and joomla as the webapp. Generates a standard VirtualHost entry in httpd.conf, but with just the DocumentRoot changed. The Content db setting of joomla shows up in server-manager, but a modify then ignores it and reverts to setting options for available ibays. Obviously the Content property needs to be set to the directory name under /opt where the web application resides.

I haven't tested it, but I assume if you had no VirtualDomains defined and set the Primary Domain to be redirected you would still get the standard VirtualHost entry created and therefore still have access to server-manager etc. - Timn 12:54, 15 February 2010 (UTC)