I’m working on a project that combines PHP and Python. The Python part acts like a mini-server, listening on port 8765. My PHP code talks to it using cURL requests to localhost.
Here’s a quick look at my Python setup:
class RequestHandler(BaseHandler):
def handle_get(self):
if self.request_path == '/query':
self.send_ok()
# More code here
self.write_response(result)
It’s working fine on our dev machines. Now I need to get it running in production. I’m thinking about:
- Changing my code to use FastCGI
- Getting a budget-friendly VPS
- Setting up Apache to manage both PHP and Python with FastCGI
The Python part should stay private and keep running. We’re expecting about 800 requests daily to start.
Is this a good plan? Can I use a regular shared host instead of a VPS? Any tips for keeping it simple, reliable, and cheap? I’m open to suggestions for both the tech setup and hosting options.
Thanks for any advice!
For your scenario, I’d recommend considering a Platform as a Service (PaaS) solution like Heroku or DigitalOcean App Platform. These platforms can handle both PHP and Python applications seamlessly, eliminating the need for complex server configurations. They offer automatic scaling, easy deployment, and reasonable pricing for low-traffic applications.
You can keep your current setup with minimal changes by deploying the Python backend as a separate app, allowing the PHP frontend to communicate with it via HTTP requests. This approach provides a good balance of simplicity, reliability, and cost-effectiveness, especially given your expected traffic volume. Additionally, it offers a straightforward path for scaling if your project grows in the future.
hm, interesting project! have u looked into using a microservices approach? you could deploy ur python backend as a small service on something like AWS Lambda or Google Cloud Functions. then ur PHP frontend can just make API calls to it. might be simpler and cheaper than a full VPS setup. what do u think about that idea?
hey, have u considered using docker? it’s pretty neat. u can containerize ur python backend and php frontend and use docker-compose to run them together. much simpler than wrestling with fastcgi configs. just my two cents!