ubuntuでヘッドフォンが使えない時の対処法

ubuntuでスピーカーから音声は出るけどヘッドフォンから音声出ない」という人のための対処法
もしかしたら解決するかも。とりあえず自分の環境では解決できた。

codecを調べる

$ cat /proc/asound/card0/codec#* | grep Codec
Codec: Conexant CX20585
Codec: Intel IbexPeak HDMI

とりあえず出力結果でググッてみる

誰かが解決しているのを祈る。
自分はすぐ解決方法が出てました。

/etc/modprobe.d/alsa-base.confに設定を追記

多分こんなようなオプションを追加する。
環境によって違うと思うよ。

options snd-hda-intel model=ideapad

再起動

ヘッドフォンから音出ました。

Ruby on Railsで外部ライブラリを使ってみた

結構ハマった。
ちゃんとマニュアル読めと。

  • 参考サイト
    • 使用するGemはGemfileに書く

http://mitukiii.jp/2010/12/12/make-app-by-ruby-on-rails3/

  • マニュアル
    • 3.3 Installing the Required Gems

http://api.rubyonrails.org/

方法

  • Gemfileに以下のように追記
$ vim ./Gemfile
gem 'hoge'
  • 以下を実行
$ bundle install


参考サイトにも書いてあるように、適当にcontrollerとかにrequire 'hoge'と書いても怒られます。

Ruby on Railsで外部ライブラリを使ってみた

結構ハマった。
ちゃんとマニュアル読めと。

  • 参考サイト
    • 使用するGemはGemfileに書く

http://mitukiii.jp/2010/12/12/make-app-by-ruby-on-rails3/

  • マニュアル
    • 3.3 Installing the Required Gems

http://api.rubyonrails.org/

方法

  • Gemfileに以下のように追記
$ vim ./Gemfile
gem 'hoge'
  • 以下を実行
$ bundle install
||< 

CentOS 5.5にリポジトリを追加

結構サボってます。

CentOS5.5のmysqlやら何やらのパッケージは古い。
yumから新しめのパッケージをインストールするため、リポジトリを追加する。
追加するのはepelとremi

リポジトリ追加方法

 $ sudo rpm -Uvh http://download.fedora.redhat.com/pub/epel/5/i386/epel-release-5-4.noarch.rpm
 $ sudo rpm -Uvh http://rpms.famillecollet.com/enterprise/remi-release-5.rpm
 $ vim /etc/yum.repo.d/epel.repo

 enabled=1 → enabled=0に変更

 $ vim /etc/yum.repo.d/remi.repo
 
 こちらもenabled=1 → enabled=0に変更

インストール

mysqlmysql-serverをインストールしてみる。
デフォルトでenabled=0で無効にしているので、必要なときに
オプション「--enablerepo=epel,remi」を付け有効にする。

 $ sudo yum --enablerepo=epel,remi install mysql mysql-server

で完了。
無事mysql.5.1系がインストールできた・・・・となるはずだったんだが、
当初、何故かインストールできず。
remiのリポジトリが有効になってない感じ。


priorityとかがおかしいのかなぁ、思って色々探し回ってたら以下のサイトを発見。
http://forums.famillecollet.com/viewtopic.php?id=207


yum-prioritiesのパッケージがインストールされていた(俺が入れたのかな?)らしく、
それが有効になっていたかららしい。
「--noplugins」で無効にしてインストールしたらできた。

 $ sudo yum --noplugins --enablerepo=epel,remi install mysql mysql-server

てかyum-prioritiesが要らないと思うので削除。

 $ sudo yum remove yum-priorities

これで一件落着。


しかしrubyは1.8.5・・・・

  • 参考サイト

http://fedoraproject.org/wiki/EPEL
http://rpms.famillecollet.com/

CentOS 5.5にrubyとrubygemsを入れて、Ruby on Railsの環境を構築してみた

立て続けに日記。

前回リポジトリを追加して、新しめのパッケージをインストールすることができるよになったが、
rubyに関しては1.8.5で古いまま。


1.8.5でインストールすると、rails入れる段階で1.8.7にしろよ、と怒られる。
なので、1.8.7を入れるようにする。


