Mar 08

In a terminal console, do the following commands:

To stop apache2 for this session only:

1
 sudo /etc/init.d/apache2 stop

To remove apache2 permanently from startup scripts:

1
 sudo update-rc.d apache2 remove

To reinstate apache2 in the startup scripts:

1
 sudo update-rc.d apache2 defaults


Post to Twitter

Tagged with:
Feb 23

剛寫完 Clipbucket 2.0.91 後, 2.1測試版也推出了, 多了許多功能, 但也必須多加一些套件, 以下是要新加的.

1. cURL

<cce code=”shell”>

sudo apt-get install curl php5-curl

</code>

再重新啟動 Apache Server

<cce code=”shell”>

sudo /etc/init.d/apache2 restart

</code>

這樣就可以裝了.

另外附加的 PHPShield 現在查到的方法是以下. (待證)

Download phpshield from here

After download unzip and upload the file phpshield.5.2.lin in to /usr/lib/php5/20060613+lfs folder

Now you need to edit the php.ini file using the following command

sudo vi / etc/php5/apache2/php.ini

or

sudo nano / etc/php5/apache2/php.ini

add the following line at the end of the file

extension=phpshield.5.2.lin

Save and exit the file

Now you need to restart apache server using the following command

sudo /etc/init.d/apache2 restart

That’s it now check your phpmotion

I hope this helps

Post to Twitter

Feb 11

有天在尋找類似 Youtube 的架站系統, 比較了幾個, 但最後覺得 Clipbucket 在功能, 安裝便利性和需求都比較簡單入手. 而且它還是免費開放程式碼的PHP系統. 我就想來研究一下.雖然安裝過程很容易, 但是在環境的設定, 我可是費了很多工年才研究出正確的步驟.

Clipbucket 網站實在是很爛, 教學文件實在是什麼都沒有, 只有 blah blah blah…. 所以我就把我從頭到尾安裝到成功轉檔的步驟記錄下來.  現在最近版本是 v2.0.91 可以在這裡下載: http://sourceforge.net/projects/clipbucket/files/ClipBucket%20v2/

首先, 我不是 Linux guy, 所以我花了很多時間在整理環境和安裝需要的套件. 在開始前, 我們先看一下它的需求.

Requirements

  1. PHP 5.2.x & MySql 5.x.x
  2. PHP with Background Processing and Exec Enabled
  3. GD Library For Captchas and Other Image Manuplation
  4. FFMPEG – FLVTOOL2 – MP4Box

就這樣. :mrgreen: 很清楚吧. 整個教學就是幾行. 但是我裝了N次都少一些模組. 所以下面就是完整的教學說明.

首先, 這個說明是在 ubuntu server 10.10 32-bit 上執行的. 而且我是在 VMware ESXi 4.1 上測試的. 等寫完後再來測實機, 畢竟轉檔是很耗資源. 硬體一定要夠力.

Step I: Environmental readiness

最快最簡單的方式就是安裝 Ubuntu Server 再安裝 LAMP Server. 這樣一來基本環境 Apache 2, MySQL and PHP 5 都齊了. 剩下來就大家都覺得麻煩的 FFMPEG. 記得還有 SSH 要開啟.

第二步就是要安裝 medibuntu repository. Medibuntu 是 (Multimedia, Entertainment & Distractions In Ubuntu) 的簡稱. 由於其中包括了第三方和有專利的未開放原始碼的套始, 所以不能一起包在一般的釋出來.

加入 Medibuntu 的 repository

1
sudo wget --output-document=/etc/apt/sources.list.d/medibuntu.list http://www.medibuntu.org/sources.list.d/$(lsb_release -cs).list && sudo apt-get --quiet update && sudo apt-get --yes --quiet --allow-unauthenticated install medibuntu-keyring && sudo apt-get --quiet update

安裝 mediabuntu

1
sudo apt-get --yes install app-install-data-medibuntu apport-hooks-medibuntu

安裝libdvdcss2 (DVD 套件)

1
sudo apt-get install libdvdcss2

加入原生不支援的解碼

1
sudo apt-get install w32codecs

* 註: 如果是在64位元系統上, 打 w64codecs

安裝必需的解碼器

