Archive for the ‘Website Development’ Category

What is suPHP and what are the benefits?

Sunday, May 24th, 2009

 

The earlier version was PHPsuExec but that is quickly being replaced by suPHP and the two do basically the same thing.

suPHP provides an additional layer of protection on servers. It causes php scripts to run under the account username instead of the user ‘nobody’ which is the user that apache/php would run under on a server that is not running suPHP. This feature allows us to more easily track any potential security breaches that come in via insecure php script(s) that a user is running.

 

suPHP also does away with the requirement of using 777 permissions on directories/files that need write permission. In fact if a directory and/or file has the permission set to (CHMOD) 777 and it is access via a browser, then an internal server error 500 will be generated. The highest level of permissions that a user can use on a suPHP enabled server is 755. This permission setting is sufficient enough for any directories/files that needs to be written to.

 

The benefit of using suPHP besides better security, is that it will make any PHP applications (most often CMS systems) such as Mambo more user friendly. Case in point: If you upload/install anything via Mambo such as a template on a non-suphp server, then those template files will be owned by ‘nobody’ and you will not be able to edit them manually or even delete them from your account. This ownership issue is done away with suPHP. On a suPHP enabled server, those same template files will be owned by the account username and the account holder will be able to manipulate those files as he sees fit.

 

No longer do you need to use (chmod) the dangerous file permission of 666 or the folder permission of 777 to make things writable.

The correct permissions should be:

  • Writable Folders: 755
  • Writable Files: 644
  • Files that need to be un-writable: 444

HTTP Error 500 – Internal server error

Monday, May 18th, 2009

 

If you are receiving the error 500 it will be due to one of the following issues:

  • .htaccess

Check your .htaccess file for php_ commands. If you have any, add a # in front of the line or delete them. Then test your webpage. If you still have the error try removing everything from your .htaccess file. If that resolves the issue add the .htaccess lines back one at time until you find the bad line.

If these steps do not resolve your issue try the next steps.

  • File and folder permissions

Check your files and folders to make sure you don’t have any files with the permission 666 or folders with the permission 777.

 

Those permissions are not needed onĀ our servers. We run suPHP which allows you to make files writable without creating the major security hole that occurs when using the permissions 666 and 777.

 

The correct permissions should be:

Folders: 755

Files: 644

Files that need to be unwritable: 444

  • MIME-Types

If you added a MiME-Type to the system in order to run html files as php scripts, you will have to remove it and add an ApacheHandler instead.

 

Log into cPanel, then click on Apache Handlers and add the following:

Handler: application/x-httpd-php

Extension(s): .html

.htaccess – Change your default directory page.

Friday, May 15th, 2009

 

Some of you may be wondering, just what in the world is a DirectoryIndex? Well, this is a command which allows you to specify a file that is to be loaded as your default page whenever a directory or url request comes in, that does not specify a specific page. Tired of having yoursite.com/index.html come up when you go to yoursite.com? Want to change it to be yoursite.com/ILikePizzaSteve.html that comes up instead? No problem!

 

DirectoryIndex filename.html

 

This would cause filename.html to be treated as your default page, or default directory page. You can also append other filenames to it. You may want to have certain directories use a script as a default page. That’s no problem too!

 

DirectoryIndex filename.html index.cgi index.pl default.htm

 

Placing the above command in your htaccess file will cause this to happen: When a user types in yoursite.com, your site will look for filename.html in your root directory (or any directory if you specify this in the global htaccess), and if it finds it, it will load that page as the default page. If it does not find filename.html, it will then look for index.cgi; if it finds that one, it will load it, if not, it will look for index.pl and the whole process repeats until it finds a file it can use. Basically, the list of files is read from left to right.

 

One thing you have to keep in mind, sub-folders will adopt the .htaccess settings specified within there main folder.