Difference between revisions of "Web Application Redirect Tutorial"
RayMitchell (talk | contribs) (added tutorial) |
(No difference)
|
Revision as of 09:40, 29 February 2008
Web Application Tutorial
Overview
This Howto gives a practical example of redirecting (virtual) domains to web applications located in the /opt/... folder.
It utlises information published in http://wiki.contribs.org/Web_Application_RPM and applies it to an example installation of Joomla CMS using http://wiki.contribs.org/Joomla
The same concepts will apply to other web applications or content installed in /opt/....
Scenario
You want to have a web application in /opt
You want to have a virtual domain(s) on your sme server
You want to access the web app in /opt/appname using the virtual domain ie www.myvirtualdomain.com
Based on information in http://forums.contribs.org/index.php?topic=38878.15 and utilising the information in http://wiki.contribs.org/Web_Application_RPM here's what I did as a redirect example.
Procedure
Install Joomla using http://wiki.contribs.org/Joomla
This installs the Joomla CMS application in /opt/joomla
It also installs a fragment /etc/e-smith/templates/etc/httpd/conf/httpd.conf/92joomla
Create another fragment
pico -w /etc/e-smith/templates/etc/httpd/conf/httpd.conf/80OptDomainJoomla
Enter the following code, having replaced foo with joomla, and save the file
It is taken from http://wiki.contribs.org/Web_Application_RPM Webserver Templates - a workaround to enable the application to be located in a domain or subdomain rootwith joomla
{ my $status = $joomla{'status'} || "disabled"; return " # joomla-status is disabled.\n" unless $status eq 'enabled';
my $domain = $joomla{'domain'} || "disabled"; return " # no hostname or domain for joomla defined\n" if $domain eq 'disabled';
my $DocRoot = "/opt/joomla";
$OUT = ""; $OUT .= "\n"; $OUT .= "# Redirect an existing hostname or domain to $DocRoot.\n"; $OUT .= "<VirtualHost 0.0.0.0:80>\n"; $OUT .= " ServerName $domain\n"; $OUT .= " DocumentRoot $DocRoot\n"; $OUT .= "</VirtualHost>\n"; $OUT .= "<VirtualHost 0.0.0.0:443>\n"; $OUT .= " ServerName $domain\n"; $OUT .= " DocumentRoot $DocRoot\n"; $OUT .= " SSLEngine on\n"; $OUT .= "</VirtualHost>\n"; }
Then use the db command to configure the system to run joomla from the root of a virtual domain ie www.myvirtualdomain.com
The virtual domain must exist in the Domains panel and be correctly configured in external DNS.
The domain panel content location ie Primary or an ibay, will be overridden by the following db setting.
You will also need to set the status to enabled as the code reads this db property (even though the default status is enabled it needs to be set).
config setprop joomla status enabled config setprop joomla domain www.myvirtualdomain.com expand-template /etc/httpd/conf/httpd.conf sv h /service/httpd-e-smith
Then open your browser and type in the URL
http://www.myvirtualdomain.com
The Joomla CMS should open and the browser will display the same URL
Remember to Refresh your browser cache to clear old cached data.
As indicated in http://wiki.contribs.org/Web_Application_RPM you can also use a URL in the form
mymaindomain.com/cms
or
myvirtualdomain.com/cms
Remove any previous domain entry first
config setprop joomla status enabled config delprop joomla domain config setprop joomla URL cms expand-template /etc/httpd/conf/httpd.conf sv h /service/httpd-e-smith
Apply the above concepts to any other application installed in /opt/appname, keeping in mind the template fragments should conform to the code shown in the examples posted in
http://wiki.contribs.org/Web_Application_RPM
and should be renamed appropriately eg
92webappname
and
80OptDomainWebappname
The fragments should also be edited to suit the webappname
To view the db settings do
config show joomla
which should give output like
joomla=service DbName=joomla DbPassword=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx DbUser=joomlauser Name=Joomla PublicAccess=global domain=www.myvirtualdomain.com status=enabled
or
joomla=service DbName=joomla DbPassword=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx DbUser=joomlauser Name=Joomla PublicAccess=global URL=cms status=enabled
Reference links
http://forums.contribs.org/index.php?topic=38878.15
http://wiki.contribs.org/Web_Application_RPM
http://wiki.contribs.org/Joomla