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