Issue with two instances of cakePHP on the same Server

I recently copied and adapted (modified) an existing application on the same Apache2 Server (On a Ubuntu Server) :
==> After deploy, If I access site 1, Site 2 Gives Apache 500 Error (and not cakephp 500 error page) . And vice versa if I access Site 2 first.
I changed the cache prefixes in app.php . On localhost (windows) I don’t have this problem. It appears only when I Deploy on the remote Ubuntu Server .
I had a look at apache error log and I found that Site 2 is trying to access Site 1 files. Here is the log:
(in this example, the correct path is not /…/web10/… , but /…/web9/.)

[Thu Mar 23 00:36:38.270054 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/clients/client1/web9/web/vendor/cakephp/chronos/src/Chronos.php) is not within the allowed path(s): (/var/www/clients/client1/web10/web:/var/www/clients/client1/web10/private:/var/www/clients/client1/web10/tmp:/var/www/jobea.ca/web:/srv/www/jobea.ca/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web9/web/vendor/composer/ClassLoader.php on line 354
[Thu Mar 23 00:36:38.270369 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/clients/client1/web9/web/vendor/cakephp/cakephp/src/Chronos/Chronos.php) is not within the allowed path(s): (/var/www/clients/client1/web10/web:/var/www/clients/client1/web10/private:/var/www/clients/client1/web10/tmp:/var/www/jobea.ca/web:/srv/www/jobea.ca/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web9/web/vendor/composer/ClassLoader.php on line 354
[Thu Mar 23 00:36:38.270412 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  Class 'Cake\\Chronos\\Chronos' not found in /var/www/clients/client1/web9/web/vendor/cakephp/chronos/src/carbon_compat.php on line 16
[Thu Mar 23 00:36:38.270637 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/clients/client1/web9/web/vendor/cakephp/chronos/src/ChronosInterface.php) is not within the allowed path(s): (/var/www/clients/client1/web10/web:/var/www/clients/client1/web10/private:/var/www/clients/client1/web10/tmp:/var/www/jobea.ca/web:/srv/www/jobea.ca/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web9/web/vendor/composer/ClassLoader.php on line 354
[Thu Mar 23 00:36:38.270870 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/clients/client1/web9/web/vendor/cakephp/cakephp/src/Chronos/ChronosInterface.php) is not within the allowed path(s): (/var/www/clients/client1/web10/web:/var/www/clients/client1/web10/private:/var/www/clients/client1/web10/tmp:/var/www/jobea.ca/web:/srv/www/jobea.ca/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web9/web/vendor/composer/ClassLoader.php on line 354
[Thu Mar 23 00:36:38.270883 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  Class 'Cake\\Chronos\\ChronosInterface' not found in /var/www/clients/client1/web9/web/vendor/cakephp/chronos/src/carbon_compat.php on line 17
[Thu Mar 23 00:36:38.271619 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Warning:  file_exists(): open_basedir restriction in effect. File(/var/www/clients/client1/web9/web/vendor/cakephp/cakephp/src/Utility/Inflector.php) is not within the allowed path(s): (/var/www/clients/client1/web10/web:/var/www/clients/client1/web10/private:/var/www/clients/client1/web10/tmp:/var/www/jobea.ca/web:/srv/www/jobea.ca/web:/usr/share/php5:/usr/share/php:/tmp:/usr/share/phpmyadmin:/etc/phpmyadmin:/var/lib/phpmyadmin) in /var/www/clients/client1/web9/web/vendor/composer/ClassLoader.php on line 354
[Thu Mar 23 00:36:38.271640 2017] [:error] [pid 13132] [client 209.197.185.227:57088] PHP Fatal error:  Class 'Cake\\Utility\\Inflector' not found in /var/www/clients/client1/web9/web/vendor/cakephp/cakephp/src/Utility/bootstrap.php on line 18

Thanks

You should check on your virtual host first and do not forget to empty cakephp cache before to deploy in production.

Are you using nginx or apache ?

I’m using Apache2 on Ubuntu 14.x LTS .
What do you mean by checking the virtual host, Do you mean the configuration file of the virtual host ?
For cache I delete /tmp/* .

Yes you should check it as well.

I actually don’t know your file structure, except with the path you gave us, so hard to help you :wink:

I think I found something interesting… May be it is because of the __DIR__ constant
I did the following test :

  1. I added an echo __DIR__ in the top of the file : /vendor/composer/ClassLoader.php in both sites ;
  2. Site 1 displays it’s own directory;
  3. Site 2 Displays Site’s 1 directory !!

What do you think ? Thanks

Ok !
I found it my self … The problem was a bug in OPCache :
https://bugs.php.net/bug.php?id=67481

I disabled it and it works. Here is how to do it (I had not the exact paths but I tried to do the same).

https://serverpilot.io/community/articles/how-to-disable-the-php-opachce.html

I rebooted the whole server after that