Archive

文章標籤 ‘uBuntu’

在現有Apache2再安裝新的module – mod_wsgi.so

2010年2月12日 尚無評論

我在開發機上已經先安裝了Apache2,現在需要讓Python能在Apache上執行,得使用一個module,這裡使用wsgi這個module,但得手動make及install
底下是我的過程:

一、到wsgi官網下載wsgi的source code (我是下載現在的最新3.1版,不知道n年後會是更新到幾版^^)
在我的home目錄,執行 (就直接放在home目錄吧)


$ sudo -c wget http://modwsgi.googlecode.com/files/mod_wsgi-3.1.tar.gz

二、下載後,解壓縮:(我這裡會直接解到mod_wsgi-3.1目錄)

$ tar xvfz mod_wsgi-3.1.tar.gz

※注意唷,我現在是3.1,之後是多少~~不知道~~~

三、進入mod_wsgi-3.1目錄吧,要執行底下的指令來確認環境

$ ./configure

我會寫這篇,就是因為在這裡卡到了~,因為我出現一堆apxs找不到的錯誤訊息
上網再找,總算在Apache apxs這則討論找到解決的方法~

因為我是先安裝了Apache2,並沒有source code,所以wsgi在偵測環境時,沒有可用的原始檔
當然我也有用

sudo apt-cache search apxs

來看apxs會是在哪個pakage裡,但還是列了很多,不確定我該裝哪一個,索性還是照著Apache apxs這則討論直接安裝apache2-threaded-dev吧


$ sudo apt-get install apache2-threaded-dev

(老實說,我還沒找到這個安裝後是安裝到哪個位置,不管,晚一點再找吧~)

然後再回到我home下的mod_wsgi-3.1目錄
再次檢查wsgi需要的環境
這回就全找到了
沒有錯誤啦!!!

好,直接執行下面的指令吧

make

照手冊說就是Building The Source Code
但我執行後還沒看到mod_wsgi.so呀
因為,還需要安裝~~
正是底下的指令


$ sudo make install

記住,要以 root 的身份執行呀~

這時一切都ok了,剩下最後一步,讓Apache載入這個mod_wsgi!!

我的這個Apache2因為是安裝在uBuntu 9.10 desktop裡,在Apache的設定位置較不一樣
如下:

$ cd /etc/apache2/mods-available
$ sudo vim wsgi_module.load

然後編輯就是完全一樣的了

LoadModule wsgi_module /usr/lib/apache2/modules/mod_wsgi.so

這個mod_wsgi.so絕對位置,請依照實際情況給予正確的位置哦,可能不同的server,放的位置會不同吧~

$ cd /etc/apache2/mods-enabled
$ sudo ln -s ../mods-available/wsgi_module.load .

好了,再重啟一下Apache吧!!

sudo /etc/init.d/apache2 stop
sudo /etc/init.d/apache2 start

就OK了!!

之後,要再實做設定時,再把這篇補齊嘍~

Categories: Python, uBuntu Tags: , ,

Ubuntu常用命令與技巧

2010年2月12日 尚無評論

Ubuntu常用命令與技巧

sudo apt-get install 軟體名 安裝軟體命令
sudo nautilus 打開文件(有root權限)
su root 切換到 “root"

ls 列出當前目錄文件(不包括隱含文件)
ls -a 列出當前目錄文件(包括隱含文件)
ls -l 列出當前目錄下文件的詳細資訊

cd .. 回當前目錄的上一級目錄
cd – 回上一次所在的目錄
cd ~ 或 cd 回當前使用者的宿主目錄
mkdir 目錄名 創建一個目錄
rmdir 空目錄名 刪除一個空目錄
rm 文件名 文件名 刪除一個文件或多個文件
rm -rf 非空目錄名 刪除一個非空目錄下的一切

mv 路經/文件 /經/文件 移動相對路經下的文件到絕對路經下
mv 文件名 新名稱 在當前目錄下改名
find 路經 -name “字符串" 搜尋路經所在範圍內滿足字符串匹配的文件和目錄

fdisk fdisk -l 查看系統分區資訊
fdisk fdisk /dev/sdb 為一塊新的SCSI硬碟進行分區
chown chown root /home 把/home的屬主改成root使用者
chgrp chgrp root /home 把/home的屬組改成root組

Useradd 創建一個新的使用者
Groupadd 組名 創建一個新的組
Passwd 使用者名 為使用者創建密碼
Passwd -d使用者名 刪除使用者密碼也能登陸
Passwd -S使用者名 查詢賬號密碼
Usermod -l 新使用者名 老使用者名 為使用者改名
Userdel–r 使用者名 刪除使用者一切

