# Execute python files with Nginx

**URL:** <https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906>\
**Category:** NGINX\
**Created:** [August 6, 2015, 1:26pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906 "2015-08-06T13:26:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rafa\_F](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/958977/32.png) [@Rafa\_F](https://www.ruby-forum.com/u/Rafa_F)\
**Post date:** [August 6, 2015, 1:26pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/1 "2015-08-06T13:26:27Z")

</div>

Hello,  
How can we execute python files with Nginx? Anybody can help  
me  
to give steps by steps to follow. In Apache, it is very easy to execute  
python files but in python, I am trying from last 2 days and nothing  
happening. Any Idea how to use “uwsgi” ?

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 6, 2015, 1:49pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/2 "2015-08-06T13:49:50Z")

</div>

Hello,

I’ve never used python with nginx, but there are some examples on how to  
configure everything here:

> **[Getting Started | NGINX](https://www.nginx.com/resources/wiki/start/)**
>
> Useful tools, examples, and other learning resources for getting started with NGINX.

Best Regards

Posted at Nginx Forum:

> **[Re: Execute python files with Nginx](https://forum.nginx.org/read.php?2,260817,260818#msg-260818)**
>
> Hello, How can we execute python files with Nginx? Anybody can help me to give steps by steps to follow. In Apache, it is very easy to execute python files but in python, I am trying from last 2 days and nothing happening. Any Idea how to use...

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 6, 2015, 1:53pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/3 "2015-08-06T13:53:55Z")

</div>

I tried that and getting issues. Unable to configure. I am not getting  
those steps. Any help you can do by explaining in steps…

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 7, 2015, 9:20pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/4 "2015-08-07T21:20:55Z")

</div>

Hi Nitin,

Would you mind providing a bit more information?

> On Aug 6, 2015, at 4:53 AM, Nitin S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> I tried that and getting issues. Unable to configure. I am not getting those  
> steps. Any help you can do by explaining in steps…

What issues are you running into? Can you copy and paste any errors  
you’re receiving?

Can you provide the configuration file you are using?

What is the behavior you are expecting and what is the behavior you’re  
seeing?

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 7, 2015, 10:13pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/5 "2015-08-07T22:13:29Z")

</div>

Hi,  
Right now, I am not office… I am from India… Now, it is 1.42  
am.  
It will be great. If you provide step by step from beginning. Is it  
possible to mail. Thanks.

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 11, 2015, 2:51pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/6 "2015-08-11T14:51:59Z")

</div>

Hi Nitin,

If you’re using django you can follow these steps:

> **[How To Serve Django Applications with uWSGI and Nginx on Ubuntu 14.04 |...](https://www.digitalocean.com/community/tutorials/how-to-serve-django-applications-with-uwsgi-and-nginx-on-ubuntu-14-04)**
>
> Django is a powerful web framework that can help you get your Python application or website off the ground. Django includes a simplified development server f…

Daniel Theodoro  
Cel: 11 99399-3364  
[http://www.linkedin.com/in/danieltheodoro](http://www.linkedin.com/in/danieltheodoro)

• RHCA - Red Hat Certified Architect  
• RHCDS - Red Hat Certified Datacenter Specialist  
• RHCE - Red Hat Certified Engineer  
• RHCVA - Red Hat Certified Virtualization Administrator  
• LPIC-3 - Senior Level Linux Certification  
• Novell Certified Linux Administrator - Suse 11  
• OCA - Oracle Enterprise Linux Administrator Certified Associate

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 11, 2015, 7:34pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/7 "2015-08-11T19:34:10Z")

</div>

Hi Daniel,  
I am not using Django. I am using core python files.  
Is  
it possible with it?

On Tue, Aug 11, 2015 at 6:21 PM, Daniel Theodoro  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 11, 2015, 7:55pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/8 "2015-08-11T19:55:48Z")

</div>

Thanks Shannon…

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [September 5, 2015, 6:37pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/9 "2015-09-05T18:37:06Z")

</div>

Hello nitin  
Please check this configuration.It works for you.  
Server {

listen localhost:8080;

```
    listen [::]:8060 ipv6only=on;

    root /var/www;

    index index.html index.htm index.py;

```

location /html/ {

```
 # Disable gzip (it makes scripts feel slower since they have to

```

complete

```
 # before getting gzipped)

 gzip off;

 # Set the root to /usr/lib (inside this location this means that we

```

are

```
 # giving access to the files under /usr/lib/cgi-bin)

 #root /var/www;

 # Fastcgi socket

 fastcgi_pass unix:/var/run/fcgiwrap.socket;

 # Fastcgi parameters, include the standard ones

 include /etc/nginx/fastcgi_params;

 # Adjust non standard parameters (SCRIPT_FILENAME)

 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

```

}

}

---

<div class="post-metadata">

**Author:** ![Nitin\_S](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/7bcc69/32.png) [@Nitin\_S](https://www.ruby-forum.com/u/Nitin_S)\
**Post date:** [August 11, 2015, 7:53pm UTC](https://www.ruby-forum.com/t/execute-python-files-with-nginx/242906/10 "2015-08-11T19:53:28Z")

</div>

Hi Nitin,

If you are looking for a tutorial on how to get a python application up  
and running with NGINX check out this tutorial:

> **[How To Set Up uWSGI and Nginx to Serve Python Apps on Ubuntu 14.04 |...](https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04)**
>
> In this guide, we will be setting up a simple WSGI application served by uWSGI. We will use the Nginx web server as a reverse proxy to the application server…

[https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04](https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-ubuntu-14-04)

For future reference, Digital Ocean has some really well written  
tutorials to give you a place to start.

Our community is a great place to ask questions once you get stuck. The  
best way to get help when you are stuck is to send:

\*your configuration file  
\*the error logs you’re getting  
\*any other relevant code

I find it most helpful if someone also includes what behavior they are  
expecting the program to perform and what they are seeing it do in  
reality.

Hopefully this is helpful!

Shannon  
Jr. Developer Advocate  
NGINX
