Top Nav

Archive | PHP

Upgrade PHP on Server with IUS Repository

It’s easy to upgrade between PHP version is you’re using the IUS repository:

http://iuscommunity.org

Start by determining which version and modules you have already installed:

So in this case we have the “php52” packages.

Next decide which package set you want to upgrade to. Right no in IUS the choices are:

  1. php52
  2. php53u
  3. php54

IUS provides a great extension for yum which allows for replacing packages:

Now you can replace the PHP version with something like this:

Just change php52 and php53 to the original and new version that you want to replace.

After the install completes run “yum list | grep php | grep installed” again and make sure that you have all the extensions that you need.

0

Block PHP Execution With .htaccess In Folder

For a server using Plesk add the following lines to a .htaccess file to stop execution of PHP scripts in the folder:

I like to use this to protect cache and image upload folders that are writable by the web server but should not be able to execute code.

As a further precaution, chown the .htaccess to root, so it can’t be overwritten by Apache or FTP, and “chattr +i” to be sure about it.

1

PHP Parse error: syntax error, unexpected $end

There are two common causes to this error:

1. You have an actual syntax error in you code that needs to be fixed.

2. Your code is expecting the PHP “short_open_tags” setting to be turned on and it is not.

This second case is common when you’re moving a site between servers – the old server has short_open_tags turned on and the code works but the new site has it turned off and the code breaks.

The solution to the second case is to either (a) modify the code to remove the dependency on short_open_tags or (b) turn on short_open_tags in php.ini or your .htaccess file.

0

Install PHP SSH2 extension on RHEL 5.6 with EPEL repository

Here are the steps to install the PHP SSH2 extention on RHEL 5.6 with the EPEL repository.

  1. Install packages that may be needed:
  2. Temporarily allow binary execution in /tmp
  3. Install the extension:
  4. Restore /tmp restrictions:
  5. Reload apache:
0