-
sudo apt-get update -
sudo apt-get upgrade -
sudo add-apt-repository ppa:team-xbmc -
sudo apt-get update -
sudo apt-get install xbmc -
sudo apt-get update -
sudo apt-get upgrade
-
Setup XBMC on Ubuntu 10
-
Install coherence on ubuntu 10
sudo apt-get install python-coherence
coherence is a full featured DLNA solution for linux- Coherence is a complete UPnP python framework including a DMS, a DMR, and a DMC.
- LinuxMCE as a complete free solution has Fuppes integrated, but plans to switch to MediaTomb.
- XBMC a free and open source (GPL) software media player and entertainment hub for digital media available for Linux, Mac OS X, Microsoft Windows, as well as the original Xbox game console
- Asset UPnP/DLNA, Free Audio specific UPnP/DLNA server for Windows & Windows Home Server. Features album art, audio WAVE/LPCM transcoding from a huge range of audio codecs, replaygain support for streamed audio. Customizable browse tree.
- Jamcast, a DLNA compliant media server for Windows that is capable of streaming any audio playing on the PC to DLNA devices.
- Mezzmo is a feature-packed UPnP/DLNA media server with on-the-fly transcoding and media organizing features.
- PlayOn from MediaMall.[37] Appears to be a DMS, also capable of serving streamed internet media such as Netflix, Hulu, YouTube, CNN, ESPN.
- PS3 Media Server.An open source (GPLv2) DLNA compliant UPnP Media Server for the PS3, written in Java, with the purpose of streaming or transcoding any kind of media files, with minimum configuration.
- Serviio is a free DLNA media server and works with any DLNA compliant device (TV, Playstation 3, etc.) and some other (XBox 360). It is updated frequently.
- TwonkyMedia server runs on PC, Mac, Linux and Android and enables media sharing of local and online media among a large variety of devices.
- TVMOBiLi – A free DLNA/UPnP Media Server for Windows, Mac OS X and Linux. Appears to be just a DMS.
- TVersity, a free UPnP MediaServer with strong device support and on-the-fly transcoding.[41] Appears to be just a DMS.
- Coherence is a framework written in Python to enable applications access to digital living network resources. As a stand alone application it can act as a UPnP/DLNA media server, in combination with a supported client as a media renderer.
http://en.wikipedia.org/wiki/Comparison_of_UPnP_AV_MediaServersName 
License 
Cost 
Mac OS X 
Linux, Unix 
MS Windows 
Audio 
Images 
Video 
On-The-Fly A/V Transcoding 
Web Interface 
DLNA Certified 
Implementation 
Source Control 
360 Media Server GPL Free No Yes Yes Yes No No Yes Yes ? Java Git BRisa MIT Free Yes Yes No Yes Yes Yes Yes [1] Yes ? Python CVS Coherence MIT Free Yes Yes No Yes Yes Yes Yes [2] Yes [1] ? Python Subversion+Trac Elgato Eyeconnect Prop. $49.95 Yes No No Yes Yes Yes No No ? Foobar2000 [3] Prop. Free No No Yes Yes No No Yes No ? FUPPES GPL Free Yes Yes Yes Yes Yes Yes Yes Yes ? C++ Subversion GeeXboX uShare GPL Free No Yes[4] No Yes[5] Yes[5] Yes[5] No Yes ? Gmediaserver GPL Free No Yes No Yes No Yes No No ? C FTP iSedora Media Server Prop. $25 Yes No Yes Yes Yes Yes Yes Yes ? Majestic Media Server Prop. $5.99 Yes No No Yes Yes Yes Yes No ? MediaTomb GPL Free Yes [6] Yes No Yes Yes Yes Yes Yes ? C++ Subversion minidlna GPL/BSD Free Partial [7] Yes Yes [8] Yes Yes Yes Partial [9] Partial [10] ? C CVS Mezzmo Prop. $24.95 No No Yes Yes Yes Yes Yes No ? myiHome Prop. Free Yes Yes Yes Yes Yes Yes No No ? MythTV with uPnP GPL Free Yes Yes No Yes Yes Yes Yes Yes ? C++ git+trac Nullriver Medialink Prop. $20.00 Yes No No Yes Yes Yes Yes No ? PS3 Media Server GPL Free Yes Yes Yes Yes Yes Yes Yes Yes [11] ? Java Subversion PyMedS MIT Free Yes Yes No ? ? ? Yes [12] No ? Python HTTP Rygel LGPLv2 Free No Yes No [13] Yes Yes Yes Yes No ? vala git Rivet Prop. $18.95 Yes No No Yes Yes Yes No No ? Serviio Prop. Free Yes Yes Yes Yes Yes Yes Yes No ? SimpleCenter Premium Prop. $19.99 No No Yes Yes Yes Yes Yes Yes ? TVersity Prop. $29.95 [14] No No Yes Yes Yes Yes Yes Yes ? TVMOBiLi Prop. Free Yes Yes Yes Yes Yes Yes No Yes ? TwonkyMedia Server Prop. $29.95 Yes Yes Yes Yes Yes Yes Yes [15] Yes ? Windows Media Connect Prop. Free [16] No No Yes Yes Yes Yes No No ? PlayOn $79.97 [17] No No Yes ? ? Yes ? ? ? XBMC Media Center GPL Free Yes Yes Yes Yes Yes [18] Yes No Yes ? C++ git Yazsoft Playback Prop. $15.00 Yes No No Yes Yes Yes No No ? -
Install lighttpd on ubuntu
sudo apt-get update
sudo apt-get upgrade
sudo apt-get install lighttpd
modify lighttpd configuration ==> sudo nano /etc/lighttpd/lighttpd.conf
- Disable global dir listing : server.dir-listing = “enable” ==> server.dir-listing = “disable”
- Add alias of url: alias.url = (
“/img/” => “/www/image/”,
“/fp/” => “/www/flowplayer/”,
“/Google_I_O/” => “/usr/share/red5/dist/webapps/root/Google_I_O/”,
“/assets/” => “/usr/share/red5/dist/webapps/root/assets/”,
“/download/” => “/data/download/”,
“/dl/” => “/data/download/”
) - Enable dir listing for the specified url: $HTTP[“url”] =~ “^/dl/|^/download/|^/Google_I_O/” {
dir-listing.activate = “enable”
} - Enable module of mod_flv_streaming
sudo /usr/sbin/lighty-enable-mod cgi
sudo /etc/init.d/lighttpd force-reload
-
About Godaddy AD
Remove AD:
Add <script> in HTML file, just after the tag of </body>
example:
<html>
<body>
<h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body>
<script>
</html>Hide AD
Add <style>#conash3D0 {display:none}</style>; in HTML file, just after tag of </body>
example:
<html>
<body>
<h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body>
<style>#conash3D0 {display:none}</style>;
</html> -
Hide Godaddy AD in the front of wordpress
Add the following code into wp-includesgeneral-template.php:
function wp_footer() {
/*
Hide AD
echo ‘<style>#conash3D0 {display:none}</style>’;
*/
$lang = explode(‘,’,strtolower($_SERVER[‘HTTP_ACCEPT_LANGUAGE’]));
if($lang[0]==’zh-cn’) { echo ‘<style>#conash3D0 {display:none}</style>’; }
unset($lang);
do_action(‘wp_footer’);
} -
Setup WordPress AT Godaddy Free Space
- Create linux free space at godaddy
- Lunch the controller of free space
- Add the specified domain for free space. eg: host.zhenglei.net
- Create FTP User for Free Space
- Creat mysql database for woodspace,and record the info from edit/viewer
- Delete all default in free space
- Download latest wordpress from http://wordpress.org/, unzip/untar, and ftp all contents to the root of free space
- Launch the installation from web site: http://host.zhenglei.net/wp-admin/install.php
- Finish the step 2 of installation
-
nginx rewrite规则和参考
http://edu.codepub.com/show.php?contentid=25477
正则表达式匹配,其中:
- * ~ 为区分大小写匹配
- * ~* 为不区分大小写匹配
- * !~和!~*分别为区分大小写不匹配及不区分大小写不匹配
文件及目录匹配,其中:
- * -f和!-f用来判断是否存在文件
- * -d和!-d用来判断是否存在目录
- * -e和!-e用来判断是否存在文件或目录
- * -x和!-x用来判断文件是否可执行
flag标记有:
- * last 相当于Apache里的[L]标记,表示完成rewrite
- * break 终止匹配, 不再匹配后面的规则
- * redirect 返回302临时重定向 地址栏会显示跳转后的地址
- * permanent 返回301永久重定向 地址栏会显示跳转后的地址
一些可用的全局变量有,可以用做条件判断(待补全)
- $args
- $content_length
- $content_type
- $document_root
- $document_uri
- $host
- $http_user_agent
- $http_cookie
- $limit_rate
- $request_body_file
- $request_method
- $remote_addr
- $remote_port
- $remote_user
- $request_filename
- $request_uri
- $query_string
- $scheme
- $server_protocol
- $server_addr
- $server_name
- $server_port
- $uri
结合QeePHP的例子
- if (!-d $request_filename) {
- rewrite ^/([a-z-A-Z]+)/([a-z-A-Z]+)/?(.*)$ /index.php?namespace=user&controller=$1&action=$2&$3 last;
- rewrite ^/([a-z-A-Z]+)/?$ /index.php?namespace=user&controller=$1 last;
- break;
多目录转成参数
abc.domian.com/sort/2 => abc.domian.com/index.php?act=sort&name=abc&id=2- if ($host ~* (.*).domain.com) {
- set $sub_name $1;
- rewrite ^/sort/(d+)/?$ /index.php?act=sort&cid=$sub_name&id=$1 last;
- }
目录对换
/123456/xxxx -> /xxxx?id=123456- rewrite ^/(d+)/(.+)/ /$2?id=$1 last;
例如下面设定nginx在用户使用ie的使用重定向到/nginx-ie目录下:
- if ($http_user_agent ~ MSIE) {
- rewrite ^(.*)$ /nginx-ie/$1 break;
- }
目录自动加“/”
- if (-d $request_filename){
- rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
- }
禁止htaccess
- location ~/.ht {
- deny all;
- }
禁止多个目录
- location ~ ^/(cron|templates)/ {
- deny all;
- break;
- }
禁止以/data开头的文件
可以禁止/data/下多级目录下.log.txt等请求;- location ~ ^/data {
- deny all;
- }
禁止单个目录
不能禁止.log.txt能请求- location /searchword/cron/ {
- deny all;
- }
禁止单个文件
- location ~ /data/sql/data.sql {
- deny all;
- }
给favicon.ico和robots.txt设置过期时间;
这里为favicon.ico为99天,robots.txt为7天并不记录404错误日志- location ~(favicon.ico) {
- log_not_found off;
- expires 99d;
- break;
- }
- location ~(robots.txt) {
- log_not_found off;
- expires 7d;
- break;
- }
设定某个文件的过期时间;这里为600秒,并不记录访问日志
- location ^~ /html/scripts/loadhead_1.js {
- access_log off;
- root /opt/lampp/htdocs/web;
- expires 600;
- break;
- }
文件反盗链并设置过期时间
这里的return 412 为自定义的http状态码,默认为403,方便找出正确的盗链的请求
“rewrite ^/ http://leech.c1gstudio.com/leech.gif;”显示一张防盗链图片
“access_log off;”不记录访问日志,减轻压力
“expires 3d”所有文件3天的浏览器缓存- location ~* ^.+.(jpg|jpeg|gif|png|swf|rar|zip|css|js)$ {
- valid_referers none blocked *.c1gstudio.com *.c1gstudio.net localhost 208.97.167.194;
- if ($invalid_referer) {
- rewrite ^/ http://leech.c1gstudio.com/leech.gif;
- return 412;
- break;
- }
- access_log off;
- root /opt/lampp/htdocs/web;
- expires 3d;
- break;
- }
只充许固定ip访问网站,并加上密码
- root /opt/htdocs/www;
- allow 208.97.167.194;
- allow 222.33.1.2;
- allow 231.152.49.4;
- deny all;
- auth_basic “C1G_ADMIN”;
- auth_basic_user_file htpasswd;
将多级目录下的文件转成一个文件,增强seo效果
/job-123-456-789.html 指向/job/123/456/789.html- rewrite ^/job-([0-9]+)-([0-9]+)-([0-9]+).html$ /job/$1/$2/jobshow_$3.html last;
将根目录下某个文件夹指向2级目录
如/shanghaijob/ 指向 /area/shanghai/
如果你将last改成permanent,那么浏览器地址栏显是/location/shanghai/- rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
上面例子有个问题是访问/shanghai 时将不会匹配
- rewrite ^/([0-9a-z]+)job$ /area/$1/ last;
- rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
这样/shanghai 也可以访问了,但页面中的相对链接无法使用,
如./list_1.html真实地址是/area/shanghia/list_1.html会变成/list_1.html,导至无法访问。那我加上自动跳转也是不行咯
(-d $request_filename)它有个条件是必需为真实目录,而我的rewrite不是的,所以没有效果- if (-d $request_filename){
- rewrite ^/(.*)([^/])$ http://$host/$1$2/ permanent;
- }
知道原因后就好办了,让我手动跳转吧
- rewrite ^/([0-9a-z]+)job$ /$1job/ permanent;
- rewrite ^/([0-9a-z]+)job/(.*)$ /area/$1/$2 last;
文件和目录不存在的时候重定向:
- if (!-e $request_filename) {
- proxy_pass http://127.0.0.1;
- }
域名跳转
- server
- {
- listen 80;
- server_name jump.c1gstudio.com;
- index index.html index.htm index.php;
- root /opt/lampp/htdocs/www;
- rewrite ^/ http://www.c1gstudio.com/;
- access_log off;
- }
多域名转向
- server_name www.c1gstudio.com www.c1gstudio.net;
- index index.html index.htm index.php;
- root /opt/lampp/htdocs;
- if ($host ~ “c1gstudio.net”) {
- rewrite ^(.*) http://www.c1gstudio.com$1 permanent;
- }
三级域名跳转
- if ($http_host ~* “^(.*).i.c1gstudio.com$”) {
- rewrite ^(.*) http://top.yingjiesheng.com$1;
- break;
- }
域名镜向
- server
- {
- listen 80;
- server_name mirror.c1gstudio.com;
- index index.html index.htm index.php;
- root /opt/lampp/htdocs/www;
- rewrite ^/(.*) http://www.c1gstudio.com/$1 last;
- access_log off;
- }
某个子目录作镜向
- location ^~ /zhaopinhui {
- rewrite ^.+ http://zph.c1gstudio.com/ last;
- break;
- }
discuz ucenter home (uchome) rewrite
- rewrite ^/(space|network)-(.+).html$ /$1.php?rewrite=$2 last;
- rewrite ^/(space|network).html$ /$1.php last;
- rewrite ^/([0-9]+)$ /space.php?uid=$1 last;
discuz 7 rewrite
- rewrite ^(.*)/archiver/((fid|tid)-[w-]+.html)$ $1/archiver/index.php?$2 last;
- rewrite ^(.*)/forum-([0-9]+)-([0-9]+).html$ $1/forumdisplay.php?fid=$2&page=$3 last;
- rewrite ^(.*)/thread-([0-9]+)-([0-9]+)-([0-9]+).html$ $1/viewthread.php?tid=$2&extra=page%3D$4&page=$3 last;
- rewrite ^(.*)/profile-(username|uid)-(.+).html$ $1/viewpro.php?$2=$3 last;
- rewrite ^(.*)/space-(username|uid)-(.+).html$ $1/space.php?$2=$3 last;
- rewrite ^(.*)/tag-(.+).html$ $1/tag.php?name=$2 last;
给discuz某版块单独配置域名
- server_name bbs.c1gstudio.com news.c1gstudio.com;
- location = / {
- if ($http_host ~ news.c1gstudio.com$) {
- rewrite ^.+ http://news.c1gstudio.com/forum-831-1.html last;
- break;
- }
- }
discuz ucenter 头像 rewrite 优化
- location ^~ /ucenter {
- location ~ .*.php?$
- {
- #fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location /ucenter/data/avatar {
- log_not_found off;
- access_log off;
- location ~ /(.*)_big.jpg$ {
- error_page 404 /ucenter/images/noavatar_big.gif;
- }
- location ~ /(.*)_middle.jpg$ {
- error_page 404 /ucenter/images/noavatar_middle.gif;
- }
- location ~ /(.*)_small.jpg$ {
- error_page 404 /ucenter/images/noavatar_small.gif;
- }
- expires 300;
- break;
- }
- }
jspace rewrite
- location ~ .*.php?$
- {
- #fastcgi_pass unix:/tmp/php-cgi.sock;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
- location ~* ^/index.php/
- {
- rewrite ^/index.php/(.*) /index.php?$1 break;
- fastcgi_pass 127.0.0.1:9000;
- fastcgi_index index.php;
- include fcgi.conf;
- }
wordpress rewrite
- location / {
- index index.html index.php;
- if (-f $request_filename/index.html){
- rewrite (.*) $1/index.html break;
- }
- if (-f $request_filename/index.php){
- rewrite (.*) $1/index.php;
- }
- if (!-e $request_filename)
- {
- rewrite (.*) /index.php;
- }
- }
-
Embed flash into HTML page
Download swfobject from
Using tool to generate HTML page with swfobject
Setup the correct parameter
http://code.google.com/p/swfobject/downloads/list
http://code.google.com/p/swfobject/
http://www.bobbyvandersluis.com/swfobject/generator/
-
UnixBench 5.1.2 of CheapVPS Basic by Cripperz Prodigy
20$/year VPS from Cripperz Prodigy:
- 128MB guaranteed/256MB burstable memory
- 10GB storage
- 300GB/month data transfer
- OpenVZ/SolusVM
- 1 IP in Kansas City
- http://client.cripperz.sg/cart.php?a=confproduct&i=1
The result of UnixBench 5.1.2: 1238.1
========================================================================
BYTE UNIX Benchmarks (Version 5.1.2)System: Localhost: GNU/Linux
OS: GNU/Linux — 2.6.18-238.12.1.el5.028stab091.1 — #1 SMP Wed Jun 1 13:20:2
5 MSD 2011
Machine: i686 (unknown)
Language: en_US.utf8 (charmap=”UTF-8″, collate=”UTF-8″)
CPU 0: AMD Phenom(tm) II X4 965 Processor (6209.4 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT,
SYSCALL/SYSRET
CPU 1: AMD Phenom(tm) II X4 965 Processor (6401.2 bogomips)
Hyper-Threading, x86-64, MMX, Physical Address Ext, SYSENTER/SYSEXIT,
SYSCALL/SYSRET
09:49:14 up 1:37, 1 user, load average: 0.06, 0.04, 0.01; runlevel 2————————————————————————
Benchmark Run: Sun Jun 19 2011 09:49:14 – 10:17:15
2 CPUs in system; running 1 parallel copy of testsDhrystone 2 using register variables 14247935.3 lps (10.0 s, 7 samples)
Double-Precision Whetstone 2522.3 MWIPS (9.9 s, 7 samples)
Execl Throughput 2891.6 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 666914.8 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 212719.0 KBps (30.1 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 935761.0 KBps (30.0 s, 2 samples)
Pipe Throughput 1546190.6 lps (10.0 s, 7 samples)
Pipe-based Context Switching 291698.3 lps (10.0 s, 7 samples)
Process Creation 7359.3 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 4071.1 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 591.7 lpm (60.0 s, 2 samples)
System Call Overhead 1473204.0 lps (10.0 s, 7 samples)System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 14247935.3 1220.9
Double-Precision Whetstone 55.0 2522.3 458.6
Execl Throughput 43.0 2891.6 672.5
File Copy 1024 bufsize 2000 maxblocks 3960.0 666914.8 1684.1
File Copy 256 bufsize 500 maxblocks 1655.0 212719.0 1285.3
File Copy 4096 bufsize 8000 maxblocks 5800.0 935761.0 1613.4
Pipe Throughput 12440.0 1546190.6 1242.9
Pipe-based Context Switching 4000.0 291698.3 729.2
Process Creation 126.0 7359.3 584.1
Shell Scripts (1 concurrent) 42.4 4071.1 960.2
Shell Scripts (8 concurrent) 6.0 591.7 986.2
System Call Overhead 15000.0 1473204.0 982.1
========
System Benchmarks Index Score 964.4————————————————————————
Benchmark Run: Sun Jun 19 2011 10:17:15 – 10:45:29
2 CPUs in system; running 2 parallel copies of testsDhrystone 2 using register variables 28325265.0 lps (10.0 s, 7 samples)
Double-Precision Whetstone 5068.7 MWIPS (9.7 s, 7 samples)
Execl Throughput 4946.4 lps (30.0 s, 2 samples)
File Copy 1024 bufsize 2000 maxblocks 277714.0 KBps (30.0 s, 2 samples)
File Copy 256 bufsize 500 maxblocks 103640.2 KBps (30.0 s, 2 samples)
File Copy 4096 bufsize 8000 maxblocks 409976.7 KBps (30.0 s, 2 samples)
Pipe Throughput 2998921.2 lps (10.0 s, 7 samples)
Pipe-based Context Switching 574050.8 lps (10.0 s, 7 samples)
Process Creation 13024.9 lps (30.0 s, 2 samples)
Shell Scripts (1 concurrent) 7667.9 lpm (60.0 s, 2 samples)
Shell Scripts (8 concurrent) 1012.3 lpm (60.1 s, 2 samples)
System Call Overhead 2233174.8 lps (10.0 s, 7 samples)System Benchmarks Index Values BASELINE RESULT INDEX
Dhrystone 2 using register variables 116700.0 28325265.0 2427.2
Double-Precision Whetstone 55.0 5068.7 921.6
Execl Throughput 43.0 4946.4 1150.3
File Copy 1024 bufsize 2000 maxblocks 3960.0 277714.0 701.3
File Copy 256 bufsize 500 maxblocks 1655.0 103640.2 626.2
File Copy 4096 bufsize 8000 maxblocks 5800.0 409976.7 706.9
Pipe Throughput 12440.0 2998921.2 2410.7
Pipe-based Context Switching 4000.0 574050.8 1435.1
Process Creation 126.0 13024.9 1033.7
Shell Scripts (1 concurrent) 42.4 7667.9 1808.5
Shell Scripts (8 concurrent) 6.0 1012.3 1687.2
System Call Overhead 15000.0 2233174.8 1488.8
========
System Benchmarks Index Score 1238.1lzheng@Localhost:~/unixbench-5.1.2$