Project

General

Profile

Install the MRC PHP Extension » History » Version 80

Amber Herold, 09/05/2012 11:57 AM

1 21 Amber Herold
h1. Install the MRC PHP Extension
2 1 Amber Herold
3 77 Amber Herold
MRC Tools is installed as a php extension and is required for displaying mrc files live on the web browser.
4
5 78 Amber Herold
*Note:* The MRC PHP Extension is not compatible with PHP 5.3 and greater. For this reason, Appion/Leginon version 3.0 and greater no longer require the MRC PHP extension. Appion/Leginon versions older than 3.0 still require the MRC PHP extension as well as a PHP 5.2.x. 
6 9 Amber Herold
7 1 Amber Herold
8 6 Amber Herold
h2. Make sure you have installed the prerequisite packages
9 1 Amber Herold
10 24 Amber Herold
You may find installation information for the following packages under [[Install Web Server Prerequisites]].
11 6 Amber Herold
12
h3. php-devel
13
14 27 Neil Voss
You can check whether php-devel is installed by typing:
15
<pre>phpize</pre>
16 1 Amber Herold
17 74 Neil Voss
Do not worry about any error message as long as the command is found.
18
&nbsp;
19 4 Amber Herold
20 6 Amber Herold
h3. php-GD/FFTW3-devel
21 4 Amber Herold
22 80 Amber Herold
Make sure that php-GD and FFTW 3 devel libraries are installed. Visit or refresh http://yourhost/info.php which you created earlier. It should have a section looking like this:
23 4 Amber Herold
24 79 Amber Herold
!http://emg.nysbc.org/attachments/1563/gd_phpinfo.jpg!
25 4 Amber Herold
26 11 Amber Herold
*Note:*
27 10 Amber Herold
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":http://www.php.net/manual/en/image.requirements.php. 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.
28 1 Amber Herold
29 10 Amber Herold
h2. MRC Tools Installation
30 4 Amber Herold
31 64 Amber Herold
# Go to the myami/programs/php_mrc directory
32 72 Neil Voss
<pre>
33
cd myami/programs/php_mrc
34
</pre>
35 64 Amber Herold
# Compile and install the MRC module
36 1 Amber Herold
<pre>
37 27 Neil Voss
phpize
38 1 Amber Herold
./configure 
39
make
40 27 Neil Voss
sudo make install
41 4 Amber Herold
</pre>
42 64 Amber Herold
&nbsp;
43
# Check that the mrc.so module exists in your php module directory 
44
&nbsp;
45 48 Amber Herold
(e.g., @/usr/lib64/php/modules@ on 64bit CentOS/RHEL/Fedora). If you are unsure where the php module directory is, use http://localhost/info.php to find it under *extension_dir*.
46 64 Amber Herold
&nbsp;
47 1 Amber Herold
<pre>
48
ls /usr/lib64/php/modules
49
  mrc.so
50 54 Eric Hou
</pre>
51
For Suse
52
<pre>
53
ls /usr/lib64/php5/extensions
54
  mrc.so