やりたいことは

    • rubyrubygemsのパッケージを作って
    • インストールする
    • そしてrailsを入れる

ということ。
これが結構大変でした。

パッケージを作る準備

調べて回ると、checkinstallからパッケージを作ってる方が多かった。
なので自分もそれに倣ってやってみることに。

以下のサイトを参考に進めました。
http://teps4545.blogspot.com/2010/10/centos-55-ruby-187-passenger-300.html

checkinstallパッケージをインストールする。がしかし・・・

checkinstallパッケージをインストールする。
これまたrpmforgeリポジトリにあるらしい。
なので、前回同様リポジトリを追加してみる。

$ wget http://packages.sw.be/rpmforge-release/rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
$ sudo rpmforge-release-0.5.1-1.el5.rf.x86_64.rpm
$ sudo vim /etc/yum.repos.d/rpmforge.repo

enabled=1をenabled=0にする

んでインストール

$ sudo yum --enablerepo=rpmforge install checkinstall    
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.nara.wide.ad.jp
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: ftp.nara.wide.ad.jp
Setting up Install Process
No package checkinstall available.
Nothing to do

ん?

$ sudo yum --enablerepo=rpmforge search checkinstall
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * addons: ftp.nara.wide.ad.jp
 * base: ftp.nara.wide.ad.jp
 * extras: ftp.nara.wide.ad.jp
 * rpmforge: ftp-stud.fht-esslingen.de
 * updates: ftp.nara.wide.ad.jp
Warning: No matches found for: checkinstall
No Matches found

無いようです・・・。


どっかにパッケージ無いか探したけど、これと言ってよさげなものがない。
なのでソースから入れました。
まあパッケージ作るだけだからいいか、と。

$ sudo http://www.asic-linux.com.mx/~izto/checkinstall/files/source/checkinstall-1.6.2.tar.gz
$ tar zxvf checkinstall-1.6.2.tar.gz 
$ cd checkinstall-1.6.2
$ make
$ sudo make install

/usr/local/sbin/checkinstallがインストールされます。
これでパッケージ作る準備は完了。

rubyのパッケージを作る&インストール

以下の手順で。

$ wget ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.7-p334.tar.gz
$ tar zxvf ruby-1.8.7-p334.tar.gz 
$ cd ruby-1.8.7-p334
$ ./configure --prefix=/usr
$ make
$ sudo /usr/local/sbin/checkinstall --fstrans=no
checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.

(省略)

**********************************************************************

 Done. The new package has been saved to

 /usr/src/redhat/RPMS/x86_64/ruby-1.8.7-p334-1.x86_64.rpm
 You can install it in your system anytime using: 

      rpm -i ruby-1.8.7-p334-1.x86_64.rpm

**********************************************************************

色々聞かれますが、そのままデフォルトでやっちゃいました。
そしてインストール

$ sudo rpm -ihv /usr/src/redhat/RPMS/x86_64/ruby-1.8.7-p334-1.x86_64.rpm

ok

rubygemsのパッケージを作る&インストール

続いてrubygems
これも同様にパッケージを作成していきます。

$ wget http://rubyforge.org/frs/download.php/74234/rubygems-1.5.2.tgz
$ tar zxvf rubygems-1.5.2.tgz
$ cd rubygems-1.5.2
$ sudo /usr/local/sbin/checkinstall -R "ruby setup.rb"

ここでエラー発生。
「/usr/local/lib64/installwatch.soがねーよ」と怒られる。
調べて以下のサイト発見。
http://d.hatena.ne.jp/yk77/20101123/1290460702


そんな感じでシンボリックリンクを付ける。

$ sudo ln -s /usr/local/lib/installwatch.so /usr/local/lib64/installwatch.so

これで回避。
んで再度実行するとまたもやエラー

$ sudo /usr/local/sbin/checkinstall -R "ruby setup.rb"
(省略)
Installing with ruby setup.rb...

========================= Installation results ===========================
/var/tmp/tmp.IgXYC16603/installscript.sh: line 4: ruby setup.rb: command not found

****  Installation failed. Aborting package creation.

Cleaning up...OK

Bye.

