Koozali.org: home of the SME Server

Settinging document root to /opt/myapp

guest22

Settinging document root to /opt/myapp
« on: January 24, 2017, 02:22:25 PM »
Hi,


what is the (correct) way, if possible, to set the document root to /opt/myapp ? The /opt/myapp sees the Primary ibay as document root. Can I used a php_admin_flag or a custom fragment in httpd.conf?


TIA

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Settinging document root to /opt/myapp
« Reply #1 on: January 25, 2017, 02:50:44 AM »
I think it is a hack to httpd.conf

I guess the clues are in this section https://wiki.contribs.org/Useful_Commands#Apache_Related_Commands

You probably need a custom fragment based on that. Add one of those commands to an ibay, update and then check the httpd.conf and VirtualHost sections.

A quick grep of /etc/httpd/conf like this shows some Pydio settings

grep -rn base /etc/httpd/conf/*

php_admin_value open_basedir /usr/share/pydio:/var/lib/pydio:/var/log/pydio:/etc/pydio:/var/cache/pydio:/usr/share/pear/:/home/e-smith/files/shares

B. Rgds
JC
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation

guest22

Re: Settinging document root to /opt/myapp
« Reply #2 on: January 27, 2017, 12:54:19 PM »
Thanks, but that's about setting php open basedir as per wiki (useful commands). I'm looking very specifically how to set the document root.

Offline ReetP

  • *
  • 3,722
  • +5/-0
Re: Settinging document root to /opt/myapp
« Reply #3 on: January 27, 2017, 02:13:50 PM »
Thanks, but that's about setting php open basedir as per wiki (useful commands). I'm looking very specifically how to set the document root.

It's in httpd.conf

Note I never knew how to do this and found out by having a grep about for DocumentRoot and looking at the code in some contribs

[root@esmith conf]# grep Document httpd.conf
# Documentation for modules is in "/home/httpd/manual/mod" in HTML format.
# DocumentRoot: The directory out of which you will serve your
DocumentRoot /home/e-smith/files/ibays/Primary/html
DocumentRoot         /home/e-smith/files/ibays/crm/html

Set via the httpd.conf templates e.g.

cd /etc/e-smith/templates/etc/httpd/conf/httpd.conf

[root@home httpd.conf]# grep -rn Document *
15DSOstart:14:# Documentation for modules is in "/home/httpd/manual/mod" in HTML format.
50DocRoot:1:# DocumentRoot: The directory out of which you will serve your
50DocRoot:5:DocumentRoot /home/e-smith/files/ibays/Primary/html
VirtualHosts/20IbayContent:15:    $OUT .= "    DocumentRoot         $basedir/html\n";
WebAppVirtualHost/50Content:55:    my $root = $domain->prop('DocumentRoot') ||
WebAppVirtualHost/50Content:58:    $OUT .= "    DocumentRoot $root\n";

Unfortunately it will only point to one of your existing ibays (check $basedir in templates, VirtualHosts/20IbayContent), so if you want to use /opt you need a bit of trickery.

Make your own virtualhost templates (copy over another example) to a new directory. If you used the stock one as a template then you can modify $basedir depending on what you want as a trigger for it.

A good one to use as a base would be the WebAppVirtualHost from Dans contrib - see the template 50Content to see how the DocumentRoot is set.

/etc/e-smith/templates/etc/httpd/conf/httpd.conf/WebAppVirtualHost -> VirtualhostTest

Modify templates to give you the config required.

You then need to tell a domain to use that template path to create the required VirtualHost entry in httpd.conf (other config entries removed for clarity):

my.domain.net=domain
    Description=my opt domain
    TemplatePath=VirtualhostTest

Job done. The only aside is why make life difficult and use /opt ? i know it used to be considered better but as far as I understand it now there is no reason not to just use an ibay.


B. Rgds
John
...
1. Read the Manual
2. Read the Wiki
3. Don't ask for support on Unsupported versions of software
4. I have a job, wife, and kids and do this in my spare time. If you want something fixed, please help.

Bugs are easier than you think: http://wiki.contribs.org/Bugzilla_Help

If you love SME and don't want to lose it, join in: http://wiki.contribs.org/Koozali_Foundation