cPanel Hosting/Apache Premature End of Script – 6 Ways to Fix – in 2022

July 22nd, 2015 by admin Leave a reply »

This is painful error specialy for commerical website, If you are getting a 500 internal server error (apache premature end of script) then don't worry, We can help you in fixing this error.



First solution: (Required Root access/WHM Access)

There is high chances that your error will not fixed by this method however its worth to at lest try this.

Login to your WHM Account, go to "Easy Apache" and rebuild apache without changing anything.



Second Solution: (Root access)

If you make any changes to folder /usr/local/apache/conf/includes/somefiles then rever it for temproary time and restart apache by running this command.

service httpd restart



Third and Final Way:

If you have a root access then paste following code inside your home folder in .htaccess file  –  /home/.htaccess

suPHP_ConfigPath /usr/local/lib/php.ini


If you don't have a root access then don't worry, You can paste this code in your public_html/.htaccess file or If you have a hosting account with us then open a ticket and we will fix this error for you.

Note: Make sure to change php filepath acording to your server file path, on some servers php located inside /usr/lib/.


Other fix:

Remove RLimitCPU/RLimitMEM limit from your httpd.conf file, restart apache and then recheck.


How to check whereis php.ini file is located?

Login to your Dewlance VPS SSH Root account and type this command:

whereis php


You will get output like /usr/lib/php.ini, It means your php is located in /usr/lib/ folder.





Still cPanel 500 error not fixed?

In php.ini file: 

Open your php.ini file and increase memory limit of your php script.


memory_limit = 260M;  

(Recommended limit by Dewlance)


Via cPanel/WHM:

Go to Server Configuration >> PHP Configuration Editor >> Search for "memory_limit" and increase memory limit value to 260 or more, then scroll down and click on the "Save" button.





Other possible issue:

Are you sure that your file permission is not set to different user? Many users create file from root account and forget to change permission.

If your account username is: xyzuser then you can use this command on SSH to change permission of your file.

chown Myuser:Myuser  /home/youruser/public_html/yourfilename.php


Leave a Reply