Ever considered developing a RESTful API? Ever wondered what is FRAPI and how it works? Well apart from reading the frameworks’s website, there was no real way to assess FRAPI as a RESTful API Framework — Not until recently.
In order to ease adoption and make it more accessible for people to evaluate FRAPI, we’ve put an Amazon AMI together. This AMI comes pre-installed with Linux Lucid Lynx (Ubuntu 10.04 LTS), NGINX as the webserver, Memcached — (And no, port 11211 isn’t opened to the public), PHP5-FPM, APC and obviously FRAPI.
If you’d like to give this public AMI a spin, just go to Amazon’s instance management section, click on “Launch Instance, go to community AMIs, and search for : “ami-0adf2f63″ . Once you found it, click on “Select” (And make sure to select Port HTTP (80) when asked about which ports to open).
You can go directly to the AMI’s host name in a browser and you will get FRAPI’s default invalid action error, or you can follow these steps to customise it a bit more.
Now that you see your new shiny FRAPI-AMI instance running in your management console, you have a few options:
First option is: Find the “Public DNS” and the “Public IP Address” of the instance you just launched and point your domain-name’s DNS to the IP you found — Your domains could be: api.mydomain.com and admin.api.mydomain.com
Second Option is: If you do not currently hold a domain name for your API, edit your /etc/hosts file (Or the equivalent in your OS) to have an entry that points to the IP of your instance
10.0.0.1 api.mydomain.com admin.api.mydomain.com.
Once you are done with either Option 1 or Option 2, you’ll need to connect to your instance over SSH (ssh ubuntu@hostname-of-the-instance -i your-amazon-cert.pem). Upon connection, you’ll be greeted with a welcome screen giving you some information about FRAPI and the server’s software :
Once you are connected, make sure to “sudo su” and then edit the files that are in /home/ubuntu/sites/. The only thing you have to modify in those files are the “server_name” details. Put either your domain name or your made up domain name that is setup in your /etc/hosts file. The end result should be an admin file with something that contains something along the lines of
and an api configuration file that contains
Don’t give up, you are nearly there, now you have to run : “/etc/init.d/nginx restart && /etc/init.d/php5-fpm restart” and you are done.
If you go to the api.mydomain.com in your browser you should now see FRAPI’s default invalid action XML error. If you go to admin.api.mydomain.com you should be able to login with the username “admin” and password “password” — Hint: You should go to the “configurations -> users” section and modify that password.
SSH into your instance, and go to /home/ubuntu/development/custom/Actions, you will see all your API Controllers there and you can follow the steps here http://wiki.github.com/frapi/frapi/creating-actions (In our case, the generated files go into /home/ubuntu/development/custom/Actions)
We like to blog about things we're passionate about. We love PHP, MySQL, CouchDB, Linux, Apache - web development standards. We also like writing about building web apps and working with web technology.
You can email us on firstname.lastname@example.org