Deploying Formulize to a Website

If you’re trying to update an existing Formulize system, check out the Updating Formulize page.

What you’ll need

  • a web server with PHP and MariaDB (or MySQL) installed and ready to go
  • a database created in MariaDB (or MySQL)
  • a database user created, with full rights to the database in MariaDB (or MySQL)

Quick Start

  1. Get the Formulize files onto your web server. We recommend using git. See below, and make sure you block web access to the .git folder. You could also download the latest release from GitHub, and transfer the files to your web server however you see fit.

  2. Put the files in the folder where you want Formulize to exist, ie:
    • if you want Formulize to exist at https://www.mysite.com then put the files in the web root.
    • if you want Formulize to be in a subfolder like https://www.mysite.com/formulize then put the files in the /formulize folder, inside the web root.
  3. Make sure the folders that need to be writable are writable by the web server user.

  4. Open a web browser and go to the location where you put Formulize. The installer will appear. Follow the steps for using the installer

Getting the files onto your server with git

We recommend cloning the GitHub repository so that it’s easy to track any changes, and easy to update Formulize in the future.

# ssh to your server
# then go to the folder where you want to install Formulize
cd /path/where/you/want/formulize

# make sure the folder is empty
# delete any contents if necessary

# clone Formulize from GitHub into this folder
# don't forget the dot at the end!
git clone https://github.com/jegelstaff/formulize.git .

# make your own branch to track changes
git checkout -b my-formulize-branch

Important: block web access to the .git folder

Do this before you run the installer, and before your site is public.

Cloning puts a .git folder in the root of your website. It holds a complete copy of your site’s files and their history, including anything you commit to your branch later. If it can be reached through a web browser, anyone can download it.

On an Apache server, add this line to the .htaccess file in the root of your website. Create the file if it isn’t there.

RedirectMatch 404 /\.git

On an nginx server, add this inside the server block for your site, then reload nginx:

location ~ /\.git {
    return 404;
}

To check that it worked, go to https://www.mysite.com/.git/config in a web browser (use your own site’s address). You should see a “Not Found” page. If the browser shows or downloads a file instead, the .git folder is still accessible, so check the setting above before going any further.

Next steps

Regardless of how you get the files on your server, the next steps are the same:

If you’re using git, commit changes regularly to your branch

As you use Formulize, some configuration changes are stored in files on the server. These files will show up in git as changes.

Periodically, you should review the changes, and commit them to your branch. It’s generally a good idea to automate this to run nightly, using cron and a bash script. That way, you have a regular history of changes.

For details of how to update your Formulize site using git, check out the Updating Formulize page.

If you’re not using git, consider deleting some folders and files

Some of the folders and files are not necessary for the actual operation of Formulize on a live website.

If you are using git to manage the files, it’s best not to remove these, although you could. It would create merge challenges later if you do remove them.

However, if you’re not using git, then these folders are basically taking up extra space and serving no purpose, so you might as well delete them:

  • /.github/
  • /.sauce/
  • /.vscode/
  • /docker/
  • /docs/
  • /install/ (only delete after completing the installation!)
  • /tests/
  • /trust/ (do not delete if you used this as your actual trust path!)
  • .editorconfig
  • .gitignore
  • docker-compose.yml