1
2
3
4
5
sudo apt-get update
sudo apt-get install build-essential git-core checkinstall yasm texi2html libfaac-dev libjack-jackd2-dev libmp3lame-dev libopencore-amrnb-dev libopencore-amrwb-dev libsdl1.2-dev libtheora-dev libva-dev libvdpau-dev libvorbis-dev libvpx-dev libx11-dev libxfixes-dev libxvidcore-dev zlib1g-dev
sudo apt-get install libxvidcore-dev libmp3lame-dev libfaac-dev libfaac-dev libx264-dev
sudo apt-get install libavcodec-unstripped-52 libavdevice-unstripped-52 libavformat-unstripped-52 libavutil-unstripped-50 libpostproc-unstripped-51 libswscale-unstripped-0
sudo apt-get install liblame0 libfaad2 libfaac-dev libxvidcore-dev liba52-0.7.4 liba52-0.7.4-dev libdts-dev checkinstall

安裝 x264

1
2
3
4
5
6
sudo git clone git://git.videolan.org/x264.git
cd x264/
sudo ./configure
sudo make
sudo checkinstall --pkgname=x264 --pkgversion="2:0.$(grep X264_BUILD x264.h -m1 | cut -d' ' -f3).$(git rev-list HEAD | wc -l)+git$(git rev-list HEAD -n 1 | head -c 7)" --backup=no --deldoc=yes --fstrans=no --default
sudo make install

安裝 flvtool2

1
sudo apt-get install flvtool2

安裝mp4box

1
sudo apt-get install gpac

安裝 FFMPEG

1
sudo apt-get install ffmpeg

最後就是安裝 qt-faststart (額外選項)

1
2
make tools/qt-faststart
sudo checkinstall --pkgname=qt-faststart --pkgversion="$(./version.sh)" --backup=no --deldoc=yes --fstrans=no --default install -D -m755 tools/qt-faststart /usr/local/bin/qt-faststart

II. 下載 clipbucket 2.0.91

Sourceforge 上有他們的 source: http://sourceforge.net/projects/clipbucket/files/ClipBucket%20v2/

回到 Home directory 下

先安裝 unzip

1
sudo apt-get install unzip

下載 Clipbucket 2.0.91

1
2
3
4
5
6
7
8
9
10
11
12
cd
wget http://downloads.sourceforge.net/project/clipbucket/ClipBucket%20v2/clipbucket_2.0.91.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fclipbucket%2Ffiles%2FClipBucket%2520v2%2F&ts=1297412770&use_mirror=iweb
mv clipbucket_2.0.91.zip\?r\=http\:%2F%2Fsourceforge.net%2Fprojects%2Fclipbucket%2Ffiles%2FClipBucket%20v2%2F clipbucket2.0.91.zip
mkdir clipbucket
unzip clipbucket2.0.91.zip -d clipbucket
cd clipbucket/
cd upload/
sudo cp -r * /var/www/
sudo cp .htaccess /var/www/
cd ..
cd update_209_2091/
sudo cp -r * /var/www/

最後把 Apache 的內建測試頁幹掉

1
2
cd /var/www/
sudo rm index.html

還要記得把 Apache 的 URL-rewrite 打開

1
2
sudo a2enmod rewrite
sudo nano /etc/apache2/sites-available/default

找AllowOverride None 改成 AllowOverride All

之後再重新啟動 Apache server

1
sudo /etc/init.d/apache2 restart

III. 安裝 Clipbucket

如果是在測式環境下,簡單一點就是加一個 DNS 名在你的 host 檔案裡. 以我的例子, 我的 vm 抓到的內部 IP 是 10.175.0.144, 我就在 Windows 7 裡, 修改 C:\Windows\System32\drivers\etc 裡頭的 hosts 檔. 在下面加入10.175.0.144     cb.chaoman.com

儲存後, 去 Browser 裡打 http://cb.chaoman.com 就會看到以下的安裝畫面了:

我本身 database 也不是很上手, 所以要借助一下 phpMyAdmin 來管理一下資料庫. 所以一併安裝

安裝 phpMyAdmin

1
sudo apt-get install phpmyadmin

安裝過程中會問 web server, 選 apache2 就好了. 之後再打入自己的密碼就可以了. 安裝成功的話, 在剛加入的 host 名中打 /phpMyAdmin 就會看到了

我們建立一個叫作 clipbucket 的資料庫, 如下圖示:


