Download the TransBASE project from Github.

Easy enough — just click the Download ZIP button or fork it if you’re savvy Git. I’m not a programmer by training so the project can probably use professional help. Please feel free to contribute.

step1a

Setting up an Amazon EC2 instance.

There are many excellent tutorials on the internet for setting up an Amazon EC2 cloud service so I’m going to not spend much time detailing these steps. I’m going to use a Windows machine because I’m lame but the project could definitely be hosted on Ubuntu if you’re into that.

Click Launch Instance to get the following screen.

step2

Select your flavor of server. I’m going to use Windows Server 2008 R2 Base. None of the components that make up TransBASE are Windows specific so you could choose something else here but you’re on your own as far as setting it up.

step3

For this tutorial I’m going to use a micro instance to keep the cost low. If you’re planning on running this in a production environment you will definitely want something more powerful.

step4

On the next page let’s only start up one instance. You could also assign a static IP address at this point but we’ll cover that later.step5

Next bump the volume’s size up to 60 gigs. That should be more than enough space for both Windows and all the other components/data.step6

Give the project a Key and Value to make it easy to search for. A better Key/Value than the one in the image could be name/transbase_demo.step7

Next you will be asked to setup a security group. You will need to allow connections through ports 3389 (make sure you specify only your IP address as being allowed to RDP), 80 (for Apache/PHP), 8080 for Tomcat, and 5432 for PostGIS. step8

Next you will be shown a review of your instance. Click the Launch button. A splash screen will appear asking you to select a private key that you will use to create a password for your server. Select Create a new key pair, give it a name, and download the .pem file. Save this file somewhere you will remember and in a place where it wont publicly accessible. Click Launch Instance and make yourself a snack — it usually takes 5-10 minutes for the instance to get up and running.step10

Once your instance is running give it a name if you didn’t do so during the launch process. step13

Next you need to assign an Elastic IP. This is prevent the IP address of the instance from being reset any time the instance is turned off. You can also use this static IP address with a DNS (I like namecheap). On the right hand menu click Elastic IPs. Click Allocate New Address towards the top of the screen. On the window that opens select VPC from the dropdown.

step15

A new IP address will be created and added to the main page. Right click the new IP address and select Associate Address. In the window that appears select the instance you just created and click Associate. In this case I’m using 52.8.187.0 as my elastic IP. step16a

Now you can connect to your instance using Remote Desktop, the key you downloaded earlier, and this static IP address. Go back to the Instances page (on the right side menu) and then right click your instance. Click Get Windows Password from the menu.step17

Upload your key (the .pem file) and click Decrypt Password — save this password somewhere you will remember.step19

Right click your instance again and click Connect. A .rdp file will download. Using the password you just obtained, try logging into your instance.

step24

Congrats! You’re now in the cloud.

Preparing the Stack. 

The first thing you need to do is disable Internet Explorer’s crazy security settings so you can actually download all the open source components you need for TransBASE. Click the Server Manager button next to the Start Menu. In the Server Manager window click on Configure IE ESC.step25

In the Internet Explorer Enhanced Security Configuration window turn off IE ESC for both Administrators and Users.

step26

Next you will need to download PostgreSQL/PostGIS. I prefer the package created by EnterpriseDB because it includes Apache (version) with PHP enabled and a stack builder for enabling PostGIS/ODBC in one install. You can download EnterpriseDB’s PostgreSQL installer here (link). If you would like to use PostGIS with ESRI ArcGIS I recommend installing version 9.1 – check out this link for more information.

step27

Run the installer to setup PostgreSQL and click Next.

step28

Select a location to install PostgreSQL. I’m going to go with the default installation location for this tutorial.

step29

Select a location where your data will be stored. Again, I’m going to go with the default.

step30

Create a password for your superuser account. By default this user will be given the name postgres. Make sure you write your password down.

step31

Enter the port number you would like PostgreSQL to listen on. I’m going to use the default of 5432 for this tutorial.

step32

Select a language.

step33

Finally, PostgreSQL is ready to be installed. Click Next to continue.

