顯示具有 Ubuntu 標籤的文章。 顯示所有文章
顯示具有 Ubuntu 標籤的文章。 顯示所有文章

2011年4月7日 星期四

掛載virtualbox 分享資料夾方法

mount -t vboxsf RubyOnRails /root/ror

自動掛載
vi /etc/fstab
RubyOnRails /root/ror vboxsf

強制移除套件

我以前也有遇過需要強制移除套件的情況,那時候我是這樣作的:
1.備份status
sudo cp /var/lib/dpkg/status /var/lib/dpkg/status.back

2.打開
sudo gedit /var/lib/dpkg/status

3.搜尋"Package: ubuntu-tweak",把那一整段刪除(刪到下個"Package: xxx"之前)
4.存檔,重新載入套件庫。

2011年2月17日 星期四

更換apt-get抓取軟體的url

.1 備份 sources.list

sudo cp /etc/apt/sources.list /etc/apt/sources.list.ORG

2.打開 sources.list

sudo vi /etc/apt/sources.list

3.變更成其他國家的伺服器
在 vi 用下面指令把 tw 換成 us

:1,$s/tw/us/g

4.儲存 source.list

:wq!

5.更新套件清單

sudo apt-get update

2011年2月16日 星期三

在apache2設定數個網站

這個記錄是以Apache2作為HTTP daemon,在Apache2上設定數個網站。因為Apache2本來就在設計上支援這個目的。

Apache2在預設安裝後, 一般使用/var/www/作為網站的資夾料,看一下裡面會發現一個index.html檔案。

但我們既然要在這台伺服器上跑幾個網站,就得用一個資料夾有系統地存放。

我選擇在/home下建立一個叫www的資料夾,然後再在上面因應不同網站建不同的資料夾。

sudo mkdir /home/www

設定這個資料夾所屬的群組和擁有者

sudo chown www-data /home/www
sudo chgrp www-data /home/www

為新的網站建立資料夾

sudo mkdir /home/www/notes.antonyho.net

這些資料夾是用作存放CGI或者log的

sudo mkdir /home/www/notes.antonyho.net/cgi-bin
sudo mkdir /home/www/notes.antonyho.net/logs
sudo mkdir /home/www/notes.antonyho.net/htdocs

設定這個網站的擁有者為owner,設定www-data為資料夾的群組以方便儲取。

sudo chown antony -R /home/www/notes.antonyho.net
sudo chgrp www-data -R /home/www/notes.antonyho.net


好,到戲肉了。
Apache2建立virtual host的方式是在 /etc/apache2/sites-available/ 這個資料夾裡建一個設定檔,在裡面把您網站的資料夾,存取限制設定好。

假設我的網站是notes.antonyho.net,我就在 /etc/apache2/sites-available/ 裡建一個以網址命名的設定檔。

sudo touch /etc/apache2/sites-available/notes.antonyho.net


又或者利用預設的設定檔再作修改


sudo cp /etc/apache2/sites-available/default /etc/apache2/sites-available/notes.antonyho.net

修改這個檔案

sudo nano /etc/apache2/sites-available/notes.antonyho.net

以下是一個可供設考的設定檔


ServerAdmin admin@notes.antonyho.net #網站負責人的電郵
ServerName notes.antonyho.net #網址
ServerAlias notes.antonyho.net #如果網站有縮寫網址可在這裡設定

DocumentRoot /home/www/notes.antonyho.net #改為你網站用的資料夾
#這裡記得在資料夾尾加/
Options Indexes FollowSymLinks MultiViews
#上面是設定資料夾的一些屬性
#Indexes,訪客可以要求資料夾的檔案清單,這個要小心設定使用與否。
AllowOverride None
Order allow,deny
allow from all


ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ #設了這個就可以使用CGI

AllowOverride None
Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
Order allow,deny
Allow from all


ErrorLog /home/www/notes.antonyho.net/logs/error.log #error log的位置

# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog /var/log/apache2/access.log combined #access log的位置

Alias /htdocs/ "/home/www/notes.antonyho.net/htdocs/"

Options Indexes MultiViews FollowSymLinks
AllowOverride None
Order deny,allow
Deny from all
Allow from 127.0.0.0/255.0.0.0 ::1/128




設定好後儲存。
然後啟用這個網站。

sudo a2ensite hkuoshard.com

重載Apache2的設定

sudo /etc/init.d/apache2 reload



提DNS設定指向到這個伺服器後,並把網站的檔案存到/home/www/notes.antonyho.net,訪問notes.antonyho.net該會正常顯示到網站囉。


我在設定時也是主要參考下面這個英文的Debian管理教學,而我使用的是Ubuntu Server。
http://www.debian-administration.org/articles/412

2011年2月10日 星期四

linux找出符合字串的字複製到新的檔案

cat production.log | grep '19064' > 19064read.log

2010年11月3日 星期三

Ubuntu 設定固定 IP 和 Proxy

vi /etc/network/interfaces

一、單網卡單 IP
auto eth0 ## 重要,這一行一定要設定
iface eth0 inet static
address [IP] ## 請將 [IP] 換成你要的 IP
netmask 255.255.255.0
gateway 192.168.1.1

# sudo /etc/init.d/networking restart

# export http_proxy=http://帳號:密碼@代理伺服器:port