Archive for the ‘PHP’ category

Upgrading PHP on Redhat/CentOS/Fedora

March 14th, 2008

To upgrade Php on Redhat, CentOS or Fedora, simply do the following; (Note: you will have to be longed in via SSH to do this)

Step 1) Set up the atomic channel:

wget -q -O – http://www.atomicorp.com/installers/atomic.sh | sh

Step 2) Upgrade to PHP 5.2.x:

Yum update php  (Note: Yum will have to be installed first, if it is not, please follow this link – http://www.keithdmitchell.com/archives/43)

Step 3) Replace the PHP 4 php.ini with PHP 5.2.x’s (if applicable, however this is not needed if you are doing an install for plesk as it can cause issues.):

mv /etc/php.ini.rpmnew /etc/php.ini

Step 4) Replace the php.conf with the PHP 5.2.x php.conf (if applicable):

mv /etc/httpd/conf.d/php.conf.rpmnew /etc/httpd/conf.d/php.conf

Step 5) Restart the webserver

service httpd restart

Checklist

1) Source code installations of extensions, like Ioncube loader, or other extensions that have to be updated. Ive created php-ioncube-loader, php-zend-optimizer, and php-eaccelerator packages to fix this for you automatically.

2) php.ini settings, like memory_limit

3) execstack -c on any extensions that claim to need an executible stack (ASL users only).

Known Issues

1) VPS and RHEL users, If you dont use the atomic installer, you’re going to miss some dependencies, like sqlite3. Have fun with that!

2) RHEL4 users (and possibly others) can resolve the sqlite3 dependencies by grabbing rpms from the CentOS repositories. The atomic installer fixes this for you automatically. If you dont use it… have fun with that!

rpm -Uvh http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-3.3.6-2.i386.rpm http://isoredirect.centos.org/centos/4/os/i386/CentOS/RPMS/sqlite-devel-3.3.6-2.i386.rpm
up2date php

OR

yum update php

Works like a charm

3) PHP 5.2.5 causes problems with Horde and Apache configuration files on PSA 8.2.1 and lower. PSA 8.3.0 has fixed this problem, so the easiest way to fix these issues is to upgrade to PSA 8.3.0 or higher. Otherwise, you’ll need to perform the following extra steps:

3a) Modify /etc/httpd/conf.d/zz010_psa_httpd.conf

Change this:

php_admin_value include_path "/usr/share/psa-horde:/usr/share/psa-horde/pear:."

to

php_admin_value include_path "/usr/share/psa-horde/lib:/usr/share/psa-horde:/usr/share/psa-horde/pear:."

Note this file is changed every time plesk is updated, so you’ll need to go back and fix this when it does.

This also fixes the PHP Fatal error: Can’t load Horde/SessionObjects.php, open_basedir restriction problem.

3b) General issues with php_admin_value:

The fix for now is to replace the use of php_admin_value with php_value. I have only tested this as far as the domains on this server. You will find this used all over the place in zz010_psa_httpd.conf, domain level httpd.includes, and most likely in your own customizations. The biggest problems Ive had are with register_globals and include_path, I have not run into any issues with PSA httpd.include files and open_basedir.

Install PHP5 for Windows (IIS)

February 14th, 2008

