Phalconのマニュアルにあるチュートリアルを実装し、画面に「Hello!」が表示されるところまで行います。
Phalconのインストールは以下の内容で済んでいる前提です。
Phalconインストール(CentOS7.2 + PHP5.4)
または
Phalconインストール(CentOS7.2 + PHP7.0)
Phalconのサンプルソース取得
以下のマニュアルを参考にチュートリアルのソースを取得し、「Hello!」を表示します。
https://docs.phalconphp.com/ja/latest/reference/tutorial.html#id3
今回は、「/var/www/html/」配下にサンプルソースを配置します。
git cloneすることで、html下にtutorialフォルダが作成されます。
$ cd /var/www/html/ $ git clone https://github.com/phalcon/tutorial.git
Nginxの設定
以下のマニュアルを参考にnginx.confまたは、conf.d配下のconfファイルにnginxの設定を行います。
https://docs.phalconphp.com/ja/latest/reference/nginx.html
今回は、マニュアルの「$_SERVER['REQUEST_URI'] をURIsとする場合」の設定を使用します。
プロジェクトフォルダは「/var/www/html/tutorial/」です。
rootに設定するディレクトリは「/var/www/html/tutorial/public」ですので、ご注意を!
server {
listen 80;
server_name localhost;
root /var/www/html/tutorial/public;
index index.php index.html index.htm;
location / {
try_files $uri $uri/ /index.php;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index /index.php;
include fastcgi_params;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht {
deny all;
}
}
設定が完了したら、Nginxを再起動します。
$ /bin/systemctl restart nginx
以上で完了です。
ブラウザでアクセスすると、「Hello!」が表示されると思います。
お疲れさまでした。