tar -c 創建包 –x 釋放包 -v 顯示命令過程 –z 代表壓縮包
tar –cvf benet.tar /home/benet 把/home/benet目錄打包
tar –zcvf benet.tar.gz /mnt 把目錄打包並壓縮
tar –zxvf benet.tar.gz 壓縮包的文件解壓恢復
tar –jxvf benet.tar.bz2 解壓縮

make 編譯
make install 安裝編譯好的源碼包
reboot Init 6 重啟LINUX系統
Halt Init 0 Shutdown –h now 關閉LINUX系統

uname -a 查看內核版本
cat /etc/issue 查看ubuntu版本
lsusb 查看usb設備
sudo ethtool eth0 查看網卡狀態
cat /proc/cpuinfo 查看cpu資訊
lshw 查看當前硬體資訊
sudo fdisk -l 查看磁盤資訊
df -h 查看硬碟剩余空間
free -m 查看當前的記憶體使用情況
ps -A 查看當前有哪些進程
kill 進程號(就是ps -A中的第一列的數字)或者 killall 進程名( 殺死一個進程)
kill -9 進程號 強制殺死一個進程

常用apt命令:

apt-cache search package 搜索包
apt-cache show package 獲取包的相關資訊,如說明、大小、版本等
sudo apt-get install package 安裝包
sudo apt-get install package – – reinstall 重新安裝包
sudo apt-get -f install 修復安裝"-f = –fix-missing"
sudo apt-get remove package 刪除包
sudo apt-get remove package – – purge 刪除包,包括刪除配置文件等
sudo apt-get update 更新源
sudo apt-get upgrade 更新已安裝的包
sudo apt-get dist-upgrade 昇級系統
sudo apt-get dselect-upgrade 使用 dselect 昇級
apt-cache depends package 了解使用依賴
apt-cache rdepends package 是查看該包被哪些包依賴
sudo apt-get build-dep package 安裝相關的編譯環境
apt-get source package 下載該包的源代碼
sudo apt-get clean && sudo apt-get autoclean 清理無用的包
sudo apt-get check 檢查是否有損坏的依賴

清理所有軟體緩存(即緩存在/var/cache/apt/archives目錄里的deb包 )
sudo apt-get clean

刪除系統不再使用的孤立軟體
sudo apt-get autoremove
或指定軟體
sudo apt-get autoremove some_package_name

 

(若學到其他的再持續修改此篇)

Categories: uBuntu Tags:

uBuntu設定vsftpd

2010年2月6日 尚無評論

一、安裝vsftpd:

sudo aptitude install vsftpd

二、編輯vsftpd設定檔:

sudo vim /etc/vsftpd.conf

三、設定檔範例

