Home » Php » php – nginx.conf for a restful api

php – nginx.conf for a restful api

Posted by: admin July 12, 2020 Leave a comment


I’m currently developing a RESTful api as a bridge between my ios/web application and their shared database, and content.

I found my way to implement RESTful api in PHP on this blog.

I started my development on my OVH Apache-based server. Unfortunately, they didn’t provide oauth support on web hosting services and there is no way to install it. OVH told me I needed a dedicated server or a VPS server for this.

Now, I’m going to work on dotCloud. It’s a great alternative, I think, but their servers (seemingly Amazon EC2’s ones), are nginx-based.
This would be the first time I’ve used a nginx server and I need your help for “translating” this .htaccess to a nginx.conf file.

Before asking for your help, I tried to find a nginx.conf file for this but no one worked.
When I pushed them to my dotcloud app, the http service of my app crashed and dotcloud cli said :

14:55:44 [www.0] WARNING: The service crashed at startup or is listening to the wrong port. It failed to respond on port “http” (80) within 30 seconds. Please check the application logs.

Thanks for any help in advance 🙂

How to&Answers:

Thanks to this htaccess to nginx.conf converter, and some tricks and tests I’ve made, here is the corresponding nginx.conf file.

I hope it will help people. 😉

EDIT: link to my configuration is dead, but the converter is still available. As long as you have a valid Apache configuration you’re good to go.