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.
- Free Pascal >= 3.0
- Web Server (Apache, nginx)
- Fano Web Framework
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.
$ 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
Run
$ ./tools/config.setup.sh
Run
$ ./build.sh
By default, it will output binary executable in bin
directory.
To build for different environment, set BUILD_TYPE
environment variable.
$ 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_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 example Fano FastCGI application
$ ./bin/app.cgi
By default it will listen on 127.0.0.1:20477
.
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.
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.
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.
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
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
.
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.