Ubuntu 14.04---Nginx+uWsgi+Django+Python+MongoDB+m

安裝步驟:(假設root用戶是dev)
//-----------------------------------------------------------------
1a. 安裝Python (Ubuntu 12.04 default already install Python 2.7.3)
# cd /home/dev/Download
# wget http://www.python.org/ftp/python/2.7.3/Python-2.7.3.tgz
# tar xvfz Python-2.7.3.tgz
# cd Python-2.7.3
#./configure
# make
# sudo make install

1b. 安裝Python的包管理 setuptools 安裝
# cd /home/dev/Download
# wget http://peak.telecommunity.com/dist/ez_setup.py
# sudo python ez_setup.py

1c. 安裝Python的包管理pip安裝(須要先安裝setuptools)
# cd /home/dev/Download
# wget http://python-distribute.org/distribute_setup.py
# sudo python distribute_setup.py
# wget https://github.com/pypa/pip/raw/master/contrib/get-pip.py
# sudo python get-pip.py

1d. 下面使用pip 安裝readline
# sudo pip install readline

//-----------------------------------------------------------------
2. 下載安裝Django
# cd /home/dev/Download
# wget https://www.djangoproject.com/download/1.4.3/tarball/
# mv index.html Django-1.4.3.tar.gz
# tar xvfz Django-1.4.3.tar.gz
# cd Django-1.4.3
# sudo python setup.py install

//-----------------------------------------------------------------
3a. 下載安裝MongoDB,先下載安裝scons
# cd /home/dev/Download
# wget http://sourceforge.net/projects/scons/files/scons/2.1.0/scons-2.1.0.tar.gz/download
# mv download scons-2.1.0.tar.gz
# tar xvfz scons-2.1.0.tar.gz
# cd scons-2.1.0
# sudo python setup.py install

Note:
若是你發現C++編譯器沒有安裝(c++ compiler not installed!)
請先安裝C++編譯器 --- sudo apt-get install build-essential

3b. 下載安裝MongoDB
# cd /home/dev/Download
# wget http://downloads.mongodb.org/src/mongodb-src-r2.4.6.tar.gz
# tar xvfz mongodb-src-r2.4.6.tar.gz
# cd mongodb-src-r2.4.6
# scons all
# sudo scons --prefix=/usr/local/mongodb --full install

3c. 下載安裝pyMongo
# cd /home/dev/Download
# wget wget http://pypi.python.org/packages/source/p/pymongo/pymongo-2.6.2.tar.gz
# tar xvfz pymongo-2.6.2.tar.gz
# cd pymongo-2.6.2
# sudo python setup.py install

3d. 測試pyMongo是否安裝成功
# python
>>> import pymongo
若是沒有返回錯誤,則代表安裝成功

3e. 下載安裝mongoengine【暫時沒有用到】
# cd /home/dev/Download
# wget http://github.com/mongoengine/mongoengine/tarball/v0.6.20 --no-check-certificate
# tar xvfz v0.6.20
# cd MongoEngine-mongoengine-9cc6164
# sudo python setup.py install

3f. 測試mongoengine是否安裝成功
# python
>>> from mongoengine import connect
若是沒有返回錯誤,則代表安裝成功

//-----------------------------------------------------------------
4a. 下載安裝MySQL,先下載安裝cmake
# cd /home/dev/Download
# wget http://www.cmake.org/files/v2.8/cmake-2.8.8.tar.gz
# tar xvfz cmake-2.8.8.tar.gz
# cd cmake-2.8.8
#./configure
# make
# sudo make install

4b. 下載安裝mysql
# cd /home/dev/Download
# wget http://www.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.29.tar.gz
or
# wget http://cdn.mysql.com/Downloads/MySQL-5.5/mysql-5.5.29.tar.gz
# tar xvfz mysql-5.5.29.tar.gz
# cd mysql-5.5.29
# cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql -DMYSQL_DATADIR=/usr/local/mysql/data/ -DMYSQL_UNIX_ADDR=/usr/local/mysql/data/mysqld.sock -DWITH_INNOBASE_STORAGE_ENGINE=1 -DSYSCONFDIR=/etc -DEXTRA_CHARSETS=all -DDEFAULT_CHARSET=utf8 -DDEFAULT_COLLATION=utf8_unicode_ci -DWITH_DEBUG=0
# make
# sudo make install

