Project

General

Profile

Install the MRC PHP Extension » History » Version 12

Amber Herold, 04/06/2010 11:57 AM

1 1 Amber Herold
h1. MRC PHP Extension Installation and Testing
2
3 9 Amber Herold
MRC Tools is installed as a php extension and is required for displaying mrc files live on the web browser.
4 1 Amber Herold
5 6 Amber Herold
h2. Make sure you have installed the prerequisite packages
6 1 Amber Herold
7 6 Amber Herold
You may find installation information for the following packages under [[Web_Server_Installation#Web-Server-Prerequisites|Web Server Prerequisites]].
8
9
h3. php-devel
10
11 4 Amber Herold
You can check whether php-devel is installed by typing
12
13
<pre>
14 1 Amber Herold
 >phpize
15
</pre>
16 4 Amber Herold
17 6 Amber Herold
h3. php-GD/FFTW3-devel
18 4 Amber Herold
19 6 Amber Herold
Make sure that php-GD and FFTW 3 devel libraries are installed.
20 4 Amber Herold
21 8 Amber Herold
*TODO:* provide a screenshot of info.php when correctly installed.
22 4 Amber Herold
23 11 Amber Herold
*Note:*
24 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.
25
26 7 Amber Herold
h2. MRC Tools Installation
27 4 Amber Herold
28
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.
29
30
h3. 1 Download "php_mrc_src_1_5_1.tgz":http://emg.nysbc.org/attachments/107/php_mrc_src_1_5_1.tgz.
31
32
h3. 2 cd to your php devel directory
33
34 1 Amber Herold
<pre>
35 4 Amber Herold
> cd /usr/include/php/ext/
36 1 Amber Herold
> mv [downloads]/php_mrc_src_[x].tgz .
37
</pre>
38 5 Amber Herold
39 1 Amber Herold
h3. 3 Untar the archive
40
41 5 Amber Herold
<pre>
42
> tar zxvf php_mrc_src_[x].tgz
43
> cd mrc/
44 1 Amber Herold
</pre>
45 4 Amber Herold
46
h3. 4 Install mrc tools
47 1 Amber Herold
48
<pre>
49
> phpize
50
> ./configure 
51 4 Amber Herold
> make
52
> make install
53 1 Amber Herold
</pre>
54
55 4 Amber Herold
56
h3. 5 mrc.so should be in your php extension directory
57 1 Amber Herold
58
<pre>
59 4 Amber Herold
> ls /usr/lib/php/extensions
60 1 Amber Herold
mrc.so
61
</pre>
62
63
64 4 Amber Herold
65
h3. 6 Edit your php configuration file.
66 1 Amber Herold
67
<pre>
68
> vi /etc/php.ini
69
</pre>
70 4 Amber Herold
71
* Increase memory
72 12 Amber Herold
Check that you increased the memory_limit field while configuring php.ini. 
73
It is set to 8M by default. A 4kx4k float MRC image is about 64MB.
74
At NRAMM, it is set to 4000M.
75 4 Amber Herold
<pre>
76 12 Amber Herold
memory_limit = 4000M; Maximum amount of memory
77 1 Amber Herold
</pre>
78 4 Amber Herold
79 1 Amber Herold
* Check extension_dir value
80 4 Amber Herold
<pre>
81 1 Amber Herold
extension_dir = /usr/lib/php/extensions
82
</pre>
83 4 Amber Herold
84
85
86
* Add the "mrc.so" extension to the end of the *extension section*
87
 <pre>
88
 extension=mrc.so
89
 </pre>
90
*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
91
92
*OR*
93
94
 * 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:
95
 <pre>
96
 > cd /etc/php.d
97
 > vi mrc.ini
98
 </pre>
99
 
100
 * add the following lines
101 1 Amber Herold
 <pre>
102
 ; Enable mrc extension module
103 4 Amber Herold
 extension=mrc.so
104
 </pre>
105
106
h3. 7 restart your webserver
107
108
<pre>
109 1 Amber Herold
> /etc/init.d/apache2 restart
110 4 Amber Herold
</pre>
111
 
112 1 Amber Herold
*OR*
113 4 Amber Herold
114
<pre>
115
> /etc/init.d/httpd restart
116 1 Amber Herold
</pre>
117 4 Amber Herold
118
119
h3. 8 Verify the mrc tools installation
120
121
h4. Check php information
122
123
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):
124
125
!http://emg.nysbc.org/software/leginon/images/images/phpmrc.png!
126
127
If mrc is not listed, the extension did not get added in the right order.
128
129
h4. Alternative approach if mrc module does not show up in info.php output
130
131
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/*).
132
133
2. Go to the directory and make a copy of any ini file to use as a template for mrc.ini
134 1 Amber Herold
135 4 Amber Herold
<pre>
136
      >cd [additional_ini_directory]
137 1 Amber Herold
      >cp gd.ini mrc.ini
138
</pre>
139 4 Amber Herold
140 1 Amber Herold
3. Edit mrc.ini to the following
141
142 4 Amber Herold
<pre>
143
      ; comment out next line to disable mrc extension in php
144 1 Amber Herold
      extension=mrc.so
145
</pre>
146 4 Amber Herold
147 1 Amber Herold
4. Comment out mrc extension from php.ini (found in /etc/php.ini/ on a typical PHP installation)
148
149 4 Amber Herold
<pre>
150 1 Amber Herold
      ;extension=mrc.so
151
</pre>
152 4 Amber Herold
153 1 Amber Herold
5. restart your webserver
154
155 4 Amber Herold
<pre>
156 1 Amber Herold
      > /etc/init.d/httpd restart
157
</pre>
158 4 Amber Herold
159 1 Amber Herold
h4. Test the MRC module installation
160
161
Download this MRC file "mymrc.mrc":http://emg.nysbc.org/attachments/55/mymrc.mrc and the following 2 scripts into the same directory to test the PHP mrc extension. 
162
* gd module testing script "ex1.php":http://emg.nysbc.org/attachments/53/ex1.php
163
* fftw module testing script "ex2.php":http://emg.nysbc.org/attachments/54/ex2.php
164
165
Run the scripts with the following commands:
166
The expected results are shown below. If you get the same images, you've installed the extension properly.
167
168
<pre>
169
> php -q ex1.php | display
170
</pre>
171
172
* gd module test result:
173
!http://emg.nysbc.org/attachments/57/ex1.php.png!
174
175
<pre>
176
> php -q ex2.php | display
177
</pre>
178 3 Amber Herold
179
* fftw module test result:
180
!http://emg.nysbc.org/attachments/58/ex2.php.png!
181 1 Amber Herold
182
Test files work but images not showing up in the ImageViewers?
183
[[Troubleshooting Notes|Here's one way this was fixed.]]