# Fortran.io An MVC web stack written in Fortran 90 (so you get arrays, and it's not punchcards) Major credit due to: - authors of FLIBS (Arjen Markus and Michael Baudin) - Ricolindo Carino and Arjen Markus's Fortran FastCGI program and tutorial - in many ways this started as an update to this tutorial : http://flibs.sourceforge.net/fortran-fastcgi-nginx.html - String utils by George Benthian http://www.gbenthien.net/strings/index.html - Philip Branning for improving and documenting the install process, especially the SQLite parts - divVerent for fixing a server crash bug due to URL params and SQL ## Create an Ubuntu server Log in and install dependencies ``` # update Ubuntu sudo apt-get update sudo apt-get upgrade # create the user and home directory adduser fortran --gecos "" usermod -a -G sudo fortran # switch to new user su fortran cd ~ # install git and clone the repo sudo apt-get install -y git git clone https://github.com/mapmeld/fortran-machine.git # Install dependencies cd fortran-machine sudo ./install_deps_ubu.sh ``` Go to your IP address - you should see the "Welcome to nginx!" page Change the location in /etc/nginx/sites-available/default : ``` server_name 101.101.101.101; <- your IP address location / { root /home/fortran/fortran-machine; index index.html; } ``` Restart nginx to make these settings for real: ``` sudo service nginx restart ``` You should now see the test page on your IP address. ``` Test doc ``` ## Use Fortran CGI script Let's go from test page to Fortran script: ``` # compile the test server make ``` Now change nginx config /etc/nginx/sites-available/default ``` location / { root /home/fortran/fortran-machine; fastcgi_pass 127.0.0.1:9000; fastcgi_index index.html; include fastcgi_params; } ``` Then run ```sudo service nginx restart``` ``` # spawn the server spawn-fcgi -a 127.0.0.1 -p 9000 ./fortran_fcgi ``` ### Restarting the script After changing the source code, you can recompile and restart your server with: ``` ./restart.sh ``` ## Add a static folder Add to nginx config /etc/nginx/sites-available/default ``` location /static { root /home/fortran/fortran-machine; } ``` And restart nginx ``` sudo service nginx restart ``` ## Fortran controller The controller is written in Fortran in the fortran_fcgi.f90 file: ```fortran case ('/') ! most pages look like this templatefile = 'template/index.jade' call jadefile(templatefile, unitNo) case ('/search') write(unitNo,AFORMAT) '