I am follow this http://pradyumnajoshi.wordpress.com/2009/06/09/setting-up-mod_wsgi-for-apache-and-django-on-windows/
I am using python2.6, Apache2.2, Django1.3 and mod_wsgi>3 on windows xp. now I have installed Apache correctly it is running well. and I have add the following line in httpd.conf file:-
LoadModule wsgi_module modules/mod_wsgi.so
Now i restart my Apache server It's running well. But when I have add the following lines in httpd.conf:-
WSGIScriptAlias /wsgi “C:/wsgi_app/wsgi_handler.py”
<Directory “C:/wsgi_app”>
AllowOverride None
Options None
Order deny,allow
Allow from all
</Directory>
Then restart my Apache server it give error on the prompt "The request operation has failed"
please help me I am new in python.
Thank You.
Whenever debugging Apache, the first place to check is the error and access logs. I've never used apache with Windows, but if you find logs, you'll get a much more descriptive error message.
FYI, I believe it is normally recommended to make the wsgi_handler use a .wsgi extension (though I think this is probably because it is normally named django).
make sure you have wsgi_handler.py file in the directory C:/wsgi_app.
problem may be the symbol with which you are quoting.
replace “C:/wsgi_app/wsgi_handler.py” with "C:/wsgi_app/wsgi_handler.py" and “C:/wsgi_app” with "C:/wsgi_app".
Related
Resources:
LINUX UBUNTU 20.04
Apache/2.4.41 (Ubuntu) Server Port 443
Certbot verified HTTPS.
Latest version of Modoboa installed by the tutorial of mod_wsgi (sudo apt-get install libapache2-mod-wsgi-py3)
in HTTP the sites loads of Modoboa and is accessible (so this means python3 installation all good everything working fine in Apache2).
Problem:
in HTTPS it returns:
403
Forbidden
You don't have permission to access this resource.
(when I try to access it as httpS://mail.domain.nl, but without S, so http://mail.domain.nl is accessible)
Things I tried to solve the problem so far:
In /srv, I have executed $ sudo chmod -R 777 modoboa.
But this error is still there, as in it is only through HTTP accessible but not through HTTPS URL.
Does anyone know why? Since I cannot login in HTTP because of security reasons, I need to use HTTPS for the mail server.
The conf file is like this: :D
<VirtualHost *:80>
ServerName mail.domain.nl
ServerAlias www.mail.domain.nl
DocumentRoot /srv/modoboa/instance/
Alias /media/ /srv/modoboa/instance/media/
<Directory /srv/modoboa/instance/media>
Order deny,allow
Allow from all
Require all granted
</Directory>
Alias /sitestatic/ /srv/modoboa/instance/sitestatic/
<Directory /srv/modoboa/instance/sitestatic>
Order deny,allow
Allow from all
Require all granted
</Directory>
WSGIScriptAlias / /srv/modoboa/instance/instance/wsgi.py
<Directory "/srv/modoboa/instance">
Order allow,deny
Allow from all
Require all granted
</Directory>
WSGIDaemonProcess mail.domain.nl python-path=/srv/modoboa/instance/:/srv/modoboa/env/lib/python3.8/site-packages
WSGIProcessGroup mail.domain.nl
# Pass Authorization header to enable API usage:
WSGIPassAuthorization On
</VirtualHost>
Oh and domain.nl is a placeholder for publishing this document, in reality it has the domain which I use the webserver on :D.
Some emotional background story :D:D:D:D:D:
I am new to Linux, I have always been a fanboy of Windows because I didn't understand Linux (you know hate the unknown).
Since few months at my Student Association, there is one guy a diehard Linux fan and he pushed us to use Linux for our website. Since then I found it actually very comfortable, since it was also way more cheaper than Windows server I decided to use it. I have multiple Wordpress websites hosted at APACHE2 in UBUNTU 20.04, I would also like to have my own mail server and MODOBOA is verrrry beautiful upon installing, everything worked fine in NGINX but I tried to host it on APACHE2 (since I turned off apache2 while it was installing to see that it works in NGINX), after executing that sudo command to install mod_wsgi the site is accessible at HTTP but not in HTTPS.
Seems like you only have a vhost listening on port 80. You need to create another vhost and have it listen on 443 which is HTTPS.
I am running XAMPP control panel 3.2.2 in order to have Apache and MySQL hosted, and I have correctly imported PyMySQL and cgi, which I have verified to be installed.
However, when I try and run a test script to make sure that everything is working together, it prints part of the program correctly, but not the other stuff. Images attached.
How do I fix this? I have tried Googling solutions but nothing to solve it has come up, and the python.exe location is definitely correct.
Modules verified
Program displayed
Test program
XAMPP running
Alright I fixed it, here is how I did it for anyone looking at this question:
Open the Apache httpd.conf configuration file from XAMPP
Locate the AddHandler block of code using CTRL-F
Where it says
AddHandler cgi-script .cgi .pl .asp
Add .py to the end of the list so it instead becomes:
AddHandler cgi-script .cgi .pl .asp .py
Save the file with .py appended onto it
Restart XAMPP and then launch the file from a web browser, where it should be working
I have 2 python env in my server. One path is /usr/bin and other one is the anaconda path as shown below. I am getting Permission denied error when I try executing a basic Python script on my Apache server. The python interpreter path in my .py file is as follows
#!/home/cloudera/anaconda3/bin
When this path is used, the apache server shows the error as shown below:
(13)Permission denied: exec of '/var/www/cgi-bin/abc.py' failed, referer:
When my python interpreter path in .py is changed to i.e #!/usr/bin it works well.
The problem is I have installed all my packages in /home/cloudera/anaconda3/bin
I tried setting this path to be accessible to execute in apache server by adding the below line of code in /etc/httpd/conf/httpd.conf file as follows
<Directory "/home/cloudera/anaconda3/bin/">
AllowOverride None
Options ExecCGI
AddHandler cgi-script .py
#None
Order allow,deny
Allow from all
</Directory>
I still get Permission Denied. It still does not work. I am new to cgi, any help would be really grateful. Thanks in advance.
Admittedly I've completely missed the fact that the interpret was specified as directory and the actual binary file as pointed out by Jean-François Fabre. That would indeed cause the same error. But since the OP fixed that and still got the same error, I am undeleting the answer extended as requested.
Also come to think of it, it may be more of a Server Fault question as it would appear.
This error (13: EACCES) is raised by and propagated from the OS.
HTTPd servers usually employ privilege separation and once bound to a reserved port drop their EUID to an unprivileged user. Usually a dedicate one or nobody (on my system it would be user apache, group apache). You should be able to find these in your httpd.conf under User and Group resp.
Make sure this user has access and can execute the binary you're calling.
Give you've fixed the interpreted (and the file would execute on its own). Go find your httpd.conf file (I think different distros may package it differently, on mine it would reside here: /etc/httpd/httpd.conf). You will find User and Group entries there. You must be able to access and execute the script (incl. the interpreter) as this user, because that's how Apache will try to call it. I.e. this user (or group) must be able to access this file (along the complete path) and execute it. If for instance /home/cloudera/ us restricted to (0700: rwx------) and owned by user other then the one listed int your httpd.conf (very likely), OS would prevent your Apache user to access and execute the file resulting in EACCES error you are seeing. The easiest might be to become that user and see how far your access goes, but you'd need to temporarily tweak few bits for that as the Apache account likely is locked and has not shell set (or rather /bin/false as shell).
One more thing, but I hope it's not as obvious as that. The corresponding user must have execute permission on the script itself.
I am currently attempting to set up apache on my centos system with django. So far I have followed all of the instructions on the docs and everything works well.
(https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/modwsgi/)
Unfortunately when I try to replace the WSGIPythonPath command with
WSGIDaemonProcess example.com python-> path=/path/to/mysite.com:/path/to/venv/lib/python2.7/site-packages
WSGIProcessGroup example.com
as reccomended, I run into a road block. I am not using a virtual-environment for this project. I tried not having anything after the : and I also tried linking to the python2.7 site packages on my machine, both resulted in me being told there was an error on the line with daemon process. When I revert back to WSGIPythonPath my apache runs fine.
What should I do?
I installed python27 , and also the latest version of apache.
in order to run a simple program by refering link
also edited the httpd.conf file also
but i accessed the folder localhost/cgi-bin displays the error
"Forbiden you don't have the permission to access this folder"
Changed the folder permission from properties of folder.
any other way to solve the problem.
So you have a cgi script named hello.py containing the code from the tutorial and installed in the cgi-bin directory as configured in the httpd.conf file?
If you browse to http://localhost/cgi-bin/ you will most likely see a HTTP 403 Forbidden response with text along the lines of:
You don't have permission to access /cgi-bin/ on this server.
You need to execute the actual cgi script, not the containing directory, so try browsing to http://localhost/cgi-bin/hello.py.
If that doesn't work, what changes did you make to httpd.conf? Have you installed the cgi script in the directory specified in the ScriptAlias /cgi-bin/ directive?