Note:
1. 如出現報錯 Curses library not found. Please install appropriate package
則須要安裝該包
apt-get install libncurses5-dev
若是仍是有問題,加入
cmake -DCURSES_LIBRARY=/usr/lib/libncurses.so -DCURSES_INCLUDE_PATH=/usr/include
2. good link: http://zlizhe.com/ubuntu-源碼安裝-mysql5-5/
   good link: http://forum.ubuntu.org.cn/viewtopic.php?t=330121

4c. 下載安裝mysql-python
# cd /home/dev/Download
# wget http://sourceforge.net/projects/mysql-python/files/mysql-python/1.2.3/MySQL-python-1.2.3.tar.gz
# tar xvfz MySQL-python-1.2.3.tar.gz
# cd MySQL-python-1.2.3
在安裝前,須要修改site.cfg中mysql_config的路徑爲mysql安裝路徑下的/bin/mysql_config
# site.cfg
mysql_config = /usr/local/mysql/bin/mysql_config
更改完後,能夠進行編譯和安裝了
# python setup.py build
# sudo python setup.py install

Note:
1. 若是發現說,找不到Python.h
sudo apt-get install python-dev
maybe need to install --- sudo apt-get install libmysqlclient15-dev
注:經過在python代碼中使用import MySQLdb來判斷是否安裝成功

4d. 這裏還須要將mysql安裝路徑下的lib加入到環境變量LD_LIBRARY_PATH中
# export LD_LIBRARY_PATH=/usr/local/mysql/lib/:$LD_LIBRARY_PATH
若是無論用,在文件/etc/ld.so.conf中添加/usr/local/mysql/lib
good link: http://lsscto.blog.51cto.com/779396/904078

注:cmake選項說明

選項
    

說明

-DCMAKE_INSTALL_PREFIX
    

mysql安裝的主目錄。默認爲/usr/local/mysql

-DMYSQL_DATADIR
    

mysql數據保存的路徑自定義

-DMYSQL_UNIX_ADDR
    

系統Socket文件(.sock)設置基於該文件路徑進行Socket鏈接必要爲絕對路徑

-DWITH_INNOBASE_STORAGE_ENGINE
    

存儲引擎設置

-DSYSCONFDIR
    

mysql配置文件my.cnf地址默認/etc下

-DMYSQL_TCP_PORT
    

數據庫服務器TCP/IP鏈接的監聽端口默認爲3306

-DEXTRA_CHARSETS

-DDEFAULT_CHARSET

-DDEFAULT_COLLATION
    

數據庫編碼設置

-DENABLED_LOCAL_INFILE
    

默認爲關閉這裏開啓

-DWITH_DEBUG
    

DEBUG開關,默認爲關
//-----------------------------------------------------------------
5. 下載安裝uWsgi
# cd /home/dev/Download
# wget http://projects.unbit.it/downloads/uwsgi-1.2.3.tar.gz
# tar xvfz uwsgi-1.2.3.tar.gz
# cd uwsgi-1.2.3
# sudo python uwsgiconfig.py --build

//-----------------------------------------------------------------
6a. 安裝nginx - install ssl
# cd /home/dev/Download
# wget http://www.openssl.org/source/openssl-fips-2.0.2.tar.gz
# tar -zxvf openssl-fips-2.0.2.tar.gz
# cd openssl-fips-2.0.2
# ./config
# make
# sudo make install

6b. install zlib
# cd /home/dev/Download
# wget http://zlib.net/zlib-1.2.8.tar.gz
or
# wget http://prdownloads.sourceforge.net/libpng/zlib-1.2.8.tar.gz?download
# tar -zxvf zlib-1.2.8.tar.gz
# cd zlib-1.2.8
# ./configure
# make
# sudo make install

6c. install pcre
# cd /home/dev/Download
# wget ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.21.tar.gz
# tar -zxvf pcre-8.21.tar.gz
# cd pcre-8.21
# ./configure
# make
# sudo make install

6d. nginx
# cd /home/dev/Download
# wget http://nginx.org/download/nginx-1.4.2.tar.gz
# tar -zxvf nginx-1.4.2.tar.gz
# cd nginx-1.4.2
# ./configure --with-pcre=../pcre-8.21 --with-zlib=../zlib-1.2.8 --with-openssl=../openssl-fips-2.0.2
# make
# sudo make install

6e. check ningx
# cd /usr/local/nginx/sbin
# ./nginx -t

至此安裝組件完成...php

相關文章
相關標籤/搜索