Deploying Your App
This page explains the most common ways to deploy your app to a remote server.
Basics
Every THT app includes a standalone copy of the THT runtime.
This means if your server has PHP installed, you can simply copy your app to the remote server and it will usually work without any changes.
However, you will need to install THT on the remote server if you need to run the tht
command.
Copying Files
To copy files to your remote server, here are a couple of apps that you can use:
Document Root
Make sure your webserver is pointing to your app’s public
directory as the Document Root.
If you are using a shared hosting provider, this is usually set up via their control panel.
In Dreamhost, it looks something like this:
Troubleshooting
If you run into any issues, you can run tht fix
on the remote server.
This will safely update your app and fix some common problems.
$ cd path/to/myApp $ tht fix
This will:
- Clear the app cache
- Set necessary file permissions
Manual Troubleshooting
If this does not fix an issue, double-check the following:
- Your webserver Document Root is set to your
public
folder. - Create a simple
test.html
inpublic
and see if it is served correctly. - Permissions are set on your
app
directory so the webserver has read/write access. (see below)
Permissions
Permissions are a common source of errors during deployment.
The webserver’s user account will need these permissions:
- read access to your app directory
- write access to your app’s
data
directory
If tht fix
does not work, you may need to update permissions manually.
For example, on Linux, you might run this command to change ownership of the myApp
directory to the user www-data
(a common user account for Apache):
sudo chown -R www-data myApp
Webserver Configuration
Shared Hosts
If you are deploying to a shared host, it is probably running Apache with .htaccess
enabled, so you shouldn’t need to modify anything.
Apache
When you create an app, THT adds an .htaccess
file to your public
folder.
This tells Apache to route all requests to front.php
if the visitor is requests a URL that doesn’t have a corresponding file. In other words, images, etc. will be served as normal, but everything else will be handled by this php file.
Make sure Apache is set up to use .htaccess files. Otherwise, you can move the THT routing directives into the main Apache .conf
file.
These modules should also be turned on in the Apache config:
LoadModule deflate_module LoadModule rewrite_module
Nginx
Coming Soon.
It shouldn’t be too difficult to translate the Apache directives to Nginx.
If you set this up, please let us know what worked. :)
FastCGI
Coming Soon.
If you set this up, please let us know what worked. :)
Deploying Updates
When updating your app on a remote server, keep in mind that there are some files that you usualy don’t want to overwrite.
/data
folder/config/app.local.jcon
(In future updates, we will try to make this process a little easier.)