由於開發了多個Django項目,有CMS,ERP,SCADA。分別用的不一樣版本,搞的virtualenv有些混亂,因此從新安裝,用virtualenvwapper隔離開。 html
WIN7下下載安裝virtualbox,4.3.8,安裝很簡單。 java
新建centos6.4,分配2G 內存,安裝也很順利。最後一步崩潰收集那步老失敗,CTL+ALT+BACKSPACE直接進入系統,而後System-administration-kernel crash dump禁用就行了。 python
配置好簡單應用,如文件夾打開方式,網絡配置等 mysql
參考另一篇關於中文輸入法安裝的,用的ibus拼音輸入法。 linux
下載pycharm3,安裝時須要jdk支持。yum安裝的只是openjdk不能用,聽說時oracle受權的問題,新的linux都沒有jdk了。 git
Ubuntu: web
sudo add-apt-repository ppa:webupd8team/java sudo apt-get update sudo apt-get install oracle-java7-installer
centos: sql
從官網下載rpm,rpm -ivh安裝,默認到/usr/java. shell
配置下環境變量: 數據庫
sudo vim /etc/profile
添加以下:
export JAVA_HOME=/usr/java/jdk1.7.0_51 export CLASSPATH=.:$JAVA_HOME/jre/lib/rt.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export PATH=$PATH:$JAVA_HOME/bin
cd到pycharm目錄, sh pycharm.sh開始安裝。安裝完成後註冊:
用戶名:yueting3527 註冊碼: ===== LICENSE BEGIN ===== 93347-12042010 00001FMHemWIs"6wozMZnat3IgXKXJ 2!nV2I6kSO48hgGLa9JNgjQ5oKz1Us FFR8k"nGzJHzjQT6IBG!1fbQZn9!Vi ===== LICENSE END =====
由於centos中默認python爲2.6,咱們但願用最新的2.7.6版本。可是必定要注意centos下好多都依賴2.6,譬如yum,咱們最好單獨安裝又不與2.6衝突。
先安裝編譯所須要的依賴包
yum groupinstall "Development tools" yum install zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel readline-devel tk-devel gdbm-devel db4-devel libpcap-devel
# Python 2.7.6: wget http://python.org/ftp/python/2.7.6/Python-2.7.6.tar.xz tar xf Python-2.7.6.tar.xz cd Python-2.7.6 ./configure --prefix=/usr/local make && make altinstall
注意運用make altinstall而不是make install,這樣跟系統的2.6分別在不一樣的路徑下,也不會衝突了。python2.7在/usr/local/bin下,python2.6在/usr/bin下
從這裏http://www.pip-installer.org/en/latest/installing.html get-pip.py,
sudo python2.7 get-pip.py
sudo pip install virtualenvwrapper
安裝好以後須要簡單配置下,主要是設置獨立環境的保存路徑:
$ export WORKON_HOME=~/Envs $ mkdir -p $WORKON_HOME $ source /usr/local/bin/virtualenvwrapper.sh $ mkvirtualenv cms
爲了以後使用方便不用每次都輸這麼長的指令,能夠加入~/.bashrc
export WORKON_HOME=~/Envs export PROJECT_HOME=~/Devel export VIRTUALENVWRAPPER_PYTHON=/usr/local/bin/python2.7 export VIRTUALENVWRAPPER_VIRTUALENV=/usr/local/bin/virtualenv source /usr/local/bin/virtualenvwrapper.sh
使用時
source ~/.bashrc
若是要刪除一個virtualenv須要先deactivate,以下:
deactivate rmvirtualenv cms
由於yum的版本過低了,記得好像是1.7的,咱們用源碼編譯安裝。
先安裝一些依賴包,固然有些可能以及裝過了
sudo yum -y install curl curl-devel zlib-devel openssl-devel perl cpio expat-devel gettext-devel sudo yum autoconf
sudo wget https://git-core.googlecode.com/files/git-1.9.0.tar.gz
$ tar -zvxf git-1.9.0.tar.gz $ cd git-1.9.0 $ make prefix=/usr/local all $ sudo make prefix=/usr/local install
如今已經能夠用git命令了,用git把 Git 項目倉庫克隆到本地,以便往後隨時更新:
$ git clone git://git.kernel.org/pub/scm/git/git.git
配置用戶名跟email,之後提交git時用
$ git config --global user.name quanpower $ git config --global user.email quanpower@gmail.com $ git config --list
返回:
user.name=quanpower
user.email=quanpower@gmail.com
yum list installed | grep -i mysql
yum remove mysql mysql-*
rpm -Uvh http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-6.rpm
yum --enablerepo=remi,remi-test install mysql mysql-server
yum list installed | grep -i mysql
/etc/init.d/mysqld start## use restart after update
service mysqld start## use restart after update
chkconfig --levels 235 mysqld on
mysql_upgrade -u root -p
Now my MySql version is 5.5.32
mysqldb在pip中叫MySQL-python,
pip install MySQL-python
上面由於沒安裝mysql-devel會報錯,
yum --enablerepo=remi install mysql-develInstalling : mysql-devel-5.5.36-1.el6.remi.i686
由於想添加個gis功能模塊,看django推薦gis用PostgreSQL數據庫,拿來試用下,安裝的時候有幾個注意的小問題。
1.To use the yum repository, you must first install the repository RPM. To do this, download the correct RPM from the repository RPM listing, and install it with commands like:
yum install http://yum.postgresql.org/9.3/redhat/rhel-6-x86_64/pgdg-redhat93-9.3-1.noarch.rpm2.Once this is done, you can proceed to install and update packages the same way as the ones included in the distribution.
yum install postgresql93-server postgresql93-contrib
service postgresql-9.3 initdb chkconfig postgresql-9.3 oncentos須要手動初始化下而後設置默認自啓動。
鏈接PostgreSQL,選擇用的pyycopg2.另外用psycopg2時也碰到幾個問題
下載問題不大,直接去http://initd.org/psycopg/download/下載tar包就行了,或者在virtualenv裏使用
pip install psycopg2
均可。可是compile的時候報了幾回錯。
首先一個pg_cong問題,而後一個libpq問題。去看他文檔說了這麼幾點:
Psycopg is a C wrapper to the libpq PostgreSQL client library. To install it from sources you will need:
A C compiler.
The Python header files. They are usually installed in a package such as python-dev. A message such as error: Python.h: No such file or directory is an indication that the Python headers are missing.
The libpq header files. They are usually installed in a package such as libpq-dev. If you get an error: libpq-fe.h: No such file or directory you are missing them.
The pg_config program: it is usually installed by the libpq-dev package but sometimes it is not in a PATHdirectory. Having it in the PATHgreatly streamlines the installation, so try runningpg_config --version: if it returns an error or an unexpected version number then locate the directory containing the pg_config shipped with the right libpq version (usually/usr/lib/postgresql/X.Y/bin/) and add it to the PATH:
$ export PATH=/usr/lib/postgresql/X.Y/bin/:$PATH
You only need it to compile and installpsycopg2, not for its regular usage.
Note
The libpq header files used to compilepsycopg2should match the version of the library linked at runtime. If you get errors about missing or mismatching libraries when importingpsycopg2check (e.g. using ldd) if the modulepsycopg2/_psycopg.sois linked to the rightlibpq.so.
1.第一個用find / -name pg_config找到路徑,export到PATH裏。
export PATH=/usr/pgsql-9.3/bin/:$PATH
2.第二個,折騰了很久,centos裏面python-dev 是python-devel,可是libpq-dev叫libpqxx-devel
sudo yum install python-devel libpqxx-devel
這樣就行了,yum install下,後面就一路順利了。
Dependencies Resolved
================================================================================
Package Arch Version Repository Size
================================================================================
Installing:
libpqxx i686 1:4.0.1-1.rhel6 pgdg93 189 k
libpqxx-debuginfo i686 1:4.0.1-1.rhel6 pgdg93 772 k
libpqxx-devel i686 1:4.0.1-1.rhel6 pgdg93 91 k
Installing for dependencies:
postgresql93-devel i686 9.3.3-1PGDG.rhel6 pgdg93 1.4 M
Transaction Summary
================================================================================
Install 4 Package(s)
另:若是是在ubuntu下sudo apt-get install python-psgcopg2
安裝完成以後, 系統中會多出一個名爲 postgres 的用戶, 這個用戶用於登陸數據庫. 但沒法直接用該用戶在 shell 或 xdm 中登陸, 須先用其它用戶登陸 shell, 而後su到該用戶. 先爲該用戶設置一下密碼
這樣會以 postgres 用戶身份登陸, 若是要輸入密碼就輸入剛纔爲 postgres 用戶設置的密碼.
PostgreSQL默認的超級管理員密碼是postgres
鏈接方法:psql -U postgres(注意,是大寫的-U)
默認密碼爲空
修改密碼的方法是,用psql登入管理:psql -U postgres
而後用這樣的命令來修改密碼:alter user postgres with password 'new password
若是上面每一個句子輸入以後沒回顯結果, 而且交互環境開頭變爲了postgres-#(注意 # 前是一個減號而非等號), 請查看一下句尾的分號是否漏掉了.
root@server2-virtual-machine:~# vi /etc/postgresql/9.1/main/postgresql.conf
在SCADA系統中須要科學計算以及讀取底層硬件採集的數據,須要按照MODBUS協議解析。因此用到如下包:
pip install pymodbus
pip install numpy
比較折騰的時這個,由於比較大,compile比較費時間,每次還不成功。
numpy.distutils.system_info.BlasNotFoundError: Blas (http://www.netlib.org/blas/) libraries not found. Directories to search for the libraries can be specified in the numpy/distutils/site.cfg file (section [blas]) or by setting the BLAS environment variable.大stackoverflow.com救了我。 最後找到須要提早安裝下面的依賴包。
yum install lapack lapack-devel blas blas-devel
pip install scipy
pip install Django