2014年6月11日 星期三

安裝uWSGI配合Nginx Server

【安裝uwsgi】

參考:http://www.openfoundry.org/tw/tech-column/8536-introduction-of-python-extension-management-tools

先安裝 pip 套件管理程式
easy_install pip

參考:https://docs.djangoproject.com/en/dev/howto/deployment/wsgi/uwsgi/
安裝gcc
yum install gcc

安裝
yum install python-devel

安裝目前stable版的uwsgi
pip install uwsgi

參考文章:http://django-china.cn/topic/101/

測試安裝結果

測試一:直接執行uwsgi命令,不加任何參數
uwsgi

測試二:
新增測試檔案
cd /home/john/www/test.py

# test.py
def application(env, start_response):
    start_response('200 OK', [('Content-Type','text/html')])
    return "Hello World"

執行uwsgi伺服器
uwsgi --http :8001 --wsgi-file test.py

用瀏覽器開啟網頁
http://127.0.0.1:8001

成功的話,應該會出現
Hello World

2014年6月10日 星期二

CentOS安裝Django

參考文章:http://itekblog.com/django-centos-6-4/

因為安裝CentOS65時,使用Desktop方式安裝,所以系統中已經有python 2.6.6了
所以接著先安裝EPEL repositories

wget http://mirrors.nl.eu.kernel.org/fedora-epel/6/i386/epel-release-6-8.noarch.rpm
rpm -Uvh epel-release-6-8.noarch.rpm
rm epel-release-6-8.noarch.rpm -f

※另法
也可以先用wget下載,安裝https://pypi.python.org/pypi/distribute 套件。

安裝Django
yum install python-setuptools
easy_install django

或者改用pip方式裝,可指定安裝的版本
pip install Django==1.6.5

測試Django

import django
print django.get_version()

測試開發Django網站
cd ~
django-admin.py startproject testdjangosite
cd testdjangosite
python manage.py runserver

用瀏覽器開啟 http://127.0.0.1:8000/


2014年6月9日 星期一

在CentOS 6 上安裝nginx server

■資料來源:
http://wiki.nginx.org/Install
http://nginx.org/en/linux_packages.html

■新增nginx yum repository,
新增檔案/etc/yum.repos.d/nginx.repo,內容如下:

[nginx]
name=nginx repo
baseurl=http://nginx.org/packages/centos/6/$basearch/
gpgcheck=0
enabled=1

記得確定版本
或
wget http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm
rpm -ivh http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm

■更新套件庫
yum update

■安裝 Nginx Web Server
yum install nginx

■執行 Nginx Web Server
service nginx start
Starting nginx:                                            [  OK  ]

■瀏覽一下


■設定開機預設啟動 Nginx 和關閉 Apache Web Server
chkconfig --level 3 nginx on
chkconfig --level 3 httpd off

■順便安裝webmin的管理模組
http://www.webmin.com/cgi-bin/search_third.cgi?search=nginx
登入webmin後,直接以網址方式安裝模組即可。



另一篇也不錯
http://www.cyberciti.biz/faq/install-nginx-centos-rhel-6-server-rpm-using-yum-command/

2012年10月17日 星期三

vmdk轉vdi

直接利用VirtualBox附的VBoxManage就可以轉換虛擬硬碟的格式。 指令:
VBoxManage clonehd source.vmdk target.vdi --format VDI
--format是指target的格式

2012年2月20日 星期一

網執執行scratch專案

參考來源

準備檔案
1. http://scratch.mit.edu/static/misc/ScratchApplet.jar
2. http://scratch.mit.edu/static/misc/soundbank.gm

html語法



屬性 project的值可以使用utf-8中文字