回過到到剛才 Clipbucket 的安裝畫面, 按下 Fresh Install, 之後再按 I Accept 後就會遇到下面權限問題.

Chmod Issue

照下面的打就可以給適當的寫入權限了

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
cd /var/www/
sudo chmod 777 files/
sudo chmod 777 files/conversion_queue/
sudo chmod 777 files/logs/
sudo chmod 777 files/original/
sudo chmod 777 files/temp/
sudo chmod 777 files/thumbs/
sudo chmod 777 files/videos/
sudo chmod 777 files/mass_uploads/
sudo chmod 777 files/temp/install.me
sudo chmod 777 images/
sudo chmod 777 images/avatars/
sudo chmod 777 images/backgrounds/
sudo chmod 777 images/category_thumbs
sudo chmod 777 images/groups_thumbs/
sudo chmod 777 cache/
sudo chmod 777 install/
sudo chmod 777 includes/

再按一下 Recheck, 等到全部變成綠色就可以了. 按 Continue 繼續

等到要打入資料庫設定時, 打入以下設定

Host
localhost -> 剛才設過的 DNS 名或本身網址, 本地是 localhost

Database Name
clipbucket -> 剛才用 phpmyadmin 作好了

Database User
root

Database Password
xxxxx        -> 安裝 Ubuntu 時設的

Database Prefix
cb_          -> 不用動

按下 Check Connection, 如果沒問題, 再按 Continue Installation, 最後安裝就完成了. 如圖下:

Installation Complete

IV. PHP 環境的設定

由於影片檔的 size  都滿大的, PHP 預設的上傳限制是 8 MB.  我們要把一些流量限制加大. 請打入以下指今

1
sudo nano /etc/php5/apache2/php.ini

修改以下變數. (如果想要找, 按 ctrl + w, 如果習慣用 vi 的, 就用 / )

1
2
3
4
5
max_execution_time = 3000
max_input_time = 3000
memory_limit = 512M // 請視環境而設
post_max_size = 400M
upload_max_filesize = 400M

設完後, 按 ctrl + x, 再按 y, 再按 enter 就可以儲存了. (感覺好像是電玩密技)

最後把 Apache server 重新起動一下.

1
sudo /etc/init.d/apache2 restart

V. Clipbucket 設定

預設的管理員帳號和密碼是 admin / admin , 後台網址是加上 /admin_area/

最後別忘了把 includes 權限改過

1
sudo chmod 755 includes/

在 browser 下打 http://cb.chaoman.com/admin_area/ 登入後就會看到後台介面了.

雖然以上的安裝手法不是很漂亮, 但是安裝完, 去左手邊的 Tool Box 裡的 Server Modules Info 就可以看到所有必需的模組都安裝好了. :-D

Server Modules List

最後我們要設定的, 就是 cron job 的參數. cron job 我本來只知道是排程的東西, 但說明裡完全沒說 cron job 要怎麼設, 如果沒設你的影片不會自動轉檔. 所以一定要設.  去左手邊選項裡最後一個 Clipbucket Helper 裡有 Cron Jobs 的設定. 我把它貼到這裡來.

* * * * * php -q /var/www/actions/video_convert.php >/dev/null 2>&1
* * * * * php -q /var/www/actions/verify_converted_videos.php >/dev/null 2>&1
0 0,12,13 * * * php -q /var/www/actions/update_cb_stats.php >/dev/null 2>&1

設定方法如下

1
2
3
4
5
6
sudo crontab -e
2
貼上剛才上面3行
按 ctrl + x
Y
按 enter

* 注意: 網上有人建議 cron job 的最後一行最好要換行.  所以我們把游標移去第3行最後再按 enter 跳行就可以了.

最後就可以到前端介面上傳影片了. 但後端先不要關掉, 原因是要看轉檔的進度. 影片上傳後, 去剛剛 cron jobs 裡, 會看到上次執行的時間. 如果看到是從沒執行 (never run) 就是 cron jobs 設錯了.

再來去 Tool Box 裡的 Conversion Queue Manager, 就可以看到轉檔進度, Done 就是完了. 再去前端或是 video 裡就可以看到剛才上傳的影片. 這樣子你也有自己的 youtube 網站了.

CB 前端介面

