Project

General

Profile

Install the MRC PHP Extension » History » Version 5

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