# Example config file /etc/vsftpd.conf
#
# The default compiled in settings are fairly paranoid. This sample file
# loosens things up a bit, to make the ftp daemon more usable.
# Please see vsftpd.conf.5 for all compiled in defaults.
#
# READ THIS: This example file is NOT an exhaustive list of vsftpd options.
# Please read the vsftpd.conf.5 manual page to get a full idea of vsftpd's
# capabilities.
#
#
# Run standalone? vsftpd can run either from an inetd or as a standalone
# daemon started from an initscript.
listen=YES
#
# Run standalone with IPv6?
# Like the listen parameter, except vsftpd will listen on an IPv6 socket
# instead of an IPv4 one. This parameter and the listen parameter are mutually
# exclusive.
#listen_ipv6=YES
#
# Allow anonymous FTP? (Beware - allowed by default if you comment this out).
anonymous_enable=NO
#
# Uncomment this to allow local users to log in.
local_enable=YES
#
# Uncomment this to enable any form of FTP write command.
write_enable=YES
#
# Default umask for local users is 077. You may wish to change this to 022,
# if your users expect that (022 is used by most other ftpd's)
local_umask=022
#
# Uncomment this to allow the anonymous FTP user to upload files. This only
# has an effect if the above global write enable is activated. Also, you will
# obviously need to create a directory writable by the FTP user.
#anon_upload_enable=YES
#
# Uncomment this if you want the anonymous FTP user to be able to create
# new directories.
#anon_mkdir_write_enable=YES
#
# Activate directory messages - messages given to remote users when they
# go into a certain directory.
dirmessage_enable=YES
#
# Activate logging of uploads/downloads.
xferlog_enable=YES
#
# Make sure PORT transfer connections originate from port 20 (ftp-data).
connect_from_port_20=YES
#
# If you want, you can arrange for uploaded anonymous files to be owned by
# a different user. Note! Using "root" for uploaded files is not
# recommended!
#chown_uploads=YES
#chown_username=whoever
#
# You may override where the log file goes if you like. The default is shown
# below.
xferlog_file=/var/log/vsftpd.log
#
# If you want, you can have your log file in standard ftpd xferlog format
xferlog_std_format=YES
#
# You may change the default value for timing out an idle session.
idle_session_timeout=600
#
# You may change the default value for timing out a data connection.
#data_connection_timeout=120
#
# It is recommended that you define on your system a unique user which the
# ftp server can use as a totally isolated and unprivileged user.
#nopriv_user=ftpsecure
#
# Enable this and the server will recognise asynchronous ABOR requests. Not
# recommended for security (the code is non-trivial). Not enabling it,
# however, may confuse older FTP clients.
#async_abor_enable=YES
#
# By default the server will pretend to allow ASCII mode but in fact ignore
# the request. Turn on the below options to have the server actually do ASCII
# mangling on files when in ASCII mode.
# Beware that on some FTP servers, ASCII support allows a denial of service
# attack (DoS) via the command "SIZE /big/file" in ASCII mode. vsftpd
# predicted this attack and has always been safe, reporting the size of the
# raw file.
# ASCII mangling is a horrible feature of the protocol.
#ascii_upload_enable=YES
#ascii_download_enable=YES
#
# You may fully customise the login banner string:
#ftpd_banner=Welcome to OIpingo FTP service.
#
# You may specify a file of disallowed anonymous e-mail addresses. Apparently
# useful for combatting certain DoS attacks.
#deny_email_enable=YES
# (default follows)
#banned_email_file=/etc/vsftpd.banned_emails
#
# You may restrict local users to their home directories. See the FAQ for
# the possible risks in this before using chroot_local_user or
# chroot_list_enable below.
#chroot_local_user=YES
#
# You may specify an explicit list of local users to chroot() to their home
# directory. If chroot_local_user is YES, then this list becomes a list of
# users to NOT chroot().
chroot_list_enable=YES
# (default follows)
chroot_list_file=/etc/vsftpd.chroot_list
#
# You may activate the "-R" option to the builtin ls. This is disabled by
# default to avoid remote users being able to cause excessive I/O on large
# sites. However, some broken FTP clients such as "ncftp" and "mirror" assume
# the presence of the "-R" option, so there is a strong case for enabling it.
#ls_recurse_enable=YES
#
#
# Debian customization
#
# Some of vsftpd's settings don't fit the Debian filesystem layout by
# default. These settings are more Debian-friendly.
#
# This option should be the name of a directory which is empty. Also, the
# directory should not be writable by the ftp user. This directory is used
# as a secure chroot() jail at times vsftpd does not require filesystem
# access.
secure_chroot_dir=/var/run/vsftpd
#
# This string is the name of the PAM service vsftpd will use.
pam_service_name=vsftpd
#
# This option specifies the location of the RSA certificate to use for SSL
# encrypted connections.
rsa_cert_file=/etc/ssl/certs/ssl-cert-snakeoil.pem
# This option specifies the location of the RSA key to use for SSL
# encrypted connections.
rsa_private_key_file=/etc/ssl/private/ssl-cert-snakeoil.key


#可以接受的最大clinet可連線的數目
#max_clients=20
#每個ip的最大連線數目
#max_per_ip=15

另外設定一個ftp檔案管理者
目標:
1.除特定帳號外,其他人一律不許離開家目錄。
2.設定一個帳號使可以進入其他帳號之家目錄,並可以任意增刪檔案。

實做:
1.sudo vim /etc/vsftpd.conf 加入下列參數

chroot_local_user=YES
chroot_list_enable=YES
chroot_list_file=/etc/vsftpd/vsftpd.chroot_list

2. 新增一組帳號 ftpadmin

sudo adduser ftpadmin

3. 設定密碼

sudo passwd ftpadmin

4.使ftpadmin可以增刪任意資料,並更改其家目錄且設定不允許他使用bash(無法登入ssh)

sudo vim /etc/passwd

找到ftpadmin編輯:

ftpadmin:x:0:0:Ftp Admin,,,:/:/bin/false

相關指令:
重啟vsftp

sudo /etc/init.d/vsftpd restart

啟動

sudo /etc/init.d/vsftpd start

停止

sudo /etc/init.d/vsftpd stop

#移除vsftpd

sudo aptitude remove vsftpd
Categories: uBuntu Tags: , ,