Koozali.org: home of the SME Server

Need help installing a web app

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« on: April 08, 2007, 08:50:09 PM »
Please be gentle – the level of my ignorance is vast.

I am trying to set up a web application with a level of secure access without installing the application an an ibay. I have had some degree of success – but need some advice for finishing up.

I have installed the application in /usr/local (which is where the application’s developers recommended; but it could just as easily have been installed in /opt). The install subdirectory was ‘ledger-smb’.

I created a template fragment called ‘95ledger-smb’ in /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf with the following content:
Code: [Select]
Alias /ledger-smb /usr/local/ledger-smb/
<Directory /usr/local/ledger-smb>
AllowOverride All
AddHandler cgi-script .pl
AddDefaultCharset On
Options ExecCGI Includes FollowSymlinks
Order Allow,Deny
Allow from All
</Directory>

<Directory /usr/local/ledger-smb/users>
Order Deny,Allow
Deny from All
</Directory>

And expanded the template.

Access to the application of the form http://www.virtualdomain.ca/ledger-smb/ worked just fine.

Then I wanted to add SSL encryption to access to this application. To do this, I created a template fragment ‘60WebRedirect’ in /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts with the following content:
Code: [Select]

#
# RewriteRule directives for LedgerSMB
#
RewriteEngine on
{
return "" unless $port ne "443";
'RewriteRule ^/ledger-smb/(.*)$ https://%{SERVER_NAME}/ledger-smb/$1 [R,L]';
}


And expanded the template.

Access to the application of the form www.virtualdomain.ca/ledger-smb/ is now always through https.

The Problem:

Now I want to access the application with specific a virtual domain of the form www.ledgers.virtualdomain.ca without reference to the ‘ledger-smb’ directory in the url.

I tried setting up an ibay called ‘ledger-smb’ and pointed my new virtual domain to that. But that did not invoke the ledger-smb Alias directive.

Should I be replacing the Alias directive with a DocumentRoot directive that points to my main application directory? If so, how would I accomplish that with template fragments? Or is there a better way to accomplish this?

After I get that working, I will again want to force access through https.

Thanks for your help.

John
...

Offline bpivk

  • *
  • 908
  • +0/-0
    • http://www.bezigrad.com
Need help installing a web app
« Reply #1 on: April 08, 2007, 09:47:04 PM »
Couldn't you just modify the rewrite rule?
'RewriteRule ^/ledger-smb/(.*)$ https://%{SERVER_NAME}/$1 [R,L]';

But i don't know about other server settings that have priority like hostnames and domain settings.
"It should just work" if it doesn't report it. Thanks!

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Need help installing a web app
« Reply #2 on: April 08, 2007, 10:13:07 PM »
Define a VirtualHost in the server-manager for your domain.
Create a folder in your templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts directory with the name of your VirtualDomain defined in the server-manager and copy the relevant sections of templates in there form templates/etc/httpd/conf/httpd.conf or create one file holding all the directives for your virtual domain.

I copied at least the following into some of mine (but a symbolic link might work as well and even be more comfortable in case original template fragments might change):
  • template-end
  • template-begin
  • 00Setup
  • 02ServerName
  • 25SSLDirectives
  • 26RewriteTrackAndTrace
  • 50DirectoryIndex*
  • 85DefaultAccess
  • a template fragment to implement the neccesarry settings for the domain, e.g. your smb-ledger directives (your 95* scripts)
edit: fixed list
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #3 on: April 09, 2007, 03:46:37 PM »
Thanks, Cactus.

I expect I am doing something wrong. Suggestions are welcome.

My understanding about the SME template system is that if I create a fragment in custom-templates that has a different name from one of the standard templates, it gets inserted in the expansion of the standard template at the point indicated by ascii name sequence. I further understand that if I have a fragment of the same name as a standard fragment, my custom fragment will replace the standard one during template expansion.

On that basis I did the following:

Following Cactus suggestion, I specified a domain of 'ledgers.imsig.ca' and pointed it to Primary.

