Running HPI on an Apache HTTP Server - tsgrp/HPI GitHub Wiki
Using grunt, run the following command:
grunt distDebug --project=projectName --env=envName
This will create files in the DIST folder that can be placed into an directory to create a static web application.
- Edit httpd.conf
- Enable the following modules by uncommenting these lines:
- LoadModule proxy_module modules/mod_proxy.so
- LoadModule proxy_ajp_module modules/mod_proxy_ajp.so #if using the ajp forwarding module
- LoadModule rewrite_module modules/mod_rewrite.so
- Include extra vhosts file by uncommenting the following line:
- Include conf/extra/httpd-vhosts.conf
- Enable the following modules by uncommenting these lines:
Although Apache servers can be set up in any number of ways, these instructions will assume a vanilla build from source code found at the Apache HTTP Server Project website. In your apache2/conf directory, you'll find httpd.conf which defines the configuration for your server. This configuration file will define a default directory (apache2/htdocs) to place the files you found in the DIST folder after building with Grunt. You could modify this directory to specify a more obvious location such as /var/www//.
Since HPI assumes that it can call /OpenContent or /alfresco with your hostname (eg. http://localhost/alfresco), we'll need to define a VirtualHost and set up a proxy to forward back-end calls to the correct location. This can be done in an external file (conf/extra/http-vhosts.conf) or directly in httpd.conf. In any case, your configuration should look something like this, replacing references to localhost with the actual location of your OC service:
<VirtualHost *:80>
ServerName apacheComputerName
AllowEncodedSlashes On
#Optionally forward all root requests (ex. http://foo.com redirects to http://foo.com/hpi)
#RewriteEngine on
#RewriteRule ^/$ /hpi [PT]
#proxy /alfresco and /share calls to the alfresco server
ProxyPass /alfresco http://alfrescoServerName:8080/alfresco
ProxyPass /share http://alfrescoServerName:8080/share
#could optionally use ajp instead of http to make the requests
#ProxyPass /alfresco ajp://alfrescoServerName:8009/alfresco
#if running hpi on Tomcat (a separate tomcat from the Alfresco tomcat) then proxy to that tomcat to allow users to go to http://foo.com and direct them to the hpi running on
#ProxyPass /hpi ajp://tomcatServerName:8009/hpi
</VirtualHost>
Since HPI is a single-page javascript application, our only actual HTML page is an index.html file. In order to redirect all requests to that index.html (where our javascript code then handles the routing to our pages), we'll need to use the rewrite_module.
<Directory "/usr/local/apache2/htdocs">
#Turn on RewriteEngine
RewriteEngine On
#Rules
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule (.*) /index.html [L]
</Directory>