今度は「ruby setup.rbていうコマンドないよ」と怒られる。
これがよくわからなかった。
どこのサイトでも「/usr/local/sbin/checkinstall -R "ruby setup.rb"」と書いてある。
何でだろうな?
rootでやってみるも☓
/usr/bin/rubyとかfullpathでやってみるも☓
うむむ・・・・


ちなみにパッケージを作成せずに直接インストールは普通にできた。

$ sudo /usr/bin/ruby setup.rb


もうそれでもいいかな・・・。
けど何かわかりそうなんだよな・・・。


そして考えること1時間。


できた。

$ /usr/local/sbin/checkinstall -R ruby setup.rb

checkinstall 1.6.2, Copyright 2009 Felipe Eduardo Sanchez Diaz Duran
           This software is released under the GNU GPL.

(省略)

**********************************************************************

 Done. The new package has been saved to

 /usr/src/redhat/RPMS/x86_64/rubygems-1.5.2-1.x86_64.rpm
 You can install it in your system anytime using: 

      rpm -i rubygems-1.5.2-1.x86_64.rpm

**********************************************************************

「sudo /usr/local/sbin/checkinstall -R "ruby setup.rb"」ではなく
「sudo /usr/local/sbin/checkinstall -R ruby setup.rb


ダブルクォーテーションがいらない。
以上。
時間がかかった。

あとはインストール

$ sudo rpm -ihv /usr/src/redhat/RPMS/x86_64/rubygems-1.5.2-1.x86_64.rpm 

これで環境は整いました。
いやー時間かかった。

試しにrailsでも入れてみる。

gemからrailsを入れてみる。
がしかし・・・。

$ sudo gem install rails
ERROR:  Loading command: install (LoadError)
    no such file to load -- zlib
ERROR:  While executing gem ... (NameError)
    uninitialized constant Gem::Commands::InstallCommand 

もうヤダ・・・。


zlibやzlib-develが無いのかなぁと思ってインストールするも☓
で、またもや色々探し回ってサイト発見。
http://leaveanotemessagebehind.blogspot.com/2007/08/centosrubygems.html


解決策は以下のとおり。

$ cd ruby-1.8.7-p334
$ cd ext/zlib/
$ ruby extconf.rb --with-zlib-include=/usr/include --with-zlib-lib=/usr/lib
$ make
$ make install

これでrailsがインストールできる。
できるが、「rdocが云々・・・」と怒られる。
なのでgemからrdocをインストールする。

$ sudo gem install rdoc

これで再度railsをインストールすれば怒られな・・・

$ sudo gem install rails
(省略)
Installing ri documentation for rails-3.0.4...
File not found: lib

またか。
調べる。サイト発見。
http://www.ruby-forum.com/topic/216257
解決。

$ sudo mkdir /usr/lib/ruby/gems/1.8/gems/rails-3.0.4/lib
$ sudo gem install rails
Successfully installed rails-3.0.4
1 gem installed
Installing ri documentation for rails-3.0.4...
Installing RDoc documentation for rails-3.0.4...

長い道のりだったよ。

  • ソースダウンロード

http://www.asic-linux.com.mx/~izto/checkinstall/download.php

http://www.ruby-lang.org/ja/downloads/

http://rubygems.org/pages/download/

さくらインターネットVPSを申し込んでみた

何となく使ってみようかなぁ〜と思って申し込んでみた。月980円と安いしね。
申し込みから初期設定まで。

申し込み

  • http://vps.sakura.ad.jp/にアクセス
  • 「お申し込みはこちら」から登録手続きを行う
  • 申し込み完了後「お申込受付完了のお知らせ」のメールが届く

※この時点ではまだ利用できない

  • 数分後に「仮登録完了のお知らせ」が届く

この時点でサーバ利用可能になる
このメールにログイン情報(rootのパスワードなど)が記載されている

起動

ログイン

  • 付与されたIPアドレスとrootのパスワードでアクセスする
$ ssh root@hoge.sakura.ne.jp
root@hoge.sakura.ne.jp's password:<rootのパスワード>

SAKURA Internet [Virtual Private Server SERVICE]
[root@hoge.sakura.ne.jp ~]#

最初にやったサーバの設定