55 1 Amber Herold
</pre>
56 64 Amber Herold
# Edit your php configuration file, @php.ini@.
57
&nbsp;
58 1 Amber Herold
If your linux distro does not have a /etc/php.d/ or /etc/php.d/conf.d/ directory where other .ini files reside, you may need to follow the alternate instructions below titled: _Alternative approach if mrc module does not show up in info.php output_.
59 64 Amber Herold
&nbsp;
60 67 Amber Herold
** Confirm the location of "additional .ini files parsed" from the info.php web page (/etc/php.d in this example)
61 1 Amber Herold
and create a file called  "mrc.ini" in this directory. This may be done with the following series of commands:
62
<pre>
63 31 Neil Voss
cd /etc/php.d
64 1 Amber Herold
sudo touch /etc/php.d/mrc.ini
65 31 Neil Voss
sudo chmod 666 mrc.ini
66 33 Neil Voss
echo "; Enable mrc extension module" > mrc.ini
67 1 Amber Herold
echo "extension=mrc.so" >> mrc.ini
68
sudo chmod 444 mrc.ini
69
cat mrc.ini
70
</pre>
71 64 Amber Herold
&nbsp;
72 66 Amber Herold
*OR* as an alternative to the above directions:
73 64 Amber Herold
&nbsp;
74 67 Amber Herold
** Add the "mrc.so" extension to the end of the *extension section*
75 32 Neil Voss
<pre>
76
extension=mrc.so
77 4 Amber Herold
</pre>
78 64 Amber Herold
&nbsp;
79
# Restart your webserver
80
&nbsp;
81 1 Amber Herold
Example commands:
82 50 Amber Herold
<pre>
83
#SuSe
84
/etc/init.d/apache2 restart 
85 64 Amber Herold
&nbsp;
86 50 Amber Herold
#CentOS
87 4 Amber Herold
sudo /sbin/service httpd restart 
88
</pre>
89 64 Amber Herold
&nbsp;
90 71 Amber Herold
*Note:* Sometimes, the MRC module will not work even after restarting the webserver. Try restarting the whole computer: <pre>sudo reboot</pre>
91 64 Amber Herold
&nbsp;
92
# Verify the mrc tools installation
93
&nbsp;
94 4 Amber Herold
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):
95 64 Amber Herold
&nbsp;
96 4 Amber Herold
!http://emg.nysbc.org/software/leginon/images/images/phpmrc.png!
97 64 Amber Herold
&nbsp;
98 4 Amber Herold
If mrc is not listed, the extension did not get added in the right order.
99 1 Amber Herold
100 51 Amber Herold
h3. Alternative approach if mrc module does not show up in info.php output
101 4 Amber Herold
102
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/*).
103
104
2. Go to the directory and make a copy of any ini file to use as a template for mrc.ini
105 1 Amber Herold
106 4 Amber Herold
<pre>
107
      >cd [additional_ini_directory]
108 1 Amber Herold
      >cp gd.ini mrc.ini
109
</pre>
110 4 Amber Herold
111 1 Amber Herold
3. Edit mrc.ini to the following
112
113 4 Amber Herold
<pre>
114
      ; comment out next line to disable mrc extension in php
115 1 Amber Herold
      extension=mrc.so
116
</pre>
117 4 Amber Herold
118 1 Amber Herold
4. Comment out mrc extension from php.ini (found in /etc/php.ini/ on a typical PHP installation)
119
120 4 Amber Herold
<pre>
121 1 Amber Herold
      ;extension=mrc.so
122
</pre>
123 4 Amber Herold
124 16 Amber Herold
5. Restart your webserver
125 1 Amber Herold
126 4 Amber Herold
<pre>
127 1 Amber Herold
      > /etc/init.d/httpd restart
128
</pre>
129 4 Amber Herold
130 1 Amber Herold
h4. Test the MRC module installation
131
132 62 Anchi Cheng
In the myami/php_mrc (or myami/programs/php_mrc if installing from trunk) directory, you will find two test scripts, "ex1.php" and "ex2.php" and a test MRC image "mymrc.mrc". 
133 1 Amber Herold
134 55 Jim Pulokas
Copy them to your top level web directory (for example on CentOS: /var/www/html/):
135 43 Neil Voss
<pre>
136 73 Neil Voss
cd myami/programs/php_mrc
137
sudo cp ex1.php ex2.php mymrc.mrc /var/www/html/
138 39 Neil Voss
</pre>
139 37 Neil Voss
140 44 Neil Voss
Run the scripts with the following commands and visit the corresponding pages from the web server:
141 56 Jim Pulokas
The expected results are shown below. If you get the same images, you've installed the extension properly.
142
Note:  the "display" command is part of the ImageMagick package, which you may have to install.
143 1 Amber Herold
144 44 Neil Voss
web server: http://localhost/ex1.php
145
146 1 Amber Herold
<pre>
147 41 Neil Voss
php -q ex1.php | display
148 1 Amber Herold
</pre>
149
150
* gd module test result:
151
!http://emg.nysbc.org/attachments/57/ex1.php.png!
152 44 Neil Voss
153
web server: http://localhost/ex2.php
154 1 Amber Herold
155
<pre>
156 41 Neil Voss
php -q ex2.php | display
157 1 Amber Herold
</pre>
158 3 Amber Herold
159
* fftw module test result:
160
!http://emg.nysbc.org/attachments/58/ex2.php.png!
161 1 Amber Herold
162
Test files work but images not showing up in the ImageViewers?
163 60 Anchi Cheng
[[appion:Troubleshooting Notes|Here's one way this was fixed.]]
164 22 Amber Herold
165
______
166
167 75 Amber Herold
[[Download Appion and Leginon Files|< Download Appion and Leginon Files]] | [[Install_SSH_module_for_PHP_webserver|Install SSH module for PHP >]]
168 25 Amber Herold
169
170
______