Reputation: 473
I have a site with symfony3. Everything works like charm. For a couple of days, I installed an another project, to a different folder, and install symfony(3) with composer.
And there comes the problem. The first project works, but the second wouldnt. But if I restart the FPM, and browse the second project, it works, but the first goes wrong. I tried with symfony2.7 too. the same
the folder structure is
/var/www/domain1
/var/www/domain2
The default was the projects used the same fpm-socket, but i tried on different.
The nginx configuration is the following:
server {
server_name domain1;
root /var/www/domain1/web;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm-domain1.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm-domain1.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
internal;
}
location ~ /\.ht {
deny all;
}
error_log /var/log/nginx/domain1_error.log;
access_log /var/log/nginx/domain1_access.log;
}
server {
server_name domain2;
root /var/www/domain2/web;
server_tokens off;
location / {
try_files $uri /app.php$is_args$args;
}
location ~ ^/(app_dev|config)\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm-domain2.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ ^/app\.php(/|$) {
fastcgi_pass unix:/var/run/php5-fpm-domain2.sock;
fastcgi_split_path_info ^(.+\.php)(/.*)$;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
internal;
}
location ~ /\.ht {
deny all;
}
error_log /var/log/nginx/domain2_error.log;
access_log /var/log/nginx/domain2_access.log;
}
The fpm configurations:
[domain1]
user = www-data
group = www-data
listen = /var/run/php5-fpm-domain1.sock
listen.owner = www-data
listen.group = www-data
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
[domain2]
user = domain2
group = domain2
listen = /var/run/php5-fpm-domain2.sock
listen.owner = domain2
listen.group = domain2
listen.mode = 0660
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
php_admin_value[error_log] = /var/log/fpm-php.domain2.log
php_admin_flag[log_errors] = on
the domain2 user exists too, and user of the folder. and permission is good.
But the log says (it's very strange), that the secondary opened project wants to read from the other project o.0
I mean, the log is like this:
2015/11/05 13:17:04 [error] 26029#0: *33508 FastCGI sent in stderr: "PHP message: PHP Fatal error: Class 'AppBundle\AppBundle' not found in /var/www/domain2/app/AppKernel.php on line 19
PHP message: PHP Stack trace:
PHP message: PHP 1. {main}() /var/www/domain2/web/app_dev.php:0
PHP message: PHP 2. Symfony\Component\HttpKernel\Kernel->handle() /var/www/domain2/web/app_dev.php:33
PHP message: PHP 3. Symfony\Component\HttpKernel\Kernel->boot() /var/www/domain1/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:183
PHP message: PHP 4. Symfony\Component\HttpKernel\Kernel->initializeBundles() /var/www/domain1/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:121
PHP message: PHP 5. AppKernel->registerBundles() /var/www/domain1/vendor/symfony/symfony/src/Symfony/Component/HttpKernel/Kernel.php:435" while reading response header from upstream, client: 46.139.10.151, server: domain2, request: "GET /app_dev.php HTTP/1.1", upstream: "fastcgi://unix:/var/run/php5-fpm-domain2.sock:", host: "domain2"
Sooo, there is something very bad. But i dont know, as my colleagues, what the hell is this.
Somebody have a clue?
Upvotes: 0
Views: 118
Reputation: 13107
Ok, I don’t know your exact setup, but my guess would be the following:
ApcCacheLoader
in the web/app.php
of your Symfony applications.If the above is true, there might be a line in your web/app.php
which looks like this:
$loader = new ApcClassLoader('sf2', $loader);
If you have this line in two or more Symfony installations on the same server, the autoloader cache of both application collides.
Why is that? As its name suggests, ApcClassLoader
stores a list of files and namespaces in APC, and it will use the first constructor parameter as cache key.
So, obviously, you need to change that value and then rebuild the cache with app/console --env=prod
. Maybe you’ll also have to run composer install
again, I’m not sure about that one.
Upvotes: 1