rackhubがいい。

なにがいいのか?
初めからrvmとgemとpythonbrewと。nginxとubuntuな環境だからトレンドを感じます。
この流れについていかねばと。。。

とりあえず、nginxでPHPを動かしてみよう(・∀・)

参考URL:http://www.1x1.jp/blog/2011/05/yum_install_nginx_php-fpm.html

nginx自体はインストールされている。がサービスに登録されていない。。。

起動の確認は $sudo nginx

終了は $sudo kill 番号

This is a nginx default page at /usr/local/nginx/html/index.html .

とかでる。

$sudo nginx -t

とすれば、

nginx: the configuration file /usr/local/nginx-1.2.0/nginx.conf syntax is ok

とかでる。

ubuntu自動起動設定

$sudo update-rc.d -f nginx defaults

centosだったら

#chkconfig --add nginx

でいいらしい。

fast-cgiのインストール

first common gateway interfaceの略ですね。

普段apacheのモジュールとして動かすのでちょっと勝手が違。。

FastCGI Process Manager (FPM)

spawn-fcgi PHPと全く独立したプログラムで、FastCGIプロセス管理を行う

php-fpm PHPに一部機能を組み込んで、FastCGIプロセス管理を行う
の2つがある。

php-fpmのインストール

sudo apt-get install php5-fpm

/usr/sbin/php5-fpm -v

設定ファイル編集

/etc/php5/fpm/pool.d/www.conf

のuserとgroupをnginxに。

自動起動の設定 $sudo sysv-rc-conf

nginxの設定

自動起動


#user nobody;
worker_processes 1;

events {
worker_connections 128;
}
http {
include mime.types;
default_type application/octet-stream;

sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;

include /usr/local/nginx/conf.d/*;
}

/usr/local/nginx-1.2.0/conf.d/default

変更前


server {
listen 80;
server_name localhost;

location / {
root /usr/local/nginx/html;
index index.html index.htm;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

変更後


server {
listen 80;
server_name localhost;

location / {
root /home/www/html;
index index.php index.html index.htm;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /home/www/html$fastcgi_script_name;
fastcgi_intercept_errors on;
include fastcgi_params;
}

error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}

}

phpifnoでた。けども。

コマンドでphp -vとすると5.4.0。WEBでみるとphp5.3.10。。。。
sudo apt-get install php5-fpmがまずかったのか〜。。 コンパイルしないとダメなのかね。。。

これ買ったほうがいいですよ。。。