Help us understand the problem. What is going on with this article?

NginxでサブディレクトリのPhalconを動かす

More than 5 years have passed since last update.

http://localhost/webapp1http://localhost/webapp2などのアクセスで、サブディレクトリのPhalconを動かす設定例です。

/vagrant/webapp1と/vagrant/webapp2_serverにphalconのプロジェクトがあることを前提。

/vagrant/webapp1
          ├── app
          └── public
              └── index.php

/vagrant/webapp2_server
          ├── app
          └── public
              └── index.php

http://localhost/webapp1なら/vagrant/webapp1/public/index.phpを、
http://localhost/webapp2なら/vagrant/webapp2_server/public/index.phpを実行させます。

phalcon_subdirectory.conf
    # URL1つ目のセグメントとディレクトリ名が一致している場合(汎用)
    if ($request_uri ~ /(?<phalcon_subdirectory>\w+)) {
        set $root_path /vagrant/$phalcon_subdirectory/public;
    }
    # URL1つ目のセグメントとディレクトリ名が一致していない場合(/webapp2をwebapp2_serverに対応)
    if ($request_uri ~ /webapp2) {
        set $root_path /vagrant/webapp2_server/public;
    }

    location ~ ^/(?<phalcon_subdirectory>\w+)/(.+\.php)$ {
        include        fastcgi_params;
        fastcgi_pass   127.0.0.1:9000;
        fastcgi_index  index.php;

        # http://nginx.org/en/docs/http/ngx_http_fastcgi_module.html#fastcgi_split_path_info
        # 1つ目は$fastcgi_script_name、2つ目は$fastcgi_path_infoにセットされる
        fastcgi_split_path_info ^/\w+(/.+\.php)(.*)$;

        fastcgi_param  SCRIPT_FILENAME  $root_path$fastcgi_script_name;

        # アプリ任意のSERVER変数
        fastcgi_param  PHALCON_SUBDIRECTORY $phalcon_subdirectory;
        fastcgi_param  APP_ENV local;
    }


    location ~ ^/\w+(.+)? {

        location ~ ^/\w+/\.ht {
            deny  all;
        }

        alias $root_path$1;

        if (!-f $request_filename) {
            rewrite ^/(\w+)/?(.+)?$ /$1/index.php?_url=/$2 last;
        }
    }
pakiln
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした