2

I am trying to get a new webserver up and running.

php files will parse correctly but python files will not. I changed the file to +x, an this has no effect. I am not getting any errors in my logs for either nginx or uwsgi

uwsgi --socket 0.0.0.0:8001 --protocol=http --uid www-data --gid www-data --ini /var/www/html/nerd/uwsgi.ini --wsgi-file /var/www/html/nerd/nerd/wsgi.py --chdir /var/www/html/nerd/




(nerds) root@guppy:/var/www/html# cat nerd/nerd/test.py 
# test.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return [b"Hello World"] # python3

(nerds) root@guppy:/var/www/html#

(nerds) root@guppy:/var/www/html# cat nerd/uwsgi.ini                 
[uwsgi]
module = wsgi:application
#module = wsgi
master = true
chdir = /var/www/html/nerd/
wsgi-file = /var/www/html/nerd/nerd/wsgi.py
uid = www-data
gid = www-data
vacuum = true
chmod-socket = 644
socket = 8001
#socket = /tmp/uwsgi.sock
plugins = python3
die-on-term = true
virtualenv = /var/www/html/nerds/
pythonpath = /var/www/html/nerds/lib/python3.5/dist-packages
pythonpath = /var/www/html/nerds/lib/python3.5
pythonpath = ./nerd
#module = django.core.handlers.wsgi:WSGIHandler()

(nerds) root@guppy:/var/www/html#

(nerds) root@guppy:/var/www/html# cat nerd/nerd/wsgi.py                     
"""
WSGI config for nerd project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""

import os

from django.core.wsgi import get_wsgi_application

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'nerd.settings')
#os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings')

application = get_wsgi_application()


def application(environ, start_response):
    start_response('200 OK', [('Content-Type', 'text/html')])
    return ["<h1 style='color:blue'>Hello There!</h1>"]

(nerds) root@guppy:/var/www/html#

(nerds) root@guppy:/var/www/html# cat /etc/nginx/sites-available/default        
upstream django {
        #server unix:///tmp/uwsgi.sock; # for a file socket
        server 127.0.0.1:8001; # for a web port socket (we'll use this first)
}


# Default server configuration
#
server {
        listen 80 default_server;
        listen [::]:80 default_server;

        root /var/www/html;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.php index.nginx-debian.html;

        server_name guppy.trade.com;

        location / {
                try_files $uri $uri/ =404;
                include     uwsgi_params;
        }

        # pass PHP scripts to FastCGI server
        #
        location ~ \.php$ {
                include snippets/fastcgi-php.conf;
        #
        #       # With php-fpm (or other unix sockets):
                fastcgi_pass unix:/var/run/php/php7.0-fpm.sock;
        #       # With php-cgi (or other tcp sockets):
        #       fastcgi_pass 127.0.0.1:9000;
        }


}

How do I get nginx to parse a script correctly and not download the file??

0

You must log in to answer this question.

Browse other questions tagged .