Deploying Django with apache using wsgi.py

2024/11/16 3:49:16

I'm trying to deploy a Django project on a linode server that has apache, some other django projects and a php project on it. Also my project is in a virualenv and the other django projects aren't.

My Django project apache file is

WSGIPythonPath /home/nccylli/www/ylli_transactions:/root/Envs/ylli-transactions/lib/python2.6/site-packages
WSGISocketPrefix /var/run/apache2/wsgi
WSGIScriptAlias / /home/nccylli/www/ylli_transactions/ylli_transactions/wsgi.py
DocumentRoot /home/nccylli/www/ylli_transactions/static<Directory /home/nccylli/www/ylli_transactions>
<Files wsgi.py>Order allow,denyAllow from all
</Files>
</Directory>Alias  /static /home/nccylli/www/ylli_transactions/static
Alias  /media /home/nccylli/www/ylli_transactions/mediaErrorLog /home/nccylli/www/ylli_transactions/logs/error.log
CustomLog /home/nccylli/www/ylli_transactions/logs/access.log combined<VirtualHost *:80>ServerName my-domain.comServerAlias www.my-domain.comServerAdmin my-email</VirtualHost>

The PHP project apache file

<VirtualHost *:80>ServerName php-prject-domainServerAlias www.php-prject-domainDocumentRoot /home/nccylli/www/php-prject/CustomLog     /var/log/apache2/php-prject-access.log combinedErrorLog      /var/log/apache2/php-prject-error.log<IfModule mpm_itk_module>AssignUserId nccylli nccylli</IfModule>
</VirtualHost>

Now I'm running into two errors
in the django project error log

(13)Permission denied: access to / denied
(13)Permission denied: mod_wsgi (pid=9780, process='', application='my-domain.com|'): Call to fopen() failed for '/home/nccylli/www/ylli_transactions/ylli_transactions/wsgi.py'.

and in the php project error log

mod_wsgi (pid=26782): Target WSGI script '/home/nccylli/www/ylli_transactions/ylli_transactions/wsgi.py' cannot be loaded as Python module.
mod_wsgi (pid=26782): Exception occurred processing WSGI script '/home/nccylli/www/ylli_transactions/ylli_transactions/wsgi.py'.
Traceback (most recent call last):File "/home/nccylli/www/ylli_transactions/ylli_transactions/wsgi.py", line 13, in <module>from django.core.wsgi import get_wsgi_application
ImportError: No module named wsgi

Any thoughts?

Answer

Try using following code:

<Directory /home/nccylli/www/ylli_transactions/ylli_transactions>
<Files wsgi.py>Order allow,denyAllow from all
</Files>
</Directory>
https://en.xdnf.cn/q/118973.html

Related Q&A

Building a decision tree using user inputs for ordering goods

I am trying to program a decision tree to allow customers to order goods based on their input. So far, I have devised a nested if-elif conditional structure to decide if customer want to order what or…

How to de-serialize the spark data frame into another data frame [duplicate]

This question already has answers here:Explode array data into rows in spark [duplicate](3 answers)Closed 4 years ago.I am trying to de-serialize the the spark data frame into another data frame as exp…

How to pull specific key from this nested dictionary?

{"newData": [{"env1": [{"sins": [{"host": "test.com","deployTime": "2015-07-23 11:54 AM",…}],"name": “hello”}, {"…

Dropping cell if it is NaN in a Dataframe in python

I have a dataframe like this.Project 4 Project1 Project2 Project3 0 NaN laptio AB NaN 1 NaN windows ten NaN 0 one NaN NaN 1 …

How can I iterate through excel files sheets and insert formula in Python?

I get this error TypeError: Workbook object is not subscriptablewhen i run this code import xlsxwriter from openpyxl import load_workbookin_folder = rxxx #Input folder out_folder = rxxx #Output folde…

How to bind all frame widgets to Enter event

I the following code I want to bind all frame1 items to <Enter> Event, but it does not work. I mean canvas.focus_set() does not take effect. How can I solve my problem?for w in frame1.winfo_chil…

Typeerror takes no arguments [closed]

Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers.This question was caused by a typo or a problem that can no longer be reproduced. While similar q…

Unable to access element within page

Form Screenshot HTML Inspect Code screenshotIm trying to access an element within a page. Cannot give out the exact page link owing to security concerns. Im writing a python program that uses selenium …

How to wtite Erlang B and Erlang C formulas in Python [closed]

Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.Questions asking us to recommend or find a tool, library or favorite off-site resource are off-topic…

Pip is not recognizing the install command (Windows 7, Python 3.3) [duplicate]

This question already has answers here:python3 --version shows "NameError: name python3 is not defined" [duplicate](2 answers)Closed 6 years ago.I am trying to install Python programs using P…