I have a problem that seems odd. I'm using Prestashop with a LAMP stack.
When I restart Apache, everything works fine, but after some time, I start to have those messages in the log :
[Fri Feb 15 10:54:42 2013] [error] [client xxx.xxx.xxx.xxx] PHP Fatal error: Cannot redeclare class manufacturercore in /srv/www/my-ecommerce/classes/Manufacturer.php on line 30, referer: http://my-ecommerce.tld/fr/90421-example
[Fri Feb 15 10:55:56 2013] [error] [client xxx.xxx.xxx.xxx] PHP Fatal error: Cannot redeclare class categorycore in /srv/www/my-ecommerce/classes/Category.php on line 30, referer: http://my-ecommerce.tld/fr/90599-example
If I take a look at the code in Category.php or Manufacturer.php (from Prestashop), it starts with
if(class_exists('CategoryCore') != true) {
class CategoryCore extends ObjectModel {
// Code here
}
}
So now, I'm just lost.
I got an error that says the classes are redeclared, but the code seems to avoid this kind of problem.
Related
Would like to get more detail into my error log lines from my apache module.
Currently am using this to log a bad request:
ap_log_error(APLOG_MARK, APLOG_ERR, 400, r->server,"error msg");
Which results in this in the error log file:
[Wed Nov 09 14:17:08.429009 2022] [:error] [pid 765] (400)Unknown error 400: error msg
Would like to have an identifier on the left side of ":error" like the module name and also have "Unknown Error" be more specific like "Bad Request" or file line number if possible. More like the line below plus file and line number if possible:
[Wed Nov 09 13:56:51.902728 2022] [core:notice] [pid 757] AH00094: Command line: '/usr/sbin/apache2'
According to https://svn.apache.org/viewvc/httpd/httpd/trunk/include/http_log.h?view=markup
APLOG_MARK is supposed to be a macro for use as the first three parameters in
ap_log_error() and related functions, i.e. file, line, and module_index.
However no file, line or module index are present in my log line.
Thanks
I write simple C code
#include<stdio.h>
#include<sys/types.h>
#include<stdlib.h>
#include<unistd.h>
#include <sys/stat.h>
int main(){
pid_t pid;
pid=fork();
if(pid>0){
exit(1);
}
FILE *fp;
fp=fopen("pid.pid","a");
fprintf(fp,"%d",getpid());
fclose(fp);
printf("\npid = %d\n",pid);
printf("\ngetpid = %d\n",getpid());
puts("\nAfter fclose() \n");
umask(0);
while(1){}
return 0;
}
and Daemon1.service
[Units]
Description=Socket programming with Daemon
[Service]
User=root
Type=forking
WorkingDirectory=/Omkar/Doc/systemctl/
ExecStart=/Omkar/Doc/systemctl/main
Restart=always
PIDFile=/Omkar/Doc/systemctl/pid.pid
[Install]
WantedBy=multi-user.target
and stored at location
/etc/systemd/system
after this i run command
systemctl daemon-reload
systemctl enable Daemon1.service
systemctl start Daemon1.service
Then i got error
Job for Daemon1.service failed because the control process exited with error code.
See "systemctl status Daemon1.service" and "journalctl-xe" for details.
Then I check status of service with this command
systemctl status Daemon1.service
then i got this
● Daemon1.service
Loaded: loaded (/etc/systemd/system/Daemon1.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Tue 2019-11-19 18:21:26 IST; 3min 26s ago
Process: 5868 ExecStart=/Omkar/Doc/systemctl/main (code=exited, status=1/FAILURE)
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Failed to start Daemon1.service.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Unit entered failed state.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Failed with result 'exit-code'.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Service hold-off time over, scheduling restart.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Stopped Daemon1.service.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Start request repeated too quickly.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Failed to start Daemon1.service.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Unit entered failed state.
Nov 19 18:21:26 pt32-H81M-S systemd[1]: Daemon1.service: Failed with result 'start-limit-hit'.
My service is not running. What should i need to change so my code will work.
I give executable file of C code to ExecStart= in Daemon1.service
There is line in your output that is giving you a not so subtle hint: (code=exited, status=1/FAILURE)
● Daemon1.service
Loaded: loaded (/etc/systemd/system/Daemon1.service; enabled; vendor preset: enabled)
Active: failed (Result: start-limit-hit) since Tue 2019-11-19 18:21:26 IST; 3min 26s ago
Process: 5868 ExecStart=/Omkar/Doc/systemctl/main (code=exited, status=1/FAILURE)
Modify your code return 0 instead of 1 to the OS after forking.
if(pid>0){
exit(0);
}
You should be back in business to move forward after that small adjustment:
# systemctl status Daemon1.service
● Daemon1.service
Loaded: loaded (/etc/systemd/system/Daemon1.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2019-11-19 08:49:33 CST; 5s ago
Process: 20484 ExecStart=/root/stackoverflow/Daemon1 (code=exited, status=0/SUCCESS)
Main PID: 20486 (Daemon1)
CGroup: /system.slice/Daemon1.service
└─20486 /root/stackoverflow/Daemon1
Nov 19 08:49:33 lm systemd[1]: Starting Daemon1.service...
Nov 19 08:49:33 lm systemd[1]: Started Daemon1.service.
Since 7 days I tried to repair HwiOauthFukingBundle with facebook + FosUserOtherFukingBundle + Symfony 3.4.
And now, I have this incomprehensible errors in prod but not in dev.
[2018-03-17 14:45:27] php.WARNING: Warning:
require(/var/www/vhosts/domaine.fr/var/cache/prod/doctrine/orm/Proxies/__CG__ECUserBundleEntityImage.php):
failed to open stream: No such file or directory
{"exception":"[object] (ErrorException(code: 0): Warning:
require(/var/www/vhosts/domaine.fr/var/cache/prod/doctrine/orm/Proxies/__CG__ECUserBundleEntityImage.php):
failed to open stream: No such file or directory at
/var/www/vhosts/domaine.fr/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:223)"}
[]
And this one
[2018-03-17 14:45:27] request.CRITICAL: Uncaught PHP Exception
Symfony\Component\Debug\Exception\FatalErrorException: "Compile Error:
require(): Failed opening required
'/var/www/vhosts/domaine.fr/var/cache/prod/doctrine/orm/Proxies/__CG__ECUserBundleEntityImage.php'
(include_path='.:/opt/plesk/php/7.1/share/pear')" at
/var/www/vhosts/domaine.fr/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php
line 223 {"exception":"[object]
(Symfony\Component\Debug\Exception\FatalErrorException(code: 0):
Compile Error: require(): Failed opening required
'/var/www/vhosts/domaine.fr/var/cache/prod/doctrine/orm/Proxies/__CG__ECUserBundleEntityImage.php'
(include_path='.:/opt/plesk/php/7.1/share/pear') at
/var/www/vhosts/domaine.fr/vendor/doctrine/common/lib/Doctrine/Common/Proxy/AbstractProxyFactory.php:223)"}
[]
What's going on ?
I have clean the cache folder etc. but this error seems to be falling from the sky... this is a nightmare...
I have CakePHP. But sometimes, if I make (usually syntax) error, it doesn't tell me where and what's wrong, it just dies and I get:
Why is that, and how can I get line number and error type instead?
Debug is on. Version 2.2.3
UPDATE1:
Configure::write('Error', array(
'handler' => 'ErrorHandler::handleError',
'level' => E_ALL & ~E_DEPRECATED & ~E_STRICT,
'trace' => true
));
Configure::write('Exception', array(
'handler' => 'ErrorHandler::handleException',
'renderer' => 'ExceptionRenderer',
'log' => true
));
And errors files:
UPDATE 2:
app/tmp/error.log had problems with permissions, after I chmod -R 777 app/tmp/log/ I have the following stuff appearing:
2013-09-13 08:17:32 Error: Fatal Error (4): parse error in [/Users/petarpetrov/jobsAdvent/sunshine/app/View/Themed/Jobsearch/Users/employer_setting.ctp, line 24]
2013-09-13 08:17:32 Error: [FatalErrorException] parse error
#0 /Users/petarpetrov/jobsAdvent/sunshine/lib/Cake/Error/ErrorHandler.php(161): ErrorHandler::handleFatalError(4, 'parse error', '/Users/petarpet...', 24)
#1 [internal function]: ErrorHandler::handleError(4, 'parse error', '/Users/petarpet...', 24, Array)
#2 /Users/petarpetrov/jobsAdvent/sunshine/lib/Cake/Core/App.php(926): call_user_func('ErrorHandler::h...', 4, 'parse error', '/Users/petarpet...', 24, Array)
#3 /Users/petarpetrov/jobsAdvent/sunshine/lib/Cake/Core/App.php(899): App::_checkFatalError()
#4 [internal function]: App::shutdown()
5 {main}
/var/logs/apache2/error_log has no new lines after such error. However, I have the following things there:
[Thu Sep 12 12:43:37 2013] [notice] caught SIGTERM, shutting down
[Thu Sep 12 12:44:08 2013] [warn] Init: Session Cache is not configured [hint: SSLSessionCache]
httpd: Could not reliably determine the server's fully qualified domain name, using ::1 for ServerName
PHP: parse error in /private/etc/php.ini on line 1927
[Thu Sep 12 12:44:08 2013] [notice] Digest: generating secret for digest authentication ...
[Thu Sep 12 12:44:08 2013] [notice] Digest: done
[Thu Sep 12 12:44:08 2013] [notice] Apache/2.2.22 (Unix) DAV/2 PHP/5.3.15 with Suhosin-Patch mod_ssl/2.2.22 OpenSSL/0.9.8x configured -- resuming normal operations
[Thu Sep 12 12:53:55 2013] [notice] child pid 467 exit signal Segmentation fault (11)
[Thu Sep 12 12:53:55 2013] [notice] child pid 466 exit signal Segmentation fault (11)
[Thu Sep 12 13:02:14 2013] [notice] child pid 468 exit signal Segmentation fault (11)
[Thu Sep 12 13:02:33 2013] [notice] child pid 545 exit signal Segmentation fault (11)
[Thu Sep 12 16:21:26 2013] [notice] child pid 463 exit signal Segmentation fault (11)
[Thu Sep 12 16:21:28 2013] [notice] child pid 465 exit signal Segmentation fault (11)
[Fri Sep 13 10:14:50 2013] [notice] child pid 462 exit signal Segmentation fault (11)
Network Tab:
Check app/tmp/logs/error.log
Check the web server error and access logs!
Check the Network tab in chrome and check the response and request there
Or use something like Charles (http://www.charlesproxy.com/) to monitor the request and response
Check what headers the application is returning
FastCgiIpcDir problems in error log
Hi,
I have noticed in my Apache error logs the following error (error 1):
[Wed Feb 08 14:00:06 2012] [alert] [client 41.185.88.175] (2)No such file or directory: FastCGI: failed to connect to (dynamic) server "/var/www/bin/php-splashpage-user/php-fastcgi": something is seriously wrong, any chance the socket/named_pipe directory was removed?, see the FastCgiIpcDir directive
Directly afterwards followed by this error (error 2):
[Wed Feb 08 14:00:06 2012] [error] [client 41.185.88.175] FastCGI: incomplete headers (0 bytes) received from server "/var/www/bin/php-splashpage-user/php-fastcgi"
How do I fix error 1?
I read about changing this due to the host system cleaning out the "/tmp" directory ( the default dir for fastCgiIpcDir if not defined ) periodically and thus obliterating communication with current active FastCGI services. So I decided to give it a go. I set the FastCgiIpcDir in fastcgi.conf file in hopes of success, but there is simply no change.
This is the contents of my fastcgi.conf file:
<IfModule mod_fastcgi.c>
FastCgiIpcDir /var/lib/apache2/fastcgi_test
FastCgiConfig -idle-timeout 60 -maxClassProcesses 1
FastCgiWrapper On
AddHandler php5-fcgi .php
Action php5-fcgi /cgi-bin/php-fastcgi
<Location "/cgi-bin/php-fastcgi">
Order Deny,Allow
Deny from All
Allow from env=REDIRECT_STATUS
Options ExecCGI
SetHandler fastcgi-script
</Location>
</IfModule>
Permissions and onwerships of /var/lib/apache2/fastcgi_test:
drwxr-xr-x 3 www-data www-data 4.0K 2012-02-08 09:20 fastcgi_test
My php wrapper script php_fastcgi has the following lines:
#!/bin/sh
PHP_FCGI_CHILDREN=120
export PHP_FCGI_CHILDREN
PHP_FCGI_MAX_REQUESTS=1000
export PHP_FCGI_MAX_REQUESTS
umask 0022
exec /usr/bin/php-cgi -d apc.shm_size=50
I am running PHP 5.3.1, Apache/2.2.14, Ubuntu 10.04.
Here's few things I've picked up so far:
Error 1 only appears at the beginning of an hour say 6 seconds just after the new hour
From working with mod_FastCgi I have learnt that increasing the child processes help relieve some of the "error 2" errors ( which cause the HTTP 500 error at random intervals). Currently I am not quite sure what the affect of error 1 would be, however if error 2 follows directly after then it's safe to say it's not a good thing.
There is very little, if any, full information on errors reported by Fastcgi with tried and tested solutions. Sadly I may just be adding onto the piles of Fastcgi errors posted on the web with no conclusion.
Your help, advice or tips in resolving error 1 would be readily appreciated.
I don't know how to make it work with a wrapper, and suexec, but you should try this:
http://blog.kmp.or.at/2013/06/apache-2-2-on-debian-wheezy-w-php-fpm-fastcgi-apc-and-a-kind-of-suexec/
The solution in the link does not even use suexec, nor the wrapper, and that way at least it works.
The steps required for that:
0) install php5-fpm, and apache-mpm-worker if not already installed
1) comment this line :
#FastCgiWrapper On
2) make an alias:
Alias /cgi-bin/php-fastcgi **/var/something**
3) fastcgiexternalserver:
FastCgiExternalServer **/var/something** -socket php5-fpm-site1user.sock
(The strongly typed paths must be the same)
4) set up the conf in php5-fpm/pool.d/site1user.conf
[site1user]
user = site1user
group = site1user
listen = /var/run/php5-fpm-site1user.sock
pm = dynamic
pm.max_children = 5
pm.start_servers = 2
pm.min_spare_servers = 1
pm.max_spare_servers = 3
chdir = /
5) restart fpm
service php5-fpm restart
6) for deeper understanding check my other answer here
https://serverfault.com/questions/524708/php5-fpm-apache2-on-wheezy-connect-failed-with-fastcgi/536277#536277