Siwapp Deployment Strategies

Unpacking siwapp files onto a web server can sometimes be challenging. Here are a few tips to help your out.

sf_root_dir, sf_web_dir... what??

In several posts at the forum, and at some point at the siwapp installation instructions, you will be talked about these two "things" called "sf_root_dir" and "sf_web_dir". What are these?

In short terms

sf_root_dir is the folder in which siwapp 'internal' folders (apps/, logs/, lib/...) and files are deployed, and sf_web_dir is the folder in which the files siwapp needs to be publicly accessed through the web are (index.php, css/, js/...) (wow, that was messy).

A somehow longer explanation

When you unpack the siwapp package, you get this folder/files structure:

  • LICENSE (this is a file)
  • symfony (this is a file)
  • apps/
  • config/
  • data/
  • doc/
  • lib/
  • plugins/
  • test/
  • web/

Only the contents of the 'web' folder needs to be somewhere on a web server 'public_html' folder. All the other folders are 'internal' siwapp folders that doesn't have to be reachable through the web.

sf_root_dir is the directory where all the siwapp 'internal' folders are installed. These are the folders siwapp needs to be operative. These folders doesn't have to be visible in a web server. In fact they shouldn't. These folders are:

  • symfony
  • apps/
  • config/
  • data/
  • doc/
  • lib/
  • plugins/
  • test/
  • cache/ (this folder doesn't come with the installation package. you need to create it yourself)
  • log/ (this folder doesn't come with the installation package. you need to create it yourself. It's optional, though)

sf_web_dir is the directory where the siwapp web folder contents is. This is the only contents that needs to be visible in your web browser. In the default package, this is just the web folder and its contents. This folder is generally located at the same place than the others siwapp internal folders, but it doesn't have to be like that.

Let's do some "learning by example". Say you've decompressed your package in the /home/jzarate/src/. Then you should have this structure:

  • /home/jzarate/src/symfony
  • /home/jzarate/src/apps/
  • /home/jzarate/src/config/
  • /home/jzarate/src/data/
  • /home/jzarate/src/doc/
  • /home/jzarate/src/lib/
  • /home/jzarate/src/plugins/
  • /home/jzarate/src/test/
  • /home/jzarate/src/web/
    • /home/jzarate/src/web/config.php
    • /home/jzarate/src/web/index.php
    • /home/jzarate/src/web/installer_dev.php
    • /home/jzarate/src/web/installer.php
    • /home/jzarate/src/web/pre_installer_code.phpt
    • /home/jzarate/src/web/pre_installer_instructions.php
    • /home/jzarate/src/web/siwapp_dev.php
    • /home/jzarate/src/web/css/
    • /home/jzarate/src/web/js/
    • /home/jzarate/src/web/images/
    • /home/jzarate/src/web/sfFormExtraPlugin/
    • /home/jzarate/src/web/sfJqueryReloadedPlugin/
    • /home/jzarate/src/web/uploads/
    • /home/jzarate/src/web/robots.txt

NOTE: I've detailed the contents of the "web" folder, just to make sure you notice it.

Well, in this particular case:

  • your sf_root_dir would be where the siwapp internal folders are, which is /home/jzarate/src
  • your sf_web_dir would be where the web contents is, which is /home/jzarate/src/web

Deployment strategies

The big news is sf_root_dir and sf_web_dir are decoupled!! They don't need to share the basedir, they just need to have some common path, but not the whole thing!!

Say your shared hosting ftp account have the following structure:

  • /home/basic_users/kelly/
  • /home/basic_users/kelly/public_html/
  • /home/basic_users/kelly/stats/
  • /home/basic_users/kelly/cgi-bin/

"public_html" would be the folder whose contents your web server displays.

all this configurations would be acceptable for siwapp:

Config Case 1. Just dump the whole thing into your public_html dir

If you just unzip the package inside some folder inside your public_html directory, you obtain:

  • /home/basic_users/kelly/public_html/siwapp/apps/
  • /home/basic_users/kelly/public_html/siwapp/config/
  • /home/basic_users/kelly/public_html/siwapp/lib/
  • /home/basic_users/kelly/public_html/siwapp/....
  • /home/basic_users/kelly/public_html/siwapp/web/
  • /home/basic_users/kelly/public_html/siwapp/web/installer.php
  • /home/basic_users/kelly/public_html/siwapp/web/....

With this config, you should point your browser to http://yourdomain.com/siwapp/web/. The essential variables would be:

  • sf_root_dir would be /home/basic_users/kelly/public_html/
  • sf_web_dir would be /home/basic_users/kelly/public_html/web

This is highly not recommended. having all your essential folders publicly available, is not just a 'security hole' , it's turning your site and database into a campus frat house.

Config Case 2: Rename your 'web' folder as 'public_html'

In this case, you unpack your siwapp folders on the same folder your 'public_html' folder is, and then put all the contents of your siwapp 'web' folder into your 'public_html' folder:

  • /home/basic_users/kelly/apps/
  • /home/basic_users/kelly/config/
  • /home/basic_users/kelly/lib/
  • /home/basic_users/kelly/...
  • /home/basic_users/kelly/public_html/installer.php
  • /home/basic_users/kelly/public_html/siwapp_dev.php
  • /home/basic_users/kelly/public_html/index.php
  • /home/basic_users/kelly/public_html/css/
  • /home/basic_users/kelly/public_html/....

With this config, you should point your browser to http://yourdomain.com/

The essential variables would be:

  • sf_root_dir would be /home/basic_users/kelly/
  • sf_web_dir would be /home/basic_users/kelly/public_html/

The only inconvenience of this config is that you may not like having all your siwapp folders scattered on your home directory, but otherwise it's fine as long as security is concerned.

Config Case 3: Rename your web folder as 'public_html', bundle the rest in another folder

Put the contents of your 'web' folder in 'public_html' and put the siwapp internal folders and files onto another folder within your home directory. Something like this:

  • /home/basic_users/kelly/siwapp/apps/
  • /home/basic_users/kelly/siwapp/config/
  • /home/basic_users/kelly/siwapp/lib/
  • /home/basic_users/kelly/siwapp/symfony
  • /home/basic_users/kelly/siwapp/doc/
  • /home/basic_users/kelly/siwapp/...
  • /home/basic_users/kelly/public_html/installer.php
  • /home/basic_users/kelly/public_html/index.php
  • /home/basic_users/kelly/public_html/siwapp_dev.php
  • /home/basic_users/kelly/public_html/css/
  • /home/basic_users/kelly/public_html/js/
  • /home/basic_users/kelly/public_html/.....

With this config, you should point your browser to http://yourdomain.com/ The essential variables would be:

  • sf_root_dir would be /home/basic_users/kelly/siwapp/
  • sf_web_dir would be /home/basic_users/kelly/public_html/

This one is quite OK. You have all your siwapp internal folders and files inside a 'siwapp' folder, and all the contents of the siwapp 'web' folder inside your public_html folder. The only drawback is that you may want your public_html folder to have other stuff , too.

Config Case 4: Your web folder inside your public_html, your internal folders bundled onto another folder

Put the contents of your 'web' folder in a particular folder inside 'public_html' and put the siwapp internal folders and files onto another folder within your home directory. That would look like:

  • /home/basic_users/kelly/siwapp/apps/
  • /home/basic_users/kelly/siwapp/config/
  • /home/basic_users/kelly/siwapp/lib/
  • /home/basic_users/kelly/siwapp/symfony
  • /home/basic_users/kelly/siwapp/doc/
  • /home/basic_users/kelly/siwapp/...
  • /home/basic_users/kelly/public_html/billing/installer.php
  • /home/basic_users/kelly/public_html/billing/index.php
  • /home/basic_users/kelly/public_html/billing/siwapp_dev.php
  • /home/basic_users/kelly/public_html/billing/css/
  • /home/basic_users/kelly/public_html/billing/js/
  • /home/basic_users/kelly/public_html/billing/.....

With this config, you should point your browser to http://yourdomain.com/billing The essential variables would be:

  • sf_root_dir would be /home/basic_users/kelly/siwapp/
  • sf_web_dir would be /home/basic_users/kelly/public_html/billing/

This one is a good one, too. You've have all your siwapp web files contained on your 'billing' folder at your web server, so you can keep other stuff at it, too.