Ubuntu14.04を設定する
VagrantでUbuntu14.04を用意した。
vagrant ssh
後以下を実行。
権限変更
$ sudo su
nginxインストール
nginxをインストールする
# sudo apt-get -y install nginx
確認
# nginx -v
HHVMの設定
インストール
sudo apt-get install software-properties-common
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0x5a16e7281be7a449
sudo add-apt-repository "deb http://dl.hhvm.com/ubuntu $(lsb_release -sc) main"
sudo apt-get update
sudo apt-get install hhvm
nginxの設定
nginx設定ファイル編集
vi /etc/nginx/conf.d/hhvm.conf
設定を記述
server {
listen 80;
server_name dev.com;
location / {
root /usr/share/nginx/html;
index index.php index.html index.htm;
# hh・php 設定
#
location ~ .(hh|php)$ {
root /usr/share/nginx/html;
fastcgi_keep_conn on;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# エラーページ設定 40x.html
#
error_page 404 /404.html;
location = /40x.html {
root /usr/share/nginx/html;
}
# エラーページ設定 50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}
起動
# /etc/init.d/nginx start
# /etc/init.d/nginx status
# update-rc.d nginx defaults
hhvm起動
起動
# /etc/init.d/hhvm start
# sudo update-rc.d hhvm defaults
テストファイルを作成して実行してみる。
プロジェクトルートに.hhconfig
ファイルを作成
移動
# cd /usr/share/nginx/html
.hhconfig作成
# touch .hhconfig
テストファイル作成
# vi test.hh
<?hh
echo "こんにちは 世界";
実行
# hhvm test.hh