Maybe try this:
I think that’s the one he tried already…
@realjumy I am very sorry, I ran out of ideas and don’t really have the time (or app/use case) to dig into and try out…
Yes, that’s one one the different approaches I tried. Maybe because how HestiaCP is designed there’s something that’s is causing the error with the duplicated names. I will try using an alternative to WSGI, maybe that way it works.
As I said, I have particular interest in making this work because I find PHP very limited and insecure. If make it work I think it’s just natural to share the way to do it with the community.
Just a note: Python is much older than PHP yet still php became the de facto backend platform in the early 2000s and this didn’t hapend because it was limited or insecure.
The recent hype python enjoyed in the recent years is mostly related to usage in data science fields, but on the web front not much has improved in the last 2 decades, as even this one month old thread shows; setting apache to serve multiple python apps shouldn’t take this long, even for a beginner.
This being said, extending support for other backends like python,node,deno or lxc/docker is something we will have to improve in the future
How relaxed/random are the content types in PHP is one of the multiple examples of how insecure it is. PHP was a good option years ago, but I don’t see many reasons to stick to it when there are many other alternatives (not just Django).
I have installed and running several websites using Django. The difficulties here are related to make it run with HestiaCP.
This is an interesting debate, although I would like not to divert too much from the main topic of the original post.
I have skimmed trough the thread and the problem is definitely not related to Hestia but with the Apache vhost config (maybe even python venv or wsgi entrypoint).
After all Hestia is just copying the template to apache and resolves the placeholder values if finds there (like %domain% %user% etc). When creating the template you have complete freedom to add anything you want there.
So if you have a standalone Apache config able to handle multiple wsgi apps it should not take more than a couple minutes to convert it to a template.
PS OT: Relaxed types are common to most dynamically typed lang like py,js,perl,ruby and that does not make them insecure. If you prefer more strict types then C#, golang might be worth looking into. (Last comment on this subj)
OK, after much frustration and suffering, I decided to ditch the idea of using WSGI. I decided to change to Gunicorn… And it simply works.
Disclaimer:
- I am not responsible for any problem derived from its installation or use. This piece is software is provided as it is.
- These templates are intended for HestiaCP 1.1.1 running on Ubuntu 18.04
- Read the instructions in the repository carefully.
- Further configuration is needed after the installation of the Django App.
- Not suitable for the faint of hearth, as it can break your server.
- At the moment it is intended for 1 single Django installation in the entire server (not just per domain or user, I mean the entire server)
- If you are giving it a try, you better know what you’re doing.
CAUTION, THERE MIGHT BE DRAGONS:
Feel free to test it and contribute.
OK, new release, in case someone wants to test it:
I also noticed something while I was “hunting dragons” in the code. If you check the lines 42-51 in Django_app.sh
you will notice that there are some lines commented out. This is because for some strange reason, the if
that adds content to the file in case it exists (which by the way, I know that the piece of code that I was attempting to add is wrong) is being executed after the next if
. This might be (or might not be) the cause why WSGI approach of these templates is not working.
Is anyone able to try these templates, please? You should be able to finally see this error when you access to your domain:
But it is solved just adding your domain and IP to the section ALLOWED_HOST
in the Django app configuration and then restarting gunicorn with systemctl restart gunicorn
.
It’s also necessary to follow this order to activate the templates (applying after each change):
- Select
Django_proxy_pass
as NGINX template - Select
Socket
as Backend Template PHP-FPM (not sure if this is necessary) - Select
Django
as Apache2 template.
In the next iteration I will sort the limitation of only 1 Django app per server.
awesome, thanks for sharing! I am sure that will be helpful for other searching around that topic!
OK, as promised:
Changelog for v1.0:
- CodeRedCMS added
- The limitation to the number of simultaneous installations is now (probably) fixed
Remember that this is for people that know what they are doing. There is still setup to be done from console after installtion, which includes setting up the database, adding users, disabling debug, changing the environment to production, and so on.
Feel free to give it a try.
I think this weekend I will try to add more templates for other stuff, such as Ghost CMS, but it will depend on how fast I do with my other commitments.
By the way… CodeRedCMS is blazing fast, it’s worth a try.
Hello, although I’ve been working with PHP for years I’m new to Python and Django.I have installed the templates as it said in the Readme.md of Github but when I try to access the web I get an error 500.
Is there anything else I should do? I’m working with Debian 10 and Hestia 1.4.12
The server log in /home/user/web/domain.tld/logs/ will give you all the information you need to anaylze your issue.
Hello, the domain.tld.es.error.log file is blank. What more tests can I do?
Hi.
I gave up with having Django apps working in Hestia because some problem back then was making the process impossible. I don’t remember which problem was, and I wish I had the time now for checking if the problem has been patched and if it’s feasible to use Django with Hestia using templates. Eventually I made it work with the files in the repo that you have, but then some change broke it. Check the previous commits, maybe you can find what made it work.
There is however a workaround, and is using Docker to containerise the Django app and adapting the templates from my Node templates:
Is not perfect and there is much to improve and fix, but it can give you a good starting point.
Sorry if I can’t be of more help, but sometimes life gets too complicated and we lack the time that we wish we had for our side projects.
Ok, no problem. For now I don’t have any serious project in Django so I’ll keep investigating, but if I don’t manage to configure it nothing happens.
Hi, the other day I saw this tutorial on how to put Django on Hestia. It is in Spanish but I think it can be useful for everyone. Just translate it with Chrome and that’s it.
https://help.clouding.io/hc/es/articles/4408217149458-C%C3%B3mo-instalar-Django-y-Gunicorn-en-HestiaCP
I just wanted to mention that I struggled with this quite a bit, but after finding this thread (and some other resources) I took the Neyder Achahuanco Apaza / vestacp-wsgi · GitLab repo and forked it to github. After some work I now have a working setup. Please see here: GitHub - jonlachmann/hestiacp-wsgi