Use uwsgi on ubuntu to deploy the CherryPy Application

Source: Internet
Author: User

Use uwsgi on ubuntu to deploy the CherryPy Application

1. Install uWSGI server

sudo apt-get install uwsgi uwsgi-plugin-python
2. Create a configuration file in the/etc/uwsgi/apps-available Directory.
appsample.json
The content is as follows:
{ "uwsgi": { "chdir": "/home/yourdir", "uid": "your-userid", "gid": "www-data", "workers": 8, "module": "appsample:mkapplication()", "pythonpath": "/path/to/the/directory/where/yourapp.py/is/found", "show-config": true, "stats": "127.0.0.1:9191" } }
3. Create a link
sudo ln -s /etc/uwsgi/apps-available/appsample.json /etc/uwsgi/apps-enabled/appsample.json
</pre>
4. restart uwsgi
sudo service uwsgi restart
5. Access
uwsgi --connect-and-read 127.0.0.1:9191
6. To facilitate stat server Detection, you can install
sudo pip install uwsgitop
Then the uwsgi operation is detected through uwsgitop
uwsgitop 127.0.0.1:9191
7, in order to use uwsgi in apache2, you need to install libapache2-mod-uwsgi
sudo apt-get install libapache2-mod-uwsgi
Then add the following configuration in apache2:
<pre name="code" class="plain"><Location /myapi> SetHandler uwsgi-handler uWSGISocket /run/uwsgi/app/appsample/socket </Location>
Configure reload apache2.
In this way, access http: // localhost/myapi/
Apache2 will redirect the access request to the uwsgi application.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.