アップデート
# yum update
vimインストール
yum install vim-enhanced.x86_64
rootのパスワード変更
# passwd 
Changing password for user root.
New UNIX password: <新しいパスワード入力> 
Retype new UNIX password: <新しいパスワード入力> 
passwd: all authentication tokens updated successfully.

user追加
# useradd hoge
# passwd hoge
Changing password for user hoge.
New UNIX password: <新しいパスワード入力> 
Retype new UNIX password: <新しいパスワード入力> 
passwd: all authentication tokens updated successfully.
rootになれるuserを制限
  • hogeのみをrootにsuできるようにする
  • 以下のサイトを参考に設定

http://www.jitaku-server.net/root.html

公開鍵追加
  • クライアントマシンで鍵を作成
$ ssh-keygen 
Generating public/private rsa key pair.
Enter file in which to save the key (/home/hoge/.ssh/id_rsa):
Enter passphrase (empty for no passphrase): <パスフレーズ入力>
Enter same passphrase again: <パスフレーズ入力>
Your identification has been saved in /home/hoge/.ssh/id_rsa.
Your public key has been saved in /home/hoge/.ssh/id_rsa.pub.
The key fingerprint is: 
The key's randomart image is:
+--[ RSA 2048]----+
|                            |
         ( 略)
|                            |
+-----------------+
  • 公開鍵をリモートサーバへ転送
$ ssh-copy-id -i .ssh/id_rsa.pub hoge@hoge.sakura.ne.jp
  • 公開鍵認証でリモート接続できるか確認
$ ssh -i  .ssh/id_rsa hoge@hoge.sakura.ne.jp
iptable変更
  • 22,80,443のポートのみ接続可にする
# iptables -P INPUT DROP  
# iptables -P FORWARD DROP  
# iptables -P OUTPUT ACCEPT  
# iptables -A INPUT -i lo -j ACCEPT 
# iptables -A INPUT -p icmp -j ACCEPT
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT  
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT  
# iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT  
# iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT        
# service iptables save
  • 確認
# iptables -L
Chain INPUT (policy DROP)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:http 
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:https 
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 

Chain FORWARD (policy DROP)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination
  • sshで接続できるか確認する

※失敗するとリモートでの接続ができなくなるので十分注意して設定する

sshdの設定
  • rootでのリモート接続不可
  • パスワード認証不可
# vim /etc/ssh/sshd_config
PermitRootLogin no # コメントを解除しnoにする
PasswordAuthentication no # yesからnoに設定する
sendmailからpostfixに変更する
# chkconfig sendmail off
# yum install postfix
# chkconfig --add postfix
  • 一旦reboot
  • postfixのみが起動していることを確認
# ps -ef | grep "sendmail" | grep -v "grep"
# ps -ef | grep "postfix" | grep -v "grep"
root      1544     1  0 18:28 ?        00:00:00 /usr/libexec/postfix/master
postfix   1549  1544  0 18:28 ?        00:00:00 pickup -l -t fifo -u
postfix   1551  1544  0 18:28 ?        00:00:00 qmgr -l -t fifo -u

とりあえずこれくらいやっておけばいいかと・・・。
さて何やろうかなぁ。

ubuntu10.10 64bit版にflashplugin 64bit版をインストールしてみた

ubuntu10.10 64bit版にはデフォルトでflashplugin32bit版がインストールされる。
それが原因かわからんけど、flashがcrashしたり、ニコ動に日本語入力ができないなど、
色々とよろしくない。
なので、64bit版を入れてみた。


ググッたら以下のサイトがあったので、それを参考にインストール。
http://heberekemaruhunihun.blog77.fc2.com/blog-entry-525.html


1.デフォルトでインストールされているflashpluginをアンインストール
ubuntuソフトウェアセンター」から「Adobe Flashプラグイン」を削除


2.コマンドラインからリポジトリを追加し、flashplugin64bit版をインストール

 $ sudo add-apt-repository ppa:sevenmachines/flash
 $ sudo apt-get update
 $ sudo apt-get install flashplugin64-installer

ブラウザを再起動すればOK。


iBus経由でニコ動にコメントできた〜。
あとはcrashしないことを祈ろう。