如果在安裝上有什麼問題, 我儘量回答. 最後附上一個測試的網站: http://chaoman.dyndns.tv/clipbucket/

資料來源:

  1. http://ubuntuforums.org/showthread.php?t=786095
  2. https://help.ubuntu.com/community/Medibuntu
  3. http://drupal.org/node/134439

Post to Twitter

Tagged with:
Jan 30

好不容易把 Hyper-V 裝完, 可以開始玩虛擬機器來研究 clipbucket. 但安裝到一半, 出現一個紅色的畫面.

No Network Interfaces Detected

我第一個直覺是 – 悶, 舊的網卡都不支援. 自從知道舊 3com 卡和 Intel Pro 10/100 在 Windows 2008 都不能順利被找到, Hyper-V Server 上應該也是找不到把. 所以下午就驅車跑去 Palo Alto 的 Fry’s 裡買個最便宜不到$10元的TrendNet的螃蟹卡 RealTek8169. 雖然新卡是馬上可以被找到, 但是在安裝時, 還是出現找不到網路介面的問題. 我想 Hyper-V 實在是不支援很多東西, 免費果然要克服很多問題.

請出了谷歌大神, 果然大家都遇到一樣的問題, 只是沒人像我傻傻去買了張新卡才發現問題不是這樣. Ben Armstrong, Microsoft 的虛擬環境專案經理在他的 Virtual PC Guy’s Blog 上有說明解決問題. 他的 blog 是: http://blogs.msdn.com/b/virtual_pc_guy/archive/2010/10/21/installing-ubuntu-server-10-10-on-hyper-v.aspx

而且在他 blog 上還有詳細的安裝步驟, 真是應該先看看的. 解決方面是先略過那個問題, 安裝完登入後再回過頭來加入驅動程式.

登入在 bash 下打入指令:

1
 sudo vi /etc/initramfs-tools/modules

打入密碼, 在這個檔案最下面加入以下幾行

hv_vmbus

hv_storvsc

hv_blkvsc

hv_netvsc

按 ESC 後, 再打 :x 儲存後, 要更新initramfs

1
 sudo update-initramfs –u

再重開機一次

1
 sudo shutdown -r now

確定 HV 驅動裝好沒, 可以鍵入以下指令. 在最下行可以看到有關 HV 等的東西

1
lsmod
ubuntu_lsmod

ubuntu_lsmod

之後再打入

1
 ifconfig -a

就可以看到到之前分配給這台虛擬機的網卡了, 但還是要設定一下

ubuntu_ifconfig-a

ubuntu_ifconfig-a

參考一下 ifconfig -a 的結果, 看一下網卡的名字, 我的情況是 eth0 & eth1 打開 /etc/network/interfaces 來加入

1
 sudo vi /etc/network/interfaces

裡頭, 可以加入以下的參據

如果是自動 DHCP , 就用下面

Auto eth0
iface eth0 inet dhcp

固定 IP 的話, 就多加IP位址等資料

Auto eth0
iface eth0 inet static
address xxx.xxx.xxx.xxx
netmask xxx.xxx.xxx.xxx
Gateway xxx.xxx.xxx.xxx

最後再重開, 或是打入以下指令就有網路囉.

1
 sudo /etc/init.d/networking restart

Post to Twitter

Tagged with:
Jan 30

雖說HVREMOTE小工具郤實能解決一些權限的問題, 但是我還是發現這個問題. HVREMOTE 下載點: http://code.msdn.microsoft.com/HVRemote

但是我還是遇到了這個問題:

You do not have the required permission to complete this task. Contact the administrator of the authorization policy for the computer

但我忘著解決這問題而忘了截圖了.  但 HVREMOTE 工具的開發者 John Howard 在他的部落格上有詳細的解決方法. 我只提出大概步驟. John Howard 的 blog: http://blogs.technet.com/b/jhoward/archive/2008/03/28/part-1-hyper-v-remote-management-you-do-not-have-the-requested-permission-to-complete-this-task-contact-the-administrator-of-the-authorization-policy-for-the-computer-computername.aspx

原則上要把現在登入的帳號在 DCOM 裡加入, 並選取相關權限. 重開機後就可以連了. 連結後就可以看到一些關於 Hyper-V 虛擬機器建立的選項. 讚.

但是我在裝 ubuntu server 時又遇到問題.

Post to Twitter

preload preload preload