Weird problem with Yii2/vagrant

Today I decided to setup a vagrant box and play with Yii2. It’s RC so I thought it’s time to be in the game :)

First the issue:

I setup dns for frontend (FE) and backend(BE) via nginx. In any case I only got backend rendered no matter which domain I used, which is very strange. Now read on for the interesting part!

Tech details:

I brought up a vagrant box and installed yii2-advanced project. Vagrant is a base Ubuntu 12.04 box with nginx & php-fpm. I had two nginx server hosts for frontend and backend. I checked both configs about 1 million times they are correct. I had two subdomains:

fe.localhost.com & be.localhost.com respectively to render FE and BE. Id doesn’t matter which one I use yii always renders backend :). So I decided to rename the BE folder to backend_ (note the underscore after backend!). Interestingly I got an error in the error log:




2014/10/17 14:33:03 [error] 3698#0: *325 FastCGI sent in stderr: "PHP message: PHP Warning:  require(/usr/share/nginx/www/yii2/backend/web/../config/bootstrap.php): failed to open stream: No such file or directory in /usr/share/nginx/www/yii2/frontend/web/index.php on line 8

PHP message: PHP Stack trace:

PHP message: PHP   1. {main}() /usr/share/nginx/www/yii2/frontend/web/index.php:0

PHP message: PHP Fatal error:  require(): Failed opening required '/usr/share/nginx/www/yii2/backend/web/../config/bootstrap.php' (include_path='/usr/share/nginx/www/yii2/vendor/phpunit/php-text-template:/usr/share/nginx/www/yii2/vendor/phpunit/php-file-iterator:/usr/share/nginx/www/yii2/vendor/phpunit/php-timer:.:/usr/share/php:/usr/share/pear') in /usr/share/nginx/www/yii2/frontend/web/index.php on line 8

PHP message: PHP Stack trace:

PHP message: PHP   1. {main}() /usr/share/nginx/www/yii2/frontend/web/index.php:0" while reading response header from upstream, client: 192.168.100.1, server: fe.localhost.com, request: "GET / HTTP/1.1", upstream: "fastcgi://127.0.0.1:9000", host: "fe.localhost.com"



the error suggests there is a problem with line 8 in frontend/web/index.php which is line:


require(__DIR__ . '/../config/bootstrap.php');

so I commented this line and all started working again. So without this line FE & BE are rendered without any issue. It could of course be something with vagrant but I tested with two simple files (frontend.php & backend.php) and they both were rendered correctly, which makes me think no issue in vagrant/nginx.

Cheers,

bettor