Project

General

Profile

Install the MRC PHP Extension » History » Version 8

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

1 1 Amber Herold
h1. MRC PHP Extension Installation and Testing
2
3 4 Amber Herold
mrctools 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 7 Amber Herold
h2. MRC Tools Installation
24 4 Amber Herold
25
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.
26
27
h3. 1 Download "php_mrc_src_1_5_1.tgz":http://emg.nysbc.org/attachments/107/php_mrc_src_1_5_1.tgz.
28
29
h3. 2 cd to your php devel directory
30
31 1 Amber Herold
<pre>
32 4 Amber Herold
> cd /usr/include/php/ext/
33 1 Amber Herold
> mv [downloads]/php_mrc_src_[x].tgz .
34
</pre>
35 5 Amber Herold
36 1 Amber Herold
h3. 3 Untar the archive
37
38 5 Amber Herold
<pre>
39
> tar zxvf php_mrc_src_[x].tgz
40
> cd mrc/
41 1 Amber Herold
</pre>
42 4 Amber Herold
43
h3. 4 Install mrc tools
44 1 Amber Herold
45
<pre>
46
> phpize
47
> ./configure 
48
> make
49
> make install
50
</pre>
51 4 Amber Herold
52
More information on the gd library can be found "here":http://www.php.net/manual/en/image.requirements.php.
53 1 Amber Herold
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.
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
73
You should increase the memory_limit field. It is set to 8M by default. The more the merrier!
74
4kx4k float MRC image is about 64MB
75 1 Amber Herold
76 4 Amber Herold
<pre>
77 1 Amber Herold
memory_limit = 256M; Maximum amount of memory
78
</pre>
79 4 Amber Herold
80 1 Amber Herold
* Check extension_dir value
81 4 Amber Herold
<pre>
82 1 Amber Herold
extension_dir = /usr/lib/php/extensions
83
</pre>
84
85 4 Amber Herold
86
87
* Add the "mrc.so" extension to the end of the *extension section*
88
89
 <pre>
90
 extension=mrc.so
91
 </pre>
92
*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
93
94
*OR*
95
96
 * 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:
97
 <pre>
98
 > cd /etc/php.d
99
 > vi mrc.ini
100
 </pre>
101
 
102
 * add the following lines
103 1 Amber Herold
 <pre>
104
 ; Enable mrc extension module
105 4 Amber Herold
 extension=mrc.so
106
 </pre>
107
108
h3. 7 restart your webserver
109
110
<pre>
111 1 Amber Herold
> /etc/init.d/apache2 restart
112 4 Amber Herold
</pre>
113
 
114 1 Amber Herold
*OR*
115 4 Amber Herold
116
<pre>
117
> /etc/init.d/httpd restart
118 1 Amber Herold
</pre>
119 4 Amber Herold
120
121
h3. 8 Verify the mrc tools installation
122
123
h4. Check php information
124
125
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):
126
127
!http://emg.nysbc.org/software/leginon/images/images/phpmrc.png!
128
129
If mrc is not listed, the extension did not get added in the right order.
130
131
h4. Alternative approach if mrc module does not show up in info.php output
132
133
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/*).
134
135
2. Go to the directory and make a copy of any ini file to use as a template for mrc.ini
136 1 Amber Herold
137 4 Amber Herold
<pre>
138
      >cd [additional_ini_directory]
139 1 Amber Herold
      >cp gd.ini mrc.ini
140
</pre>
141 4 Amber Herold
142 1 Amber Herold
3. Edit mrc.ini to the following
143
144 4 Amber Herold
<pre>
145
      ; comment out next line to disable mrc extension in php
146 1 Amber Herold
      extension=mrc.so
147
</pre>
148 4 Amber Herold
149 1 Amber Herold
4. Comment out mrc extension from php.ini (found in /etc/php.ini/ on a typical PHP installation)
150
151 4 Amber Herold
<pre>
152 1 Amber Herold
      ;extension=mrc.so
153
</pre>
154 4 Amber Herold
155 1 Amber Herold
5. restart your webserver
156
157 4 Amber Herold
<pre>
158 1 Amber Herold
      > /etc/init.d/httpd restart
159
</pre>
160 4 Amber Herold
161 1 Amber Herold
h4. Test the MRC module installation
162
163
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. 
164
* gd module testing script "ex1.php":http://emg.nysbc.org/attachments/53/ex1.php
165
* fftw module testing script "ex2.php":http://emg.nysbc.org/attachments/54/ex2.php
166
167
Run the scripts with the following commands:
168
The expected results are shown below. If you get the same images, you've installed the extension properly.
169
170
<pre>
171
> php -q ex1.php | display
172
</pre>
173
174
* gd module test result:
175
!http://emg.nysbc.org/attachments/57/ex1.php.png!
176
177
<pre>
178
> php -q ex2.php | display
179
</pre>
180 3 Amber Herold
181
* fftw module test result:
182
!http://emg.nysbc.org/attachments/58/ex2.php.png!
183 1 Amber Herold
184
Test files work but images not showing up in the ImageViewers?
185
[[Troubleshooting Notes|Here's one way this was fixed.]]