I then created the directory /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts/ledgers.imsig.ca

Into that directory I added '20IbayContent' that contains the DocumentRoot directive. The standard 20IbayContent seems to be where DocumentRoot specifies the ibay directory. So this seemed the right place to have the domain point to my ledger-smb directory.

However, when I expanded the template, httpd.conf reflected no change from the standard.

Can anyone suggest where I have gone wrong?

Thanks for your help.

John
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Need help installing a web app
« Reply #4 on: April 09, 2007, 08:53:47 PM »
Quote from: "wjhobbs"
My understanding about the SME template system is that if I create a fragment in custom-templates that has a different name from one of the standard templates, it gets inserted in the expansion of the standard template at the point indicated by ascii name sequence. I further understand that if I have a fragment of the same name as a standard fragment, my custom fragment will replace the standard one during template expansion.
This is all correct.
Quote from: "wjhobbs"
On that basis I did the following:

Following Cactus suggestion, I specified a domain of 'ledgers.imsig.ca' and pointed it to Primary.

I then created the directory /etc/e-smith/templates-custom/etc/httpd/conf/httpd.conf/VirtualHosts/ledgers.imsig.ca

Into that directory I added '20IbayContent' that contains the DocumentRoot directive. The standard 20IbayContent seems to be where DocumentRoot specifies the ibay directory. So this seemed the right place to have the domain point to my ledger-smb directory.

However, when I expanded the template, httpd.conf reflected no change from the standard.
I guess that is because you did not make any changes to the standard... have you tried adding another file with a name which will result in a sort order in front or after the template fragment and add some basic text in there which you can search for in the expanded template to see if it works, e.g. a 10test file with some comment line:
Code: [Select]
# Trying to figure out if the template system works like I would :-)After that expand the template
Code: [Select]
expand-template /etc/httpd/conf/httpd.confAfter the successful expansion open the file using vi, pico or something you preffer or use grep to find your text. If everything is OK, don't forget to restart httpd-e-smith to reflect configuration changes:
Code: [Select]
/etc/init.d/httpd-e-smith restart
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #5 on: April 09, 2007, 09:43:18 PM »
The problem seems to be that anything in a sub-directory under /VirtualHosts is being ignored. In fact, if that is the only content in custom-templates, it does not even regenerate httpd.conf!

If I put a fragment in /VirtualHosts itself, this fragment expands in all of the virtual host sections of httpd.conf.

This seems to be at odds with the behaviour I expected. If this is standard behaviour, then I need to put conditional logic in a fragment in VirtualHosts.

Can anyone confirm which is the proper SME behaviour?

John
...

Offline cactus

  • *
  • 4,880
  • +3/-0
    • http://www.snetram.nl
Need help installing a web app
« Reply #6 on: April 09, 2007, 10:54:37 PM »
Oops  :oops:  I found an error in my instructions to you. I am terribly sorry. The directory of the VirtualHost should be on the same level as the VirtualHosts folder. Once again: sorry!
Be careful whose advice you buy, but be patient with those who supply it. Advice is a form of nostalgia, dispensing it is a way of fishing the past from the disposal, wiping it off, painting over the ugly parts and recycling it for more than its worth ~ Baz Luhrmann - Everybody's Free (To Wear Sunscreen)

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #7 on: April 10, 2007, 12:41:29 AM »
I do not know if it is a bug, or just that I am doing something wrong, or that it was just never designed to work that way, but a directory put in templates-custom either under /VirtualHosts or under /httpd.conf (same level as VirtualHosts) seems to be ignored by expand-template in either case.

To solve my problem, did the following:

I installed the application in /usr/local/ledger-smb according to the developers instructions.

I created a virtual domain 'ledgers.imsig.ca' using server-manager and pointed it to the Primary ibay.

To have the right DocumentRoot directive (pointing to the application directory) I copied '20IbayContent' from the standard template location to the corresponding templates-custom location under /VirtualHosts. I then adjusted the code in the copy in the following manner:
Code: [Select]
{
    if ($virtualHost eq "ledgers.imsig.ca")
  {
    $OUT = "";
    $OUT .= "    DocumentRoot /usr/local/ledger-smb\n\n";

  }
  else
  {
   ... Standard 20IbayContent fragment code ...
  }
}

