Preparation
Install the following tools:
nginx
uwsgi
virtualenv
Nginx and uwsgi build another article: http://galean.blog.51cto.com/7702012/1302198
To install virtualenv, you must first install pip. pip can easily install, uninstall, and manage Python packages.
Virtualenv can establish multiple independent virtual environments. Each environment has its own python interpreter and its own package, which does not affect each other. The virtualenv tool can extract the python programs installed in your system and put them in a specific directory for python applications such as moinmoin described in this article. In this way, even if the python version is changed in the system, the deployed python applications will not be negatively affected.
Pip and virtualenv can work together very conveniently.
Install pip first. After installation, pip install virtualenv can automatically download and install virtualenv from the Internet. Then virtualenv env1 can create a virtual environment named env1. After entering this virtual environment, use pip install to install other packages, which will only be installed in this virtual environment, it does not affect other virtual environments or system environments.
Install pip:
Pip is: https://pypi.python.org/pypi/pip
Decompress the package,
Tar zxvf pip-1.4.1.tar.gz
Cd pip-1.4.1
Python setup. py install
Installation: virtualenv
Pip install virtualenv
If-bash: pip: command not found appears, find the path of the pip executable file:
[Root @ htuidc ~] # Find/*-name pip
/Usr/local/python27/bin/pip
Then:
[Root @ htuidc ~] #/Usr/local/python27/bin/pip install virtualenv
The installation is successful.
2. Download The moinmoin Software Package
Cd/data/web
Wget http://static.moinmo.in/files/moin-1.9.7.tar.gz
Tar zxvf moin-1.9.7.tar.gz
Cd moin-1.9.7
Install moinmoin:
####### Build an isolated python Environment
# Mkdir-p/data/web/moinmoin
# Virtualenv/data/web/moinmoin/python-env
######## Activate the python isolation environment and install moinmoin
# Cd/data/web/moin-1.9.7
# Source/data/web/moinmoin/python-env/bin/activate
# Python setup. py install
######## Install the moinmoin instance to the/data/web/moinmoin/wiki directory
# Cp-r./wiki/data/web/moinmoin
# Cd/data/web/moinmoin/wiki
# Cp config/wikiconfig. py ./
# Cp server/moin. wsgi ./
####### Disable the python isolation Environment
# Deactivate
After completing the preceding steps, we can find that thanks to the virtualenv tool, all moinmoin-related files are installed in/var/www/moinmoin/python-env/share/moin and/var/www/moinmoin/python-env/lib/python2.7/ site-packages/MoinMoin directory, by default, they are installed in the/usr/share/moin and/usr/lib/python2.7/site-packages/MoinMoin directories.
Configure nginx:
Server {
Listen 80;
Server_name localhost;
Location ^ ~ /Wiki {
Include uwsgi_params;
Uwsgi_pass 127.0.0.1: 8630;
Uwsgi_param UWSGI_PYHOME/data/web/moinmoin/python-env /;
Uwsgi_param UWSGI_CHDIR/data/web/moinmoin/wiki /;
Uwsgi_param UWSGI_SCRIPT moin_wsgi;
Uwsgi_param SCRIPT_NAME/wiki;
Uwsgi_modifier1 30;
}
Location ^ ~ /Wiki/moin_static /{
Alias/data/web/moinmoin/python-env/lib/python2.7/site-packages/MoinMoin/web/static/htdocs /;
Add_header Cache-Control public;
Expires 1 M;
}
Location =/favicon. ico {
Log_not_found off;
}
}
Next, we will give a rough analysis of the above Code process.
If the request sent by the web browser is "192.168.0.2/wiki", nginx will ~ /Wiki:
Load the "uwsgi_params.conf" file in the/etc/nginx directory;
Communicates with the uwsgi server through 127.0.0.1: 8630, similar to the process pipeline;
Set the python runtime environment. Here, the python directory constructed by the virtualenv tool in the above section contains the python program itself and the moinmoin software package installed above;
Set the uwsgi server to enter the/data/web/moinmoin/wiki directory before the corresponding http request http: // 192.168.0.7). This directory is the moinmoin instance we created earlier;
Set the python program to run on the uwsgi server, that is, moin. wsgi;
Set the http request corresponding to the python program running on the uwsgi server to http: // 192.168.0.7/wiki.
Configure uwsgi:
If you want to start uwsgi directly in the command line, you only need to use the following command:
Uwsgi-x/etc/uwsgi. xml
Of course, you need to create the uwsgi configuration file uwsgi. xml in the/etc/uwsgi directory. The content is as follows:
<Uwsgi>
<Socket>/tmp/wiki. sock </socket>
<Limit-as> 256 </limit-as>
<Processes> 6 </processes>
<Memory-report/>
<Vhost/>
<No-site/>
</Uwsgi>
This article is from the galean blog, please be sure to keep this source http://galean.blog.51cto.com/7702012/1305067