step34

At the end of the installation you will be prompted to Launch Stack Builder. Make sure this option is checked and click Finish.

step36

Select your installation of PostgreSQL and click Next.

step37

Check the following applications for installation: psqlODBC (if you want to use ODBC with your database); PostGIS 2.0 under spatial extensions; and Apache/PHP v2.4.12 under Web Development. A screen will appear confirming your selected packages. Use the default directory and click Next.

step38

Each package you selected will then install. Click next until finished. For this tutorial I am using the default installation location for all of these components. Please use port 80 for the Apache/PHP server.

step44

When you get to the PostGIS installer make sure “create spatial database” is checked.

step52

Again, select an installation location. It should default to the location of your PostgreSQL folder.

step53

Enter your postgres superuser information and click Next.

step54

At this point you may receive an error message during the PostGIS installation. There seems to be a problem with the EnterpriseDB installer; however, you can click Ignore and continue the installation. The missing .dll doesn’t seem to have any adverse effect of PostGIS.

step56

When asked to register an environmental variable for GDAL_DATA click Yes. GDAL is the library PostGIS uses to do Raster transformations. You can learn more about this cool project here (link).

step57

After the installation of all the packages is complete verify that Apache has been installed correctly by opening your browser and navigating to http://localhost/.

step57a

Next click on the Start Menu an open pgAdmin. pgAdmin is a create GUI for accessing and querying your PostgreSQL databases.

step58

Double click on your PostgreSQL instance. You will be prompted for the password you setup during installation. You should see two databases: postgis_template and postgres.

step59

Let’s create a new database for all the data in TransBASE by restoring the pg_dump found on GitHub. Right click on your instance of PostgreSQL and select New Database.

(need image)

Give it a name. In this tutorial I’ll be using transbase_demo. Set the owner of this new database to be your postgres superuser.

step61

Next click on the Definition tab at the top of the window. Use the postgis_template as the template for this new database. The postgis_template has the PostGIS extension enabled and includes all the internal tables PostGIS will need to create geospatial data. Use UTF8 for encoding. Click OK to create a new empty database.

step62

Right click on transbase_demo and click Restore. In the window that appears select Custom or tar from the dropdown box and navigate to the pg_dump of TransBASE you downloaded off GitHub then click Restore.

step63

You may receive a message that the role “opendata” does not exist. A read-only role is current used on TransBASE with the name opendata. You can create this role at a later time if needed. This error will not impact the tutorial.

step64

Double check that the pg_dump has been restored properly by checking out the tables under the public schema. As of 6/14/2015 39 tables and 36 views should be created.

step65

Create a spatial query to ensure PostGIS is running properly with the new data. Click SQL button in the top tool bar and enter the following SQL statement:

SELECT count(vw_geo_intrsctn_switrs_all_types_cyc_col_prty_vctm.unique_id), geo_bndry_neighborhoods.neighborho FROM vw_geo_intrsctn_switrs_all_types_cyc_col_prty_vctm, geo_bndry_neighborhoods WHERE ST_Intersects (vw_geo_intrsctn_switrs_all_types_cyc_col_prty_vctm.geom, geo_bndry_neighborhoods.geom) GROUP BY geo_bndry_neighborhoods.neighborho ORDER BY count(vw_geo_intrsctn_switrs_all_types_cyc_col_prty_vctm.unique_id) DESC

This query will show a count of cyclist collisions by neighborhood in San Francisco.

step66

 

Next you will need to setup Windows Firewall to allow incoming and outgoing connections on ports 80, 8080, and 5432. Click on the Start Menu then enter “firewall” in to the search bar and open the Windows Firewall with Advanced Security window.

step67

Click Inbound Rules on the left side of the window then click New Inbound Rule on the left side of the window. Create a new rule that allows a TCP connection on port 5432 then click Next.

step68

In the Action section select Allow the connection then click Next.

step69

In the Action section select Allow the connection then click Next.

step70

Give your new rule a name.

step71

Repeat the step above to create inbound and outbound rules that allow connections on ports 80 and 8080 as well following the steps above.step119