The if...else structure that was added in front of the standard code inserts my custom DocumentRoot directive for the specified virtual domain and allows normal processing for the others.

I then created a '95ledger-smb' custom template fragment in the httpd.conf directory to hold the Directory directives for the key application directories.

I then created a '60WebRedirect' custom template fragment under VirtualHosts that contained a RewriteRule to force this virtual domain's access always to use https, like this.
Code: [Select]
#
# RewriteRule directives for LedgerSMB
#
RewriteEngine on
{
return "" unless $virtualHost eq "ledgers.imsig.ca" and $port ne "443";
'RewriteRule ^/(.*)$ https://ledgers.imsig.ca/$1 [R,L]';
}


I then expanded the templates and restarted Apache.

And it seems to work!  :D

If anyone has suggestions for a better way to approach this, I would like to hear them. (The RewiteRule fragment looks a little awkward to me.)

My thanks to Cactus for pointing me in the right direction.

John
...

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #8 on: May 24, 2007, 06:24:14 AM »
Did you have to move to postgres 8 ?
Sophie from Montréal

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #9 on: May 25, 2007, 11:21:40 PM »
Quote from: "soprom"
Did you have to move to postgres 8 ?

Yes. Postgres 8.x is a requirement for ledger-smb.

Here is what I did to upgrade to postgresql 8.
Code: [Select]
# yum --enablerepo=centosplus install postgresql postgresql-contrib postgresql-devel postgresql-docs postgresql-pl postgresql-python postgresql-test
And then we need LaTeX (for pretty output) and the C compiler (to install some of the Perl components).
Code: [Select]
# yum --enablerepo=base --enablerepo=updates install tetex-latex gcc
I was going to publish a full how-to; but decided to wait until Ledger-smb 1.2 stabilizes.

John
...

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #10 on: May 27, 2007, 04:15:05 AM »
I'm installing with a different technique using folder /opt/ledgersmb

User and database are created, but the database has not been initialized (loaded with sql statements) in any way.

My problem is that login is denied... The httpd/error shows this:
Quote

Math::BigInt: couldn't load specified math lib(s), fallback to Math::BigInt::Calc at LedgerSMB/Form.pm line 36, referer: http://lla-main/ledgersmb/admin.pl

DBD::Pg::st execute failed: ERREUR:  La relation \xabusers_conf\xbb n'existe pas, referer: http://lla-main/ledgersmb/admin.pl

DBD::Pg::st fetchrow_hashref failed: no statement executing, referer: http://lla-main/ledgersmb/admin.pl


Any clue?
Quote
Sophie from Montréal

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #11 on: May 27, 2007, 04:31:22 AM »
Hi Sophie,

I presume you have postgres set up and configured correctly, that you have ledgersmb set up as superuser, that template1 is set up and that all the required Perl modules are installed.

If all of this is true, then I suspect the problem is not on the SME Server end. I suggest you pose the question on the LedgerSMB mailing list. They are very helpful, but you might have to adjust their responses to fit the SME Server configuration.

If you still think it is a problem with the SME setup, let me know and I will tell you how I installed LSMB 1.1.12 -- which may be similar to what is needed for the 1.2.x install.

John
...

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #12 on: May 27, 2007, 07:24:57 AM »
ledgersmb is superuser.

Besides, I saw that postgres 8 is required. Some sql statements are causing errors. If I upgrade postgres, will it break Sql-ledger?

As I want to keep sql-ledger running until I'm sure I can migrate, I don't want to mess my accounting system.
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #13 on: May 27, 2007, 07:31:13 AM »
I would very much like to know how you installed LSMB 1.1.12 !
Thanks in advance...
Sophie from Montréal

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #14 on: May 27, 2007, 03:28:55 PM »
Quote from: "soprom"

