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.