Project

General

Profile

Actions

Install the MRC PHP Extension » History » Revision 11

« Previous | Revision 11/80 (diff) | Next »
Amber Herold, 04/06/2010 11:49 AM


MRC PHP Extension Installation and Testing

MRC Tools is installed as a php extension and is required for displaying mrc files live on the web browser.

Make sure you have installed the prerequisite packages

You may find installation information for the following packages under Web Server Prerequisites.

php-devel

You can check whether php-devel is installed by typing

 >phpize

php-GD/FFTW3-devel

Make sure that php-GD and FFTW 3 devel libraries are installed.

TODO: provide a screenshot of info.php when correctly installed.

Note:
MRCtools are compiled and added to php extension with php-devel package. MRCtools use GD and FFTW3 that need to be compiled from their development libraries while the extension is compiled. If GD and FFTW3 sources were downloaded and compiled directly on your computer, these development files are included. If (as in most cases) GD and FFTW3 are installed from rpm, they are not included. An error message will appear when you attempt to compile mrctools. In this case, you will need separate download and installation of GD-devel and FFTW3-devel. Search http://rpmfind.net/linux/rpm2html/ for GD-devel and FFTW3-devel for the rpm distribution needed for your system. More information on the gd library can be found here. If you find that you can only view images as png instead of jpg, it may be that you do not have gd jpeg support installed.

MRC Tools Installation

mrctools is installed from the php devel directory. This is usually located in /usr/include/php/ext where you will find other php extension source such as gd. After the installation, mrc.so should be placed in php's extension directory. The location of the extension directory can be found by looking for "extension_dir" in http://your_host/info.php.

1 Download php_mrc_src_1_5_1.tgz.

2 cd to your php devel directory

> cd /usr/include/php/ext/
> mv [downloads]/php_mrc_src_[x].tgz .

3 Untar the archive

> tar zxvf php_mrc_src_[x].tgz
> cd mrc/

4 Install mrc tools

> phpize
> ./configure 
> make
> make install

5 mrc.so should be in your php extension directory

> ls /usr/lib/php/extensions
mrc.so

6 Edit your php configuration file.

> vi /etc/php.ini
  • Increase memory

You should increase the memory_limit field. It is set to 8M by default. The more the merrier!
4kx4k float MRC image is about 64MB

memory_limit = 256M; Maximum amount of memory
  • Check extension_dir value
    extension_dir = /usr/lib/php/extensions
    
  • Add the "mrc.so" extension to the end of the extension section
     extension=mrc.so
     

    Note: If you do not see a number of extensions already activated in this section, you should probably follow the alternative path below to enable the extension in a separate file

OR

  • if your linux distro has a /etc/php.d/ or /etc/php.d/conf.d/ directory where other .ini files reside, create and edit mrc.ini:
     > cd /etc/php.d
     > vi mrc.ini
     
  • add the following lines
     ; Enable mrc extension module
     extension=mrc.so
     

7 restart your webserver

> /etc/init.d/apache2 restart

OR

> /etc/init.d/httpd restart

8 Verify the mrc tools installation

Check php information

Visit or refresh http://yourhost/info.php which you created earlier. It should have a section looking like this (The version should correspond to what you've just installed):

If mrc is not listed, the extension did not get added in the right order.

Alternative approach if mrc module does not show up in info.php output

1. find in the info.php web page the location of "additional .ini files parsed" in the first table (such as /etc/php.d/conf.d/*).

2. Go to the directory and make a copy of any ini file to use as a template for mrc.ini

      >cd [additional_ini_directory]
      >cp gd.ini mrc.ini

3. Edit mrc.ini to the following

      ; comment out next line to disable mrc extension in php
      extension=mrc.so

4. Comment out mrc extension from php.ini (found in /etc/php.ini/ on a typical PHP installation)

      ;extension=mrc.so

5. restart your webserver

      > /etc/init.d/httpd restart

Test the MRC module installation

Download this MRC file mymrc.mrc and the following 2 scripts into the same directory to test the PHP mrc extension.

Run the scripts with the following commands:
The expected results are shown below. If you get the same images, you've installed the extension properly.

> php -q ex1.php | display
  • gd module test result:
> php -q ex2.php | display
  • fftw module test result:

Test files work but images not showing up in the ImageViewers?
Here's one way this was fixed.

Updated by Amber Herold over 14 years ago · 11 revisions