Besides, I saw that postgres 8 is required. Some sql statements are causing errors. If I upgrade postgres, will it break Sql-ledger?

As I want to keep sql-ledger running until I'm sure I can migrate, I don't want to mess my accounting system.

Ah! Now I understand.

SQL-Ledger should work just fine after a postgres upgrade. (But be sure to backup the SL dataset before you start just to be safe.)

Go ahead and upgrade pgsql. Then test SL to confirm that it still works. Then test LSMB to see if the problems have been resolved. Let us know the result.

John
...

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #15 on: May 27, 2007, 03:41:38 PM »
There is a problem with upgrading from pg7.4.17 to pg8 with  php-common
Quote

yum --enablerepo=centosplus install postgresql postgresql-contrib postgresql-devel postgresql-docs postgresql-pl postgresql-python postgresql-test


Quote

Transaction Check Error:   file /etc/php.ini from install of php-common-5.1.6-3.el4s1.5 conflicts with file from package php-4.3.9-3.22.5


So I renamed /etc/php.ini -> .old and did the upgrading. Then I restored php.ini

After rebooting the serveur, php seams to work but sql-ledger is broken.
Quote
could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"?
Sophie from Montréal

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #16 on: May 27, 2007, 04:55:21 PM »
I'm not sure.

Could you check to see which repository centosplus is pointing to. SME7 is based on Centos4 but Centos recently made Centos5 available -- which includes php5. SME7 is only at php4. It is possible that your yum repo for centosplus is pointing at the wrong repository.

db yum_repositories show | more

should show what repositories are specified. The centosplus repo should be pointing to .../centos/4/centosplus/...

John
...

Offline wjhobbs

  • ****
  • 171
  • +0/-0
    • http://www.chryxus.ca
Need help installing a web app
« Reply #17 on: May 27, 2007, 05:03:08 PM »
Quote from: "soprom"
I would very much like to know how you installed LSMB 1.1.12 !

I put the how-to here http://forums.contribs.org/index.php?topic=37181.0

John
...

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #18 on: May 27, 2007, 05:06:13 PM »
It appears that databases are to be upgraded!

Here's what I did to make sql-ledger work again:

Before upgrading postgres, I had a dump of all databases (pg_dump -c -F p -U postgres <database>).
Stop postgres
yum install as above

Code: [Select]

UPGRADE TO 8:
=============

mv /var/lib/pgsql/data /var/lib/pgsql/data7.4
su postgres
initdb -D /var/lib/pgsql/data
exit

/etc/init.d/postgresql start
mv /home/e-smith/files/ibays/../databases/pg_*.* /var/lib/pgsql/backups

su postgres
cd /var/lib/pgsql/data
createuser -d -P sql-ledger
createuser -d -P ledgersmb
createdb ledgersmb
createdb <databases>
createlang plpgsql template1
exit

psql <databases> < backups/pg_<databases>


Sql-ledger is now working!
Ouch!!
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #19 on: May 27, 2007, 05:20:34 PM »
pgAdmin is not working anymore...
pgsql.so is not loading.
I don't want to upgrade to php5 because SME7 will break on the next update.
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #20 on: May 27, 2007, 09:15:26 PM »
php is having problems...
Quote
Unable to load dynamic library '/usr/lib/php4/pgsql.so'
Unable to load dynamic library '/usr/lib/php4/pdo.so'
Unable to load dynamic library '/usr/lib/php4/pdo_pgsql.so'
Unable to load dynamic library '/usr/lib/php4/pdo_sqlite.so'
Unable to load dynamic library '/usr/lib/php4/pgsql.so'

I copied files in modules folder to php4 folder but nothing does it.
From a search, I see that this means php5 is required.
How can I roll back to postgresql 7 ?

Help !
Sophie from Montréal

Offline soprom

  • *
  • 589
  • +0/-0
    • www.logiciel-libre.org
Need help installing a web app
« Reply #21 on: May 27, 2007, 11:53:07 PM »
John,
Thanks for your howto. I'm trying it.
Sophie from Montréal