Project

General

Profile

Install the MRC PHP Extension » History » Version 4

Amber Herold, 04/06/2010 11:11 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 4 Amber Herold
h2. Install php-devel packages on the web server if missing:
6 1 Amber Herold
7 4 Amber Herold
You can check whether php-devel is installed by typing
8 1 Amber Herold
9
<pre>
10 4 Amber Herold
 >phpize
11
</pre>
12
13
Follow the instructions for your specific Linux distribution.
14
For example, SUSE users can use YaST or zypper to install them.
15
16
h2. php-GD/FFTW3-devel
17
18
Follow instructions from the download site. These may be included already. If not, the mrctools installation will fail.
19
*TODO:* add link to prereqs
20
21
h2. mrctools Installation
22
23
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.
24
25
h3. 1 Download "php_mrc_src_1_5_1.tgz":http://emg.nysbc.org/attachments/107/php_mrc_src_1_5_1.tgz.
26
27
h3. 2 cd to your php devel directory
28
29
<pre>
30 1 Amber Herold
> cd /usr/include/php/ext/
31 4 Amber Herold
> mv [downloads]/php_mrc_src_[x].tgz .
32 1 Amber Herold
</pre>
33
34 4 Amber Herold
h3. 3 untar the archive
35 1 Amber Herold
36
<pre>
37 4 Amber Herold
> tar zxvf php_mrc_src_[x].tgz
38 1 Amber Herold
> cd mrc/
39
</pre>
40
41 4 Amber Herold
h3. 4 Make sure that php-GD and FFTW 3 devel libraries are installed
42 1 Amber Herold
43 4 Amber Herold
*TODO:* Combine this section with the others dealing with this and provide a screenshot of info.php when correctly installed.
44
45 1 Amber Herold
<pre>
46
> phpize
47
> ./configure 
48
> make
49
> make install
50
</pre>
51
52 4 Amber Herold
More information on the gd library can be found "here":http://www.php.net/manual/en/image.requirements.php.
53
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 1 Amber Herold
55
56 4 Amber Herold
h3. 5 mrc.so should be in your php extension directory
57
58 1 Amber Herold
<pre>
59
> ls /usr/lib/php/extensions
60 4 Amber Herold
mrc.so
61 1 Amber Herold
</pre>
62
63
64
65 4 Amber Herold
h3. 6 Edit your php configuration file.
66
67 1 Amber Herold
<pre>
68
> vi /etc/php.ini
69
</pre>
70
71 4 Amber Herold
* 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
76 1 Amber Herold
<pre>
77 4 Amber Herold
memory_limit = 256M; Maximum amount of memory
78 1 Amber Herold
</pre>
79
80 4 Amber Herold
* Check extension_dir value
81 1 Amber Herold
<pre>
82 4 Amber Herold
extension_dir = /usr/lib/php/extensions
83 1 Amber Herold
</pre>
84
85
86 4 Amber Herold
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
 <pre>
104 1 Amber Herold
 ; Enable mrc extension module
105
 extension=mrc.so
106 4 Amber Herold
 </pre>
107
108
h3. 7 restart your webserver
109
110
<pre>
111
> /etc/init.d/apache2 restart
112 1 Amber Herold
</pre>
113 4 Amber Herold
 
114
*OR*
115 1 Amber Herold
116 4 Amber Herold
<pre>
117
> /etc/init.d/httpd restart
118
</pre>
119 1 Amber Herold
120 4 Amber Herold
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
137 1 Amber Herold
<pre>
138 4 Amber Herold
      >cd [additional_ini_directory]
139
      >cp gd.ini mrc.ini
140 1 Amber Herold
</pre>
141
142 4 Amber Herold
3. Edit mrc.ini to the following
143 1 Amber Herold
144
<pre>
145 4 Amber Herold
      ; comment out next line to disable mrc extension in php
146
      extension=mrc.so
147 1 Amber Herold
</pre>
148
149 4 Amber Herold
4. Comment out mrc extension from php.ini (found in /etc/php.ini/ on a typical PHP installation)
150 1 Amber Herold
151
<pre>
152 4 Amber Herold
      ;extension=mrc.so
153 1 Amber Herold
</pre>
154
155 4 Amber Herold
5. restart your webserver
156 1 Amber Herold
157
<pre>
158 4 Amber Herold
      > /etc/init.d/httpd restart
159 1 Amber Herold
</pre>
160
161 4 Amber Herold
h4. Test the MRC module installation
162 1 Amber Herold
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
181 3 Amber Herold
* fftw module test result:
182
!http://emg.nysbc.org/attachments/58/ex2.php.png!
183
184 1 Amber Herold
Test files work but images not showing up in the ImageViewers?
185
[[Troubleshooting Notes|Here's one way this was fixed.]]