6.25.2012

proftpd - install ~ create a ftp account

setup

1. update sources.list due to EOL of Debian 4

$ vi /etc/apt/sources.list
#deb     http://ftp.nz.debian.org/debian lenny main
#deb-src http://ftp.nz.debian.org/debian lenny main
#deb     http://security.debian.org lenny/updates main contrib
#deb-src http://security.debian.org lenny/updates main contrib
deb http://archive.debian.org/debian/ lenny main non-free contrib
deb-src http://archive.debian.org/debian/ lenny main non-free contrib
deb http://archive.debian.org/debian-volatile lenny/volatile main contrib non-free
deb-src http://archive.debian.org/debian-volatile lenny/volatile main contrib non-free
deb http://archive.debian.org/debian-backports lenny-backports main contrib non-free
deb http://archive.debian.org/debian-security lenny/updates main
$ apt-get update
2. install proftpd

$ apt-get install proftpd
(choose standalone from standalone or inet)
3. configure proftpd

$ vi /etc/proftpd.proftpd.conf

DefaultRoot                     ~

<Limit LOGIN>
AllowUser USER-A
AllowUser USER-B
DenyALL
</Limit>

see /etc/proftpd/proftpd.conf for more information.

4. create a ftp account

$ useradd <USER-NAME> -s /bin/false -d <PATH-TO-DIR>
$ passwd <USER-NAME>
(type password twice)


how to add a ftp account

1. create a new account

$ useradd <USER-NEW> -s /bin/false -d <PATH-TO-DIR>
$ passwd <USER-NEW>
(type password twice)
* this user can't ssh into a machine as its shell is "/bin/false".

2. allow it to ftp-login

$ vi /etc/proftpd/proftpd.conf (or open the file by another software)
<Limit LOGIN>
AllowUser <USER-A>
AllowUser <USER-B>
AllowUser <USER-NEW>      <----- add this line
DenyALL
</Limit>
3. load new configuration by restarting daemon

$ /etc/init.d/proftpd restart

how to delete a ftp account

1. delete a ftp account

$ userdel <USER-NEW>

2. disallow it to ftp-login

$ vi /etc/proftpd/proftpd.conf (or open the file by another software)
<Limit LOGIN>
AllowUser <USER-A>
AllowUser <USER-B>
AllowUser <USER-NEW>      <----- delete this line
DenyALL
</Limit>

3. load new configuration by restarting daemon

$ /etc/init.d/proftpd restart

4.27.2012

WordPress (1)

27th Apr 2012

UbuntuにWordPressをインストールした時のメモ。

cd dev
wget http://wordpress.org/latest.tar.gz
tar zxf latest.tar.gz
rm latest.tar.gz
ls wordpress/
sudo ln -s /home/sotaro/dev/wordpress /var/www/wp
sudo chmod 777 wordpress

mysql> create database wordpress;
mysql> CREATE USER 'wp'@'localhost' IDENTIFIED BY 'wordpress'
mysql> GRANT ALL PRIVILEGES ON wordpress.* TO 'wp'@'localhost';

http://localhost/wp からログイン、DBに関する情報を入力して終了。

と思いきや、、、
テーマの追加を試み、FTPが必要であることが判明。
で、FTP。

sudo apt-get install proftpd
(xinetd or standaloneで xinetd を選ぶ)


ProFTPD warning: cannot start neither in standalone nor in inetd/xinetd mode. Check your configuration.
vi /etc/init.d/proftpd

といことで、/etc/init.d/proftpdを見ると

 49   if egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.conf 2>/dev/null || \
 50      egrep -qi "server[[:space:]]*=[[:space:]]*/usr/sbin/proftpd" /etc/xinetd.d/* 2>/dev/null || \
 51      egrep -qi "^ftp.*/usr/sbin/proftpd" /etc/inetd.conf 2>/dev/null 

そういえば、sshdもあげてないし、xinetdが無いのか!ってことで

sudo apt-get install xinetd
sudo vi /etc/xinetd.d/ftp
cat /etc/xinetd.d/ftp
service ftp
{
        flags           = REUSE
        socket_type     = stream
        wait            = no
        user            = root
        server          = /usr/sbin/proftpd
}
sudo /etc/init.d/xinetd restart

アカウントは

sudo useradd -g www-data -M wordpress
sudo passwd wordpress

で用意し、再度テーマの追加に挑む。が、permissionで色々怒られ

