This site utilizes JavaScript to function correctly. Looks like it's disabled on your browser. Please enable it for your best experience.

For instructions on enabling JavaScript, click here

Skip to main content

Just Host Web Hosting Help

PHP Script Throws Server 500 Error

Here are some possibilities as to why you are getting 500 errors with php scripts.

When a php script requires write access to a file or directory (like Nucleus does for the 'media'-directory if you want to be able to upload pictures etc), you have to chmod that directory (or file) to 777 (or 666 for files) on most servers. This gives world write access to this folder (file). This is because on most servers apache (and php) runs as user 'nobody'.
Although giving world write access will make it possible to use the script, it also means a security hole, which can be used by hackers and other riff-raff.

To avoid this security hole we run phpsuexec on our servers. Using phpsuexec, php runs under your own username on the server. This removes the necessity to make files and folders world writable. Instead you can just use 755 for folders (the default) and 644 for files (also the default).

Using phpsuexec may have some consequences. Specific statements in your .htaccess file may result in an error 500 (internal server error). So here are two possible problems, and how to solve them:

ForceType

When you are using files with (or without) an extension different then the normal extension for that filetype you can use ForceType in your .htaccess file to make it clear to the server how to handle that file (or all the files in the folder) (this works on servers without phpsuexec).
An example: When you have a file called 'item' (like Nucleus uses for FancyURL's) and want it to be parsed by the server as php you use the following code in your .htaccess file:

However, because our servers use phpsuexec this will result in an internal server error. To solve this you can simply use SetHandler instead of ForceType, so your .htaccess-file becomes:

SetHandler application/x-httpd-php

php_value

On a server without phpsuexec it is possible to use the php_value statement in a .htaccess file to change the settings of php (actually overwrite the settings from php.ini). On a sever with phpsuexec this will also result in a server error. To solve this you can use a php.ini file which you put in the same folder as where you would have put your .htaccess file. In that php.ini file you can change all the php values. You only have to put the values you want to modify in that file. By example if you want to set the short_open_tag to Off you would have used short_open_tag? = off in your .htaccess file. Using a php.ini file this results in:
[PHP]
            
            short_open_tag = Off

Knowledgebase Article 250,469 views bookmark tags: directive forcetype phpsuexec tricks


Was this resource helpful?

Did this resolve your issue?


Please add any other comments or suggestions about this content:





Recommended Help Content

In the newer versions of PHP, they have included a new directive to control and handle remote includes. We disable this option, by default, which may affect some of your PHP scripts.
Knowledgebase Article 180,329 views tags: include php remote url

500 Internal Server Error when installing via the MOJO Marketplace installer.
Knowledgebase Article 283,458 views tags: cpanel errors htaccess panel php script simpel

This article will explain some common causes for 500 errors on Dedicated or V.P.S servers.
Knowledgebase Article 129,319 views tags: dedi dedicated error server vps

Related Help Content

How to customize your html or php error pages.
Knowledgebase Article 162,841 views tags: errors php

Website shows a server 500 error, what can I do to fix it?
Knowledgebase Article 717,080 views tags: error

How do I change the PHP environment for my site with php.ini?
Knowledgebase Article 807,774 views tags: configuration ini php server

How do I turn the display_errors flag on for php?
Knowledgebase Article 229,759 views tags: display errors php

This article will show a few MySQL errors along with explanations as to why they might be occurring.
Knowledgebase Article 131,187 views tags: errors mysql

When I attempt to execute my Ruby on Rails application I receive "500- Premature end of script."
Knowledgebase Article 168,573 views tags: premature rails ruby script

Script executed with a cron job requires a specific php.ini file to be used.
Knowledgebase Article 224,978 views tags: command cron cronjob crontab custom line optimizer php zend

How do I avoid Outlook IMAP timeout errors?
Knowledgebase Article 309,194 views tags: errors imap outlook timeout

** Google ad credits are only available to customers in the United States, Canada, and the United Kingdom at this time.

¹ VAT (Value Added Tax) is not included in our advertised price and will be charged separately and itemized on invoices and billing information. Standard VAT rates based on EU Member State regulations may apply. Learn more.