Next you will need to set PostgreSQL to allow connections from any IP address. You can quickly access pg_hba.conf using pgAdmin. Click on Tools, Server Configuration, then click pg_hba.conf.

step72a

Double click the top host.

step72

Change the IP Address to 0.0.0.0/0. This will allow any IP Address to connect to this instance of PostgreSQL. You could also limit this IP address to the range of your internal network if desired.

step73

Next you will want to setup Apache Tomcat. Tomcat is a Java servlet that we will use to run Geoserver and MapFish Print. The first step is to install a Java Runtime Environment (JRE). In this tutorial we’ll run Java SE Runtime Environment 8 64bit.

step74

Double click the installation file after it has finished download. We’re going to all Java to install in the default location. Click Install.

step75

After Java has finished we will need to create an environmental variable to our Java environment. In the Control Panel navigate to Systems and Security then Systems – click Advance system settings on the left hand site.

step76

In the System Properties window click the Advance tab.

step77

Click the Environmental Variables button toward the bottom of the window and create a new variable with the name JAVA_HOME and variable value that points to your …\Java\jre folder.

step78

Next we will need to download Tomcat. For this tutorial I’m going to use Tomcat 7. Download the 32/64-bit Windows Service Installer.

step79

After the installer downloads run it and click next when the Tomcat Setup screen appears.

step80

Select the Normal installation and click next.

step81

Use the default settings. In this tutorial Tomcat will be operating on port 8080. Click next.

step82

If you set up your JAVA_HOME environmental variable correctly the Tomcat installer should recognize the location of your JRE’s installation directory. Click Next.

step83

Pick a directory to install Tomcat or use the default location.

step84

When the installation wizard is complete check Run Apache Tomcat and click Finish.

step85

 

Tomcat will now start and run as a service.step86

 

Open your browser and navigate to http://localhost:8080/. If Tomcat has been installed properly you should see the following page:

step87a

Next you will need to download a Geoserver web archive (WAR) to run on the Tomcat servlet. You can obtain the WAR file here. Geoserver will allow data stored in PostGIS to be served out in a variety of OGC compliant forms and consumed by a client application.

step88

Download the latest Geoserver WAR (at the time of this writing 2.7.1), unzip the file, and save the .war file into the following directory: C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps.

step90a

 

step90b

Next you will need to add a role and user to access Tomcat’s manager interface. Navigate to the following file: C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\tomcat-users.xml and open the file in a text editor.step91a

step100Add the following role and user in between the <-tomcat-user> tags:

<role rolename = “manager-gui”/>

<user username=”manager” password=”[your_pass_word_here]” roles=”manager-gui”/>

Save the file when complete.step91

Open the Tomcat manager (bottom right side of Windows bar at the bottom of the screen) then stop and start Tomcat.

Navigate to the Tomcat web application manager interface located here: http://localhost:8080/manager/

Log in using the user name and password you created previously.

step92

 

step93

In the manager interface you should see Geoserver as an application. Double check that the service is running.

step94

Next navigate to the following web address: http://localhost:8080/geoserver. You should see the default Geoserver manager page.

step95

The default user name for logging into Geoserver is “admin” and the password “geoserver.” Make sure to change these to something more secure using the web manager. After you login you should see a screen similar to the one below.

step96

Some of the layer styles used in TransBASE require the Web Protocol Service (WPS) extension. This is not natively installed with Geoserver and will need to be added manually. Please go to the following website and download the appropriate zip file for your version of Geoserver.

step97

Unzip or copy/paste the files you just downloaded to the following folder: C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\geoserver\WEB-INF\lib.

step98

Restart Tomcat and log back into the Geoserver manager. On the left side of the page under Services an image for WPS should now be shown. Click WPS and verify that it is enabled.step100

Next you will need to overwrite Geoserver’s workspace with TransBASE’s styles and layers. Copy the following folder from your Github download and paste it in this here: (folder). If asked if you would like to merge and overwrite the existing workspaces folder in Geoserver click yes.step101

step102