sudo chown -R wordpress:www-data *
sudo find . -type d -exec chmod 775 {} \;
sudo find . -type f -exec chmod 666 {} \;

でようやく完了。

※追記
apacheの設定に下記を追加


  Options Indexes FollowSymLinks MultiViews
  AllowOverride All
  Order allow,deny
  allow from all

3.22.2012

Ubuntu ifdown eth0 and Automount USB

22 Mar 2012 

最近オンボードのNICが使えなくなり、ログを見ても特にエラーは見つからず。ドライバ、BIOS、OSの順に更新して行くも状況は変わらず。で、Windows 8をインストールしてデバイスマネージャでNICを見ると、ドライバは入ってるけど、ちゃんとロードできなかった(Code 10)、みたいなエラーが出ていて、これをネットで調べると、デバイスが正常に動いていない可能性がある。とのことで、5年ぐらい使っているからハードが壊れたんだろう、ってことでPCカードのネットワークカードを購入する。

で、オンボードNICに安らかに眠ってもらうべく

iface eth0 inet static
  address 192.168.2.1
  netmask 255.255.255.0
  post-up ifdown eth0

と /etc/network/interfaces に書き加える。 

ネットワークが解決するや、今度はUSBメモリが自動マウントされなくなり、、、

syslogを眺めるも特に問題なく、gconf-editorでnautilusの設定を確認するもmedia_automountにチェックがあり、こちらも問題なし。logではsdb1として認識されていたが、fstabを見るとsdb1の記述がある。これはもしや!とUSBメモリを抜くと予想通りfstabのsdb1はそのまんま。

で、これを削除して自動マウントも解決。

3.20.2012

git/github memo

20 Mar 2012

1.ローカルを最新化する

git pull

2.ソースを編集する
3.ローカルへ反映する

git add + git commit

 or

git commit -a

4.マスタにも反映する

git push

※ non-fast-forward updates were rejected なら

git pull --commit

conflictがあったら手で直し

git push

3.11.2012

vim x github

11 Mar 2012

ゴールは、家でvimrcやpluginを調整し、それを会社でさくっと導入し、より早く開発できるようにすること。で、良さそうなpluginがgithubで公開されているので、家と会社をつなぐのもgithubで。

まずはgit/githubの練習。github.comでアカウント作り、テスト用のリポジトリを作ると、下記のような一連のコマンドが表示されるので簡単。

$ mkdir hello-Git
$ cd hello-Git/
$ git init
$ touch README
$ vi README
$ git add README
$ git commit -m 'first commit'
$ git remote add origin git@github.com:sotaro/hello-Git.git
$ git push -u origin master
$ git push git@github.com:sotaro/hello-Git.git
続いてplugin。
自動補完のneocomplcache + vimproc、リスティング(以外にも使えるらしい)のunite.vim、vim上でコマンドが使えるvimshellの4つと、「vundle」というplugin管理用のpluginの計5つをインストールする。

$ git clone git://github.com/gmarik/vundle.git ~/.vim/vundle.git
$ vi ~/.vimrc
(抜粋)
set nocompatible
filetype off

set rtp+=~/.vim/vundle.git/
call vundle#rc()

Bundle 'Shougo/unite.vim'
Bundle 'Shougo/vimshell'
Bundle 'Shougo/neocomplcache'
Bundle 'Shougo/vimproc'

filetype plugin indent on

let g:neocomplcache_enable_at_startup = 1
とし、vim上で

:BundleInstall
とすれば、インストール完了。
で、いよいよautocompleteを試すべく適当なファイルを編集しようとすると

.vim/bundle/vimproc/autoload/proc.so" is not found.
となり、

:help vimproc
でヘルプを読むとproc.soを作る必要があるとのことで、

$ cd ~/.vim/bundle/vimproc/
$ make -f make_gcc.mak
$ ls autoload/proc.so 
autoload/proc.so
で、いろいろ試すこと数時間。
使いこなすまでには相当の時間を要するが、どれも便利。

会社では

$ sudo apt-get install git-core
$ mkdir ~/.vim ~/github
$ git clone git://github.com/gmarik/vundle.git ~/.vim/vundle.git
$ git clone git://github.com/sotaro/hello-Git.git ~/github/hello-Git.git
$ cp ~/github/hello-Git.git/.vimrc ~/
$ vi .vimrc
(:BundleInstall)
$ cd ~/.vim/bundle/vimproc/
$ make -f make_gcc.mak
で導入できるはず!