This article is based on:
Ubuntu Server_10.04_LTS
CentOS Linux release 6.0 (Final)
The platforms to be built are:
Python
Nginx
UWSGI
Beanstalkd
We recommend that you use the reading mode to browse this article.
Note: to install this environment, you must have the root permission, the usual operation directory is the home directory of the current user, and the system must have the gcc, gcc-c ++ compiler, and the installation file should be retained. if you want to uninstall a software program one day, you can enter the installation directory for execution (root permission),
Sudo make uninstall
I. Python
Most Linux platforms already have the Python environment, so you do not need to install or use it directly. This version of Ubuntu comes with Python 2.6.
Ii. Nginx
Then install Nginx. The latest stable version so far is 1.0.10,
Run the following command:
Wget http://nginx.org/download/nginx-1.0.10.tar.gz
Tar-zxf nginx-1.0.10.tar.gz
Cd nginx-1.0.10
./Configure
Make
Sudo make install
In addition. /The configure information must be checked. If the configure information is incorrect, the last two steps cannot be executed, and the congiure error information is also the root cause of the make error. For example, if if the system lacks the pcre Library, errors will be reported during the make process. /view the configure error information. Check whether the pcre component is not installed. If this component is not installed, install it on google. If wget is installed, execute the three-step installation of source code. If there is another error, check whether there is any problem. the package is not installed ,. /After configure is solved, there is no problem in the next two steps. If there is a problem with make and make install, then the problem must be that the c or c ++ compiler is not properly installed or set.
Another method is to compile the source code package by the Nginx Installer. For example, if the pcre and zlib packages are missing, you need to package the source code back and decompress the package. specify the decompressed directory in the/configure parameter. Note that you do not need to compile and install pcre and zlib on your own, because Nginx will compile and install them in a unified manner and use commands. as follows:
./Configure \
-- Prefix =/www/xres/app/nginx-1.0.10 \
-- With-pcre =/www/xres/app/install_files/pcre-8.12 \
-- With-zlib =/www/xres/app/install_files/zlib-1.2.5
P.S: The backslash (\) serves as a separator, and can be written by a command. It is not necessary.
During nginx installation, if you do not use the-prefix = DIR command to specify the directory, the default installation directory is/usr/local/nginx. Then you need to add the running file to the system. environment variables can be used and executed
Sudo ln-s/usr/local/nginx/sbin/nginx/usr/sbin/
Now it's okay. Run sudo nginx to start the nginx service. Be sure to use the root permission. Make sure that the specified port is not occupied by other programs. The default nginx service port is port 80, if you have other web servers such as Apache that may occupy port 80 and cannot be started, stop these services or change the nginx port to another non-80 port,
Finally, verify whether nginx has been started. If it is a local test, open the browser and enter http: // localhost: the welcome interface for nginx appears at 80. If you want to modify the nginx configuration file later, go to the Nginx installation directory to modify it. The default installation directory is/usr/local/nginx. /conf/nginx. conf to modify, note that the configuration file is backed up before modification to prevent unexpected
Iii. uWSGI
Nginx has supported uWSGI since version 0.8.40. If Nginx is earlier than version 0.8.40, uWSGI patches are available. the method is to upgrade your Nginx version as soon as possible. If your machine has installed the python pip package management tool, simply execute the following command to complete the installation
Pip install uwsgi
If pip is not installed, install it first. Note that the root permission is required to install pip.
Sudo apt-get install pip
If you are not an Ubuntu operating system, it will be a lot of trouble,
First, download the pip source code package.
Wget \ http://pypi.python.org/packages/source/p/pip/pip-1.0.2.tar.gz#md5=47ec6ff3f6d962696fe08d4c8264ad49
Decompress the package and enter the directory for execution.
Python setup. py install
P.S.: if an error is reported and the setuptools package cannot be imported, you must first install a setuptools package.
You can go to this page to find the python version of your system.
Http://pypi.python.org/pypi/setuptools#installation-instructions
For example, if your python version is 2.6
Wget \ http://pypi.python.org/packages/2.6/s/setuptools/setuptools-0.6c11-py2.6.egg#md5=bfa92100bd772d5a213eedd356d64086
Run the following command to complete the installation of setuptools, and then try to install pip.
Sudo sh setuptools-0.6c11-py2.6.egg
If your machine does not have the pip tool and does not want to install pip, you can use the source code installation method. First download the latest LTS source code package.
Wget http://projects.unbit.it/downloads/uwsgi-lts.tar.gz
Tar-zxf uwsgi-lts.tar.gz
Then you can run the make command in the directory. If an error is reported when the make command is executed, such as the lack of Python. for libraries such as h, you need to install Python-dev and other dependent components. You can use software management tools such as yum or apt-get to install them,
CenterOS:
Sudo yum install libxml2 * python-dev *
Ubuntu:
Sudoapt-get install build-essential python-dev libxml2-dev
Finally, test whether uWSGI has been properly installed. First, create a python file test_uwsgi.py and enter
DefApplication (env, start_response ):
Start_response ('2017 OK ', [('content-type', 'text/html')])
Return"Hello World"
Then execute the command
./Uwsgi -- http: 9090 -- wsgi-file test_uwsgi.py
P.S.: if pip is used for installation, run this command.
Uwsgi -- http: 9090 -- wsgi-file test_uwsgi.py
If no error is reported after successful startup, start the corresponding browser and check whether "Hello World" is displayed. If the browser is enabled, the address is http: // localhost: 9090 if it is properly displayed, uWSGI is successfully installed.
4. beanstalkd
Beanstalkd and beanstalk are installed in a simple and efficient queue,
1. Server
First install the server, but do some preparation before installing beanstalkd.
Beanstalkd requires libevent library support, so if the environment does not come with it, you must first install libevent,
Beanstalkd currently has limits on libevent support versions, and only supports Versions later than 1.4.1 and earlier than 2.0,
It cannot be installed too high or too low. From the official website, the latest version 1.4.x is 1.4.14b-stable. Let's use this version and execute it this time.
Wget https://github.com/downloads/libevent/libevent/libevent-1.4.14b-stable.tar.gz
Decompress the package
Tar-zxf libevent-1.4.14b-stable.tar.gz
Then go to the decompressed directory to execute the installation. Here, execute the make install command to require the root permission.
./Configure
Make
Sudo make install
Then install beanstalkd. The latest version is 1.4.6. Run the following command on the terminal to download the beanstalkd Server Source code.
Wget https://github.com/downloads/kr/beanstalkd/beanstalkd-1.4.6.tar.gz
Tar-zxf beanstalkd-1.4.6.tar.gz
Cd beanstalkd-1.4.6 /-
./Configure
Make
Sudo make install
Similarly, make install requires the root permission. After installation, try to start beanstalkd,
Beanstalkd-l 127.0.0.1-p 14711 &
For centerOS, go to the bin directory of the installation directory and run./beanstalkd.
./Beanstalkd-l 127.0.0.1-p 14711
(The followingCenterOSExecution result is the same as above)
This command requires beanstalkd to start a service in the background. If no error is reported, it is half successful. However, this command can only be connected from the local machine. If you want other clients to connect to it, you should execute this command,
Beanstalkd-d-p 14711
2. Client
Then the beanstalkd client is installed. Here we select beanstalkc and a beanstalkd client written in basic python. Installing the client is simple. You can use pip, the Python package management software. now,
Install pip and then install beanstalkc.
Sudo pip install beanstalkc
Root is also required. before using the beanstalkc client to execute the connection, make sure that the PyYAML component has been installed in the local Python. If not, execute
Sudo pip install PyYAML
OK, this is a big task. test whether the client has been successfully installed,
Start the python Console
Python
Import beanstalkc package
>>> Import beanstalkc
If no error is reported, the python client of beanstalkc is successfully installed.
Enter
>>> Beanstalk = beanstalkc. Connection (host = 'localhost', port = 14711)
Before entering this command, make sure that the beanstalkd server is started,
If no error is reported for this command, it indicates that the client has successfully connected to the server. If you connect to the server from another client, you only need to know the ip address of the server. For example, the ip address of the server is replace localhost with 192.168.0.142. You can perform the following operations normally or exit the python console or exit ()