Double click on the workspaces folder and delete all the other folders except transbase_public.

step103

Double click on transbase_public and open datastore.xml in a text editor. You will need to change the database stores properties to match your PostGIS instance.step104

Navigate to the section of XML under <connectionParamters>. Change the following parameters to match your PostGIS instance:

<entry key=“passwd”>[your_password]</entry>

<entry key =“database”>[name_of_your_transbase_database]</entry>

<entry key=“user”>[name_of_your_user_if_not_postgres]</entry>

Save this file and restart Tomcat.

step105

Log back into the Geoserver manager and click on the Layers link on the left side of the page. You should now see several layers/views being pulled from your PostGIS instance.

step106

Next you will need to configure Apache and Tomcat to work together on the same port. Some of the pages that make up TransBASE utilize PHP which Apache can easily process. An alternative would be setting up Tomcat to use PHP but I’ve never had any luck getting it to work properly. Navigate to the following — C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\apache\conf — and open httpd.conf in a text editor.

step108

Search for the following modules and uncomment (remove the # sign) in front of them:

modules/mod_proxy_http.so

modules/mod_proxy.so

step109

 

step110

Near the top of httpd.conf you will need to set up a virtual host to route traffic for the Tomcat serevlet to Port 8080 while allowing PHP based pages to be processed by Apache Server. Copy the following text under “Listen 80”:

NameVirtualHost *:80

<VirtualHost *:80>
ServerName [your_ip_address]/transbase
ProxyRequests Off
ProxyPreserveHost On

<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /metadata/metadata.php !
ProxyPass /metadata/connection.php !
ProxyPass /headerimages/rotate.php !
ProxyPass /bugreport/bugpage.php !
ProxyPass /newdatasets/newdatasets.php !
ProxyPass /youtube/youtube.php !
ProxyPass /metatable/metatable.php !
ProxyPass /connection/connection.php !
ProxyPass /faq/faq.php !
ProxyPass /logo/transbase_logo.png !
ProxyPass / http://[your_ip_address]:8080/
ProxyPassReverse / http://[your_ip_address]:8080/
</VirtualHost>

Make sure to replace the bracketed text with your IP address.

step111

The next step is to set up a Connector port on Tomcat to redirect outbound 8080 traffic back to Apache on port 80. Copy the following text into C:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\server.xml under <Connector…>:

<Connector port=”8080″
maxThreads=”150″ minSpareThreads=”25″ maxSpareThreads=”75″
enableLookups=”false” acceptCount=”100″ connectionTimeout=”20000″/>

Save the file when you’re finished.

 

step112

Copy and paste the transbase folder into your webapps folder on Tomcat — C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps.

 

step113

Open C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\transbase\scripts\heron-config\DefaultOptionsWorld.js and open it with a text editor. Use find and replace all to replace “transbasesf.org” with your project’s IP address.

step114

Next copy over the ROOT folder into the webapps folder on Tomcat. If asked, say yes to overwriting any of the existing files in the ROOT folder.

step115

 

step116

Open up C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\ROOT\index.html in a text editor and change “transbasesf.org” to your domain or IP address.

step117

Next copy all folders in the transbase apache folder over to here: C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\apache\www.

step119b

Copy the print-servlet-2.0-SNAPSHOT folder into C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps. In order to enable MapFish Print you will need to open C:\Program Files\Apache Software Foundation\Tomcat 7.0\webapps\print-servlet-2.0-SNAPSHOT\config.yaml and change the host to your IP address.step119c

MapFish also requires an installation of Python 2.7 to operate. You can find Python here.

 

stepp1

Run the installer and click Finish when it has completed.

stepp2

Open up the Services window and restart both EnterpriseDB ApachePHP and Tomcat.

step120a

step120

Navigate to your IP address in a web broswer and it should redirect to the TransBASE web application. Turn a layer on to make sure everything is working properly.

step121

Click the printer icon and verify that MapFish Print is working correctly.

step123

That’s it. The next steps would be to replace data in PostGIS with your own and modify the layers in TransBASE as needed to match your needs.