Skip to content

fanoframework/fano-fastcgi

 
 

Repository files navigation

FastCGI Web Application with Fano Framework

FastCGI Web application skeleton using Fano Framework, Pascal web application framework. It listens on TCP socket.

This project is generated using Fano CLI command line tools to help scaffolding web application using Fano Framework.

Requirement

Free Pascal installation

Make sure Free Pascal is installed. Run

$ fpc -i

If you see something like Free Pascal Compiler version 3.0.4, you are good to go.

Clone this repository

$ git clone git@github.com:fanofamework/fano-fastcgi.git --recursive

--recursive is needed so git also pull Fano repository.

If you are missing --recursive when you clone, you may find that vendor/fano directory is empty. In this case run

$ git submodule update --init

Setup required configuration

Run

$ ./tools/config.setup.sh

Build application

Run

$ ./build.sh

By default, it will output binary executable in bin directory.

To build for different environment, set BUILD_TYPE environment variable.

Build for production environment

$ BUILD_TYPE=prod ./build.sh

Build process will use compiler configuration defined in vendor/fano/fano.cfg, build.cfg and build.prod.cfg. By default, build.prod.cfg contains some compiler switches that will aggressively optimize executable both in speed and size.

Build for development environment

$ BUILD_TYPE=dev ./build.sh

Build process will use compiler configuration defined in vendor/fano/fano.cfg, build.cfg and build.dev.cfg.

If BUILD_TYPE environment variable is not set, production environment will be assumed.

Run

Run example Fano FastCGI application

$ ./bin/app.cgi

By default it will listen on 127.0.0.1:20477.

Run with a webserver

Setup a virtual host. Please consult documentation of web server you use.

This example project is a FastCGI web application. You may want to read Deployment as FastCGI application for more information on how to setup virtual host to deploy FastCGI web application.

Deployment

You need to deploy only executable binary and any supporting files such as HTML templates, images, css stylesheets, application config. Any pas or inc files or shell scripts is not needed in deployment machine in order application to run.

So for this repository, you will need to copy public, Templates, config and storages directories to your deployment machine. make sure that storages directory is writable by web server.

Known Issues

Issue with GNU Linker

When running build.sh script, you may encounter following warning:

/usr/bin/ld: warning: public/link.res contains output sections; did you forget -T?

This is known issue between Free Pascal and GNU Linker. See FAQ: link.res syntax error, or "did you forget -T?"

However, this warning is minor and can be ignored. It does not affect output executable.

Issue with unsynchronized compiled unit with unit source

Sometime Free Pascal can not compile your code because, for example, you deleted a unit source code (.pas) but old generated unit (.ppu, .o, .a files) still there or when you switch between git branches. Solution is to remove those files.

Run tools/clean.sh to remove all compiled binaries generated during compilation.

$ ./tools/clean.sh

Windows user

Free Pascal supports Windows as target operating system, however, this repository is not yet tested on Windows. To target Windows, in build.cfg replace compiler switch -Tlinux with -Twin64 and uncomment line #-WC to become -WC.

Lazarus user

While you can use Lazarus IDE, it is not mandatory tool. Any text editor for code editing (Atom, Visual Studio Code, Sublime, Vim etc) should suffice.

Releases

No releases published

Packages

No packages published

Languages

  • Pascal 37.3%
  • HTML 17.3%
  • Shell 14.9%
  • Batchfile 14.4%
  • PHP 6.3%
  • C++ 6.1%
  • Other 3.7%