My php website is showing randomly internal error 500 and after refreshing many times it works, in errors, memory allocation problem is showing…
but when i am seeing in root directory’s error_log there is no any error.
Please someone help me to identify the problem.
Thanks for any help!
Here is My php class connection code-
class mysql{
public function __construct($db=array())
{
$default = array(
'host' => 'localhost',
'user' => 'XXXXXXXXX',
'pass' => '*********',
'db' => 'XXXXXXXXX'
);
$db = array_merge($default,$db);
$this->con=new PDO("mysql:host=".$db['host'].";dbname=".$db['db'].";",$db['user'],$db['pass'], array(PDO::ATTR_PERSISTENT => true, PDO::ERRMODE_EXCEPTION => true)) or die ('Error connecting to MySQL');
$this->con->exec("SET CHARACTER SET utf8"); // Sets encoding UTF-8
}
}
And Here Is My php file-
allow_url_fopen = Off
allow_url_include = On
display_errors = On
enable_dl = Off
file_uploads = On
max_execution_time = 30
max_input_time = 60
max_input_vars = 1000
memory_limit = 256M
post_max_size = 8M
session.gc_maxlifetime = 1440
session.save_path = "/var/cpanel/php/sessions/ea-php70"
upload_max_filesize = 2M
zlib.output_compression = Off
And This is my .htaccess file
<IfModule php7_module>
php_flag display_errors On
php_value max_execution_time 30
php_value max_input_time 60
php_value max_input_vars 1000
php_value memory_limit 256M
php_value post_max_size 8M
php_value session.gc_maxlifetime 1440
php_value session.save_path "/var/cpanel/php/sessions/ea-php70"
php_value upload_max_filesize 2M
php_flag zlib.output_compression Off
</IfModule>
In Metrics/Errors It is Showing
[Thu Aug 30 12:30:17.252514 2018] [:error] [pid 31450:tid 139898017253120] (12)Cannot allocate memory: [client 171.61.187.181:50334] couldn’t create child process: /usr/sbin/suphp for /home/abovo/public_html/index.phpWebsite link is – http://abovo.in/
2
Answers
One More Thing I want To Mention Here, I was using "!" in my password, this is a exception, server shows a problem if you are using this, so simply do not use ! in your password.
You should check your server resources.Specially the
swap
area anddisk
storage.Allocating more resources will let PHP to execute your application without memory issues.If you are using linux then you could check them with following commands
Check swap
Check free RAM with
Check disk storage with