Nginx是最流行的高性能HTTP服務器。python
安裝pcre:nginx
wget https://sourceforge.net/projects/pcre/files/pcre/8.37/pcre-8.37.tar.gz
tar –zxvf pcre-8.37.tar.gz cd pcre-8.37 ./configure --prefix=/usr/local/pcre make make install
安裝zlib:web
wget http://nchc.dl.sourceforge.net/project/libpng/zlib/1.2.8/zlib-1.2.8.tar.gz
tar -zxvf zlib-1.2.8.tar.gz cd zlib-1.2. ./configure --prefix=/usr/local/zlib make make install
安裝nginx:數據庫
wget http://nginx.org/download/nginx-1.10.1.tar.gz tar -zxvf nginx-1.10.1.tar.gz cd nginx-1.10.1 ./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-pcre=/root/soft/pcre-8.37/ --with-zlib=/root/soft/zlib-1.2.8/ make && make install ####注意#### --with-pcre=/root/soft/pcre-8.37/ 指向的是pcre的源碼目錄,不是安裝目錄 --with-zlib=/root/soft/zlib-1.2.8/ 指向的是zlib的源碼目錄,不是安裝目錄 ############
MySQL-python是Python訪問MySQL數據庫的第三方模塊庫(yum安裝或源碼安裝)。django
yum install MySQL-python
uwsgi是一個快速的、純C語言開發的、自維護、對開發者友好的WSGI服務器,旨在提供專業的Python Web應用和發佈功能(源碼安裝或pip安裝)。服務器
pip install uwsgi
本次使用的是Django1.8.6版本。socket
pip install Django==1.8.6
web目錄:/data/www/性能
建立一個Django項目spa
cd /data/www
django-admin.py startproject OMServer
【/usr/local/nginx/conf/nginx.conf】.net
server { listen 80; server_name localhost; location / { uwsgi_pass 192.168.1.22:9000; #uwsgi地址及端口(要跟uwsgi配置一致) include uwsgi_params; access_log off; } location ~ /static/ { root /data/www/OMServer/; access_log off; } }
【/usr/local/nginx/conf/uwsgi.ini】
[uwsgi] socket = 192.168.1.22:9000 #uwsgi監聽的地址及端口(在nginx配置中會用到) master = true #啓動主進程 pidfile = /usr/local/nginx/logs/uwsgi.pid processes = 4 #uwsgi開啓的進程數 chdir = /data/www/OMServer #項目主目錄 wsgi-file = OMServer/wsgi.py #uwsgi文件路徑 pythonpath = /data/www profiler = true memory-report = true enable-threads = true logdata = true limit-as = 6048 daemonize = /data/logs/django.log
uwsgi --ini /usr/local/nginx/conf/uwsgi.ini
/usr/local/nginx/sbin/nginx
訪問http://192.168.1.22。出現It worked!頁面表示配置成功。