一、確保python已經安裝ok(我就用系統自帶的,方便)python
二、安裝Djangomysql
下載包wget https://www.djangoproject.com/download/1.5.5/tarballsql
tar xzvf Django-1.5.5.tar.gz
數據庫
cd Django-1.5.5
django
python setup.py install
瀏覽器
建一個簡單的project測試Django是否ok網絡
cp Django-1.5.5/django/bin/django-admin.py /usr/local/bin/app
chmod +x /usr/local/bin/django-admin.pycurl
mkdir /app/www && cd /app/www && django-admin.py startproject mysiteide
python manage.py runserver 啓動站點而後curl http://127.0.0.1:8000/ 觀察下圖請求狀態200說明該站點工做ok
python manage.py runserver 0.0.0.0:8000 經過這個命令啓動站點,則你本地網絡中的其它計算機就能夠在瀏覽器中訪問你的 IP 地址了
三、測試環境中打算使用mysql數據庫,我採用源碼安裝mysql
一、編譯安裝
mkdir /app/mysql/data -p
groupadd mysql
useradd -g mysql mysql
tar xfvz mysql-5.1.47.tar.gz
cd mysql-5.1.47
CFLAGS="-O3" CXX=gcc CXXFLAGS="-O3 -felide-constructors -fno-exceptions -fno-rtti" \
./configure --prefix=/usr/local/mysql --localstatedir=/app/mysql --sysconfdir=/etc --with-mysqld-user=mysql \
--enable-assembler --with-mysqld-ldflags=-static --libdir=/usr/lib64 --without-debug \
--enable-thread-safe-client --enable-profiling --with-client-ldflags=-static \
--witmake && make installh-plugins=innobase --with-charset=utf8 --with-extra-charsets=latin1,gbk
make && make install (沒有報錯則安裝ok,有錯誤google下,都會有答案 嘿嘿)
二、mysql安裝後的設置和測試;
//複製配置文件
cp mysql-5.1.47/support-files/my-medium.cnf /etc/my.cnf
//初始化數據庫 (必須的,很重要)
chmod /usr/local/mysql/bin/mysql_install_db
/usr/local/mysql/bin/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/app/mysql/data/
//設置mysqld的開機啓動
cp mysql-5.1.47/support-files/mysql.server /etc/init.d/mysqld
chmod 755 /etc/init.d/mysqld
chkconfig mysqld on
//配置環境 (爲了方便,將mysql 的bin目錄加到PATH中,在/etc/profile中加入myslq/bin,順便增長兩個別名方便操做)
export PATH=/usr/local/mysql/bin:$PATH
/etc/init.d/mysqld start 啓動mysql
三、刪除一些不須要的數據庫等信息
/usr/local/mysql/bin/mysql -e "delete from mysql.user where host != '127.0.0.1'"
/usr/local/mysql/bin/mysql -e "drop database test"
/usr/local/mysql/bin/mysql -e "update mysql.user set host='%' where host='127.0.0.1'"
/usr/local/mysql/bin/mysql -e "flush privileges"
補充:安裝mysql適配器MySQLdb,使用任何數據庫都要用到適配器,適配器簡單來講就是用於在數據集和數據源之間移動數據的程序
yum install MySQL-python
測試:
>>>import MySQLdb
不報錯說明安裝ok