Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

[Solved] WSGI with Python3 for Django

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
7 posts • Page 1 of 1
neyder
Posts: 6
Joined: Fri Apr 29, 2016 4:39 am

[Solved] WSGI with Python3 for Django
  • Quote

Post by neyder » Tue Feb 26, 2019 4:35 pm

Hi i was needing to use a django app inside a client, so i worked this beacuse official doc and files doesn't work.

This is a first commit, but works swiftly.

This files are meant to enable WSGI support on a Debian or Ubuntu.

Install wsgi apache module

Code: Select all

sudo apt-get install libapache2-mod-wsgi-py3
a2enmod wsgi
Download wsgi template

Code: Select all

cd /usr/local/vesta/data/templates/web
wget https://gitlab.com/neyder/vestacp-wsgi/-/archive/master/vestacp-wsgi-master.tar.gz \
   -O- | sudo tar xzvf - --strip-components=1
Create new package or set wsgi as apache template in the existing package
Add new user and assing him package with wsgi template
Add new domain and check the result

Hints

This is for Python3.
You should create a venv in private dir inside your web domain.
Your project should be alogside venv named as domain_name.

Code: Select all

private
├── name.domain.tld
└── venv
wsgi.py script is inside PROJECTAPP directory

Code: Select all

   private/
   └── name.domain.tld
       ├── manage.py
       └── PROJECTAPP
           └── wsgi.py
you can rename PROJECTAPP with

Code: Select all

sudo sed -i 's/PROJECTAPP/{change_this}/' conf/web/name.domain.tld.apache2.conf
sudo sed -i 's/PROJECTAPP/{change_this}/' conf/web/name.domain.tld.apache2.ssl.conf
this was tested using a django project.

If you want to help this is the repo :

https://gitlab.com/neyder/vestacp-wsgi
Top

realjumy
Posts: 50
Joined: Sun Jul 06, 2014 12:51 pm

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by realjumy » Fri Mar 01, 2019 6:02 pm

This is fantastic. I'm going to try to figure out how to do the same with RHEL / Centos.

So far:

Code: Select all

yum install python26 uwsgi uwsgi-plugin-python36
Then the template that you provided doesn't work in RHEL / Centos. I tried using one that I found after a bit of Googling (https://itproffi.ru/zapusk-proektov-django-v-vestacp/) but with that, I always get the same message: "Error: httpd restart failed". I also think there's an error (although it is probably not the cause of the error) in the wsgi.sh, as it is trying to add the .ru domain to the condition in:

Code: Select all

RewriteCond %{HTTP_HOST} ^www.$2\.ru\$ [NC]
Top

realjumy
Posts: 50
Joined: Sun Jul 06, 2014 12:51 pm

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by realjumy » Mon Mar 04, 2019 12:12 am

I think I will never know how to do it, since I'm not using Centos anymore... :/
Top

neyder
Posts: 6
Joined: Fri Apr 29, 2016 4:39 am

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by neyder » Fri Mar 22, 2019 5:14 pm

realjumy wrote: ↑
Mon Mar 04, 2019 12:12 am
I think I will never know how to do it, since I'm not using Centos anymore... :/
So you moved on to Debian/ubuntu side?
realjumy wrote: ↑
Fri Mar 01, 2019 6:02 pm
the wsgi.sh, as it is trying to add the .ru domain to the condition in:

Code: Select all

RewriteCond %{HTTP_HOST} ^www.$2\.ru\$ [NC]
Yeah, that's because it is only for a specific domain, not using VESTA variables and so, take a look at my code.

Should try Vesta on RHEL/CEntOS but not having time this days.
Top

realjumy
Posts: 50
Joined: Sun Jul 06, 2014 12:51 pm

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by realjumy » Sun Mar 24, 2019 8:33 pm

neyder wrote: ↑
Fri Mar 22, 2019 5:14 pm
realjumy wrote: ↑
Mon Mar 04, 2019 12:12 am
I think I will never know how to do it, since I'm not using Centos anymore... :/
So you moved on to Debian/ubuntu side?
realjumy wrote: ↑
Fri Mar 01, 2019 6:02 pm
the wsgi.sh, as it is trying to add the .ru domain to the condition in:

Code: Select all

RewriteCond %{HTTP_HOST} ^www.$2\.ru\$ [NC]
Yeah, that's because it is only for a specific domain, not using VESTA variables and so, take a look at my code.

Should try Vesta on RHEL/CEntOS but not having time this days.
I found Centos easier and more robust for servers, but for a series of reasons I stopped using it. I might return to use Centos very soon, I will try again then.
Top

realjumy
Posts: 50
Joined: Sun Jul 06, 2014 12:51 pm

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by realjumy » Fri Apr 19, 2019 4:51 pm

I'm still having problems with this.

Trying to set up a brand new server, I always get the same error when adding a domain: "Error: apache2 restart failed".

I really want to set up a Django site in my server, but I can't manage to make it work... :/ What a pity.
Top

neyder
Posts: 6
Joined: Fri Apr 29, 2016 4:39 am

Re: [Solved] WSGI with Python3 for Django
  • Quote

Post by neyder » Sat Oct 12, 2019 2:19 am

There is a new commit on this:

For more info:
https://gitlab.com/neyder/vestacp-wsgi/merge_requests/1
Top


Post Reply
  • Print view

7 posts • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password