To install PHP, please follow these steps:

  1. Log into your server through Terminal Services or Remote Desktop Connection.
  2. Open a Web browser and load http://www.php.net/downloads.php
  3. Download the Windows PHP5.x ZIP package.
  4. Create a new directory, c:\PHP.
  5. Unzip the file you downloaded above into c:\PHP.
  6. Create a new directory, C:\PHP\phpsessions.
  7. Right click the C:\PHP folder and select Properties.
  8. On the Security Tab click Add.
  9. Type IUSR_COMPUTERNAME (where computer name is the name of your computer) in the text area, click Check Names and then click OK.
  10. Select the IUSR_COMPUTERNAME user, check the Full Control box and click OK.
  11. Open C:\PHP\php.ini-dist in Notepad.
  12. Within the file, make the following replacements:
    • Replace ;extension=php_mysql.dll with extension=php_mysql.dll
    • Replace ;session.save_path = “/tmp” with session.save_path = “C:\PHP\phpsessions”
    • Replace session.gc_maxlifetime = 1440 with session.gc_maxlifetime = 43200
    • Replace SMTP = localhost with SMTP = smtp.yourdomain.com
    • Replace ;sendmail_from = me@example.com with sendmail_from = user@yourdomain.com
  13. Save the file as C:\windows\php.ini.
  14. Copy C:\PHP\libmysql.dll and C:\PHP\ext\php_mysql.dll to the C:\windows\system32 folder.
  15. Open IIS located under Control Panel -> Administrative Tools -> Internet Information Services (IIS) Manager.
  16. Right click Web Service Extensions and select Add a new Web service extension.
  17. Enter php as the Extension Name, check Set extension status to Allowed and Click Add.
  18. Enter the path to C:\PHP\php5isapi.dll and click OK.
  19. Right click Web Sites and select Properties.
  20. On the ISAPI Filters tab, click Add.
  21. Enter php as the Filter Name, enter C:\PHP\php5isapi.dll as the Executable and click OK.
  22. On the Home Directory tab, click Configuration.
  23. Click Add.
  24. Enter C:\PHP\php5isapi.dll as the Executable, enter php as the Extension and click OK.
  25. On the Documents Tab, click Add.
  26. Enter index.php and click OK.
  27. A popup box may appear asking if you want to apply the settings to certain websites. Choose specific websites to enable PHP on or Select All and click OK.
  28. Right click your Computer Name, expand All Tasks and click Restart IIS.
  29. Choose Restart IIS from the dropdown menu and click OK.

To test your installation of PHP, please follow these steps:

  1. Open up Notepad and create a new document.
  2. Add the following text into your new document: <?php phpinfo(); ?>
  3. Save this new file to your website root as phpinfo.php.
  4. In a Web browser, navigate to phpinfo.php.

You should have an output screen of all of the information regarding PHP for your server.

Install PHP5 for Windows (Apache2)

February 14th, 2008
  1. Download & Unpack

    Download and install PHP from http://www.php.net/downloads.php, you should grab the newest 5.x.x Windows Binary zip package that will work on apache.

    My file was named: php-5.2.4-Win32.zip

  2. Unzip php. In my case, I unzipped to:
    C:\php\
  3. Rename C:\php\php.ini-dist it to php.ini
  4. Edit your php.ini

    Open php.ini in a text editor and scroll down about halfway through the file and look for doc_root then change it to point to whatever your Apache DocumentRoot is set to. In my case: doc_root = “e:\public_html”

    Scroll down about 7 more lines and change the extension_dir from extension_dir = “./” to the location of the ext directory after you unzipped PHP. in my case: extension_dir = “C:\php\ext”

    and add the files you want apache to look for when a directory is loaded (if it doesn’t find any of these files, it displays folder contents). Mine looks like:

    <IfModule dir_module>
         DirectoryIndex index.php index.html default.html
    </IfModule>
  5. Testing

    Restart Apache if it is already running (if it doesn’t start or you get errors, use your Apache “Test Configuration” shortcut in the Start Menu to see why).

    To test your PHP simply create a test.php file in your Apache “DocumentRoot” folder (C:\public_html\ in my case). In your test.php file, type these 3 lines and then load the file in your browser like http://localhost/test.php (you should get a whole long list of php variables, settings, etc):

    <?php
    phpinfo();
    ?>
  6. Documentation Suggestion

    One weird thing I have noticed about PHP is that it does not come with documentation of any kind. If you are a php developer/programmer, I suggest you download the documentation. Downloads can be found on http://www.php.net/download-docs.php and I personally recommend the “English – Windows HTML Help” (chm) version as the search is so handy, although they all contain the same information.