Difference between revisions of "UWSGI"

From ArchWiki
Jump to: navigation, search
m (Fixed package name)
m (rm gap)
(16 intermediate revisions by one other user not shown)
Line 1: Line 1:
 
[[Category:Web Server]]
 
[[Category:Web Server]]
 
 
== Installation ==
 
== Installation ==
  
[[Pacman|Install]] package {{Pkg|uwsgi}} in the [[Official Repositories|official repositories]].
+
[[Pacman|Install]] package {{Pkg|uwsgi}} in the [[Official Repositories|official repositories]]. Note, the package does not come with plugins as it is just a compact package. External plugins have to be installed separately. It is a very efficient software due to the reason it is written in C. There are alternatives written in python like gunicorn, but they are slower inherently.
  
 
== Starting Service ==
 
== Starting Service ==
Line 10: Line 9:
 
  # systemctl enable uwsgi@helloworld.service
 
  # systemctl enable uwsgi@helloworld.service
  
or
+
This will enable the service for the application configured in /etc/uwsgi/helloworld.ini. Otherwise, you can also enable it through the socket interface with the following command:
 
+
 
  # systemctl enable uwsgi@helloworld.socket
 
  # systemctl enable uwsgi@helloworld.socket
 
To start the Nginx service, run:
 
# systemctl start uwsgi
 
  
 
== Configuring ==
 
== Configuring ==
  
You can create a configuration by editing and putting that in {{ic|/etc/uswgi/}}. There is a build file shipped with the package located at {{ic|/etc/uwsgi/archlinux.ini}}.  
+
You can create a configuration by editing and putting that in {{ic|/etc/uwsgi/}}. There is a build file shipped with the package located at {{ic|/etc/uwsgi/archlinux.ini}}.  
  
More details can be found here: [http://uwsgi-docs.readthedocs.org/en/latest/].
+
More details can be found [http://uwsgi-docs.readthedocs.org/en/latest/ in the uwsgi documentation].
  
 
===== Application configuration =====
 
===== Application configuration =====
Line 27: Line 22:
 
The following is a simple example to get python support. You may need to install the uwsgi-plugin-python or uwsgi-plugin-python2 plugin from the community repository by pacman.
 
The following is a simple example to get python support. You may need to install the uwsgi-plugin-python or uwsgi-plugin-python2 plugin from the community repository by pacman.
  
[uwsgi]
+
[uwsgi]
chdir = /srv/http/hwp
+
chdir = /srv/http/helloworld
module = helloworld
+
module = helloworld
plugins = python
+
plugins = python
 +
 
 +
It is also possible to run uwsgi separately with the following syntax for instance:
 +
 
 +
uwsgi --socket 127.0.0.1:3031 --plugin python2 --wsgi-file ~/foo.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191 --uid --gid
 +
 
 +
Note, you should avoid running this command as root.
  
 
===== Nginx configuration =====
 
===== Nginx configuration =====
  
        location / {
+
location / {
            root  /usr/share/nginx/html;
+
    root  /usr/share/nginx/html;
            index  index.html index.htm;
+
    index  index.html index.htm;
            include uwsgi_params;
+
    include uwsgi_params;
            # uwsgi_pass unix:/var/run/uwsgi/helloworld.sock;
+
    # uwsgi_pass unix:/var/run/uwsgi/helloworld.sock;
            uwsgi_pass 127.0.0.1:3031;
+
    uwsgi_pass 127.0.0.1:3031;
        }
+
}
  
 
== See Also ==
 
== See Also ==
* [http://uwsgi-docs.readthedocs.org/en/latest/Nginx Official Documentation]
+
* [http://uwsgi-docs.readthedocs.org/en/latest Official Documentation]
* [https://github.com/unbit/uwsgi-docs Nginx Github]
+
* [https://github.com/unbit/uwsgi-docs UWsgi Github]
 +
* [http://blog.kgriffs.com/ Fluffy White Stuff Benchmark]
 +
* [http://flask.pocoo.org/docs/deploying/uwsgi/ Flash uwsgi deploying]
 +
* [https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/uwsgi/ Django and uWSGI]
 +
* [http://www.youtube.com/watch?v=tD6UCfPCVLA Flask with uwsgi and nginx video]
 +
* [http://uwsgi-docs.readthedocs.org/en/latest/Apache.html Apache and uwsgi]

Revision as of 03:16, 26 August 2013

Installation

Install package uwsgi in the official repositories. Note, the package does not come with plugins as it is just a compact package. External plugins have to be installed separately. It is a very efficient software due to the reason it is written in C. There are alternatives written in python like gunicorn, but they are slower inherently.

Starting Service

To enable the uwsgi service by default at start-up, run:

# systemctl enable uwsgi@helloworld.service

This will enable the service for the application configured in /etc/uwsgi/helloworld.ini. Otherwise, you can also enable it through the socket interface with the following command:

# systemctl enable uwsgi@helloworld.socket

Configuring

You can create a configuration by editing and putting that in /etc/uwsgi/. There is a build file shipped with the package located at /etc/uwsgi/archlinux.ini.

More details can be found in the uwsgi documentation.

Application configuration

The following is a simple example to get python support. You may need to install the uwsgi-plugin-python or uwsgi-plugin-python2 plugin from the community repository by pacman.

[uwsgi]
chdir = /srv/http/helloworld
module = helloworld
plugins = python

It is also possible to run uwsgi separately with the following syntax for instance:

uwsgi --socket 127.0.0.1:3031 --plugin python2 --wsgi-file ~/foo.py --master --processes 4 --threads 2 --stats 127.0.0.1:9191 --uid --gid

Note, you should avoid running this command as root.

Nginx configuration
location / {
    root   /usr/share/nginx/html;
    index  index.html index.htm;
    include uwsgi_params;
    # uwsgi_pass unix:/var/run/uwsgi/helloworld.sock;
    uwsgi_pass 127.0.0.1:3031;
}

See Also