Project

General

Profile

Install the MRC PHP Extension » History » Version 18

Amber Herold, 04/06/2010 12:26 PM

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