Deploying a Static Website

Updated by Chris Sterling on May 08, 2015
Article Code: a844

The AppFog service will be retired as of June 29, 2018. Beginning on this date, the AppFog Platform-as-a-Service will no longer be available, including all source code, env vars, and database information.


Application developers


AppFog includes the Cloud Foundry Static File buildpack by default. This enables the deployment of static websites to AppFog. The Static File buildpack will serve up files using Nginx. Given that Nginx only needs about 20 MB of memory to run, you are able to run using much lower memory than the default of 1 GB that AppFog allocates to an application. This will mean that your memory usage will be lower and this will reflect in lower cost to run a static website. We recommend 64 MB as the amount of memory to reserve for most static websites.

Deploying a Static Website

To make AppFog automatically use the Static File buildpack for your application when you deploy, create an empty file named Staticfile in your top-level website directory. Now you can create an index.html file that will become your entry point into the website.

<head><title>My Page</title></head>
<body><h1>Hello World!</h1></body>

Once you have your index.html you can deploy the website to AppFog by running the following command from a terminal:

$ cf push mywebsitename -m 64M

The -m 64M tells AppFog that it should only allocate 64 MB of memory to run this website. Once it is deployed AppFog will return a URL where you can access the website in your browser:

Creating app mywebsitename in org DEMO / space Dev as mydemoaccount...

Creating route

Binding to mywebsitename...

Uploading mywebsitename...
Uploading app files from: .../mysite
Uploading 333K, 11 files
Done uploading               

Starting app mywebsitename in org DEMO / space Dev as mydemoaccount...
-----> Downloaded app package (696K)
-----> Using root folder
-----> Copying project files into public/
-----> Setting up nginx

-----> Uploading droplet (4.4M)

1 of 1 instances running

App started


App mywebsitename was started using this command `sh`

Showing health and status for app mywebsitename in org DEMO / space Dev as mydemoaccount...

requested state: started
instances: 1/1
usage: 64M x 1 instances
last uploaded: Fri May 8 21:09:05 UTC 2015
stack: lucid64

     state     since                    cpu    memory        disk         details   
#0   running   2015-05-08 02:09:19 PM   0.0%   4.9M of 64M   9.5M of 1G      

Use the URL from the urls: value and place into the location bar of a web browser. In this case it is

AppFog Website in Browser