PDA

View Full Version : Installing mailparse from source on linux


BlueC
09-25-2007, 11:40 PM
I found I couldn't install mailparse through pecl as it complained about requiring mbstring (despite the fact that mbstring is installed and working). Apparently this is a problem with certain versions of php/pear/mailparse/mbstring.

So, I found I needed to install mailparse from source, and the instructions weren't in the wiki so here I thought I'd share how I did it...

(This was on RHEL4 but I think it should apply the same to any linux distro. The only differences are likely to be the location of your php.ini files - but you should know where they are already!)

All the below was done as root user in /root and you must already have the php mbstring extension loaded.

1. Download mailparse source from http://pecl.php.net/package/mailparse - for example...

$ wget http://pecl.php.net/get/mailparse-2.1.1.tgz

2. Extract it...

$ tar xzvf mailparse-2.1.1.tgz

3. Change to the extracted directory...

$ cd mailparse-2.1.1

4. Issue the following commands to make and install the mailparse php module...

$ phpize
$ ./configure
$ make
$ make install

A successful install will copy mailparse.so into the php extensions directory.

5. Now you will need to add the following line to /etc/php.ini or create the file /etc/php.d/z-mailparse.ini and add it to that (depending on how you have php configured to load extensions)

extension=mailparse.so

Note: In my case I found that mailparse MUST be loaded AFTER mbstring otherwise it wouldn't work. This is why the /etc/php.d/z-mailparse.ini file is prefixed with a "z-" in the example above to ensure that it is executed after the /etc/php.d/mbstring.ini file!

6. Now restart apache and check that mailparse is loaded either using phpinfo() or using the cerberus compatibility checker script.

Please feel free to post any corrections/additions to this. Maybe it will make it into the wiki in some form!

Cheers
Chris

jstanden
09-25-2007, 11:55 PM
Made this post a sticky.

And yeah this should definitely find it's way into the wiki documentation. :) Thanks for that!

I've had to do the manual compile on a couple machines already. If anybody runs into mbstring header issues on compile, this bug report may be useful:
http://pecl.php.net/bugs/bug.php?id=6239

On some machines I've had luck copying the mbstring source into mailparse/ext/mbstring/. In other instances I've edited the "#IFDEF" in the mailparse source to remove the error check for mbstring (after confirming mbstring was already compiled into PHP).

Great work!

rfarnell
12-14-2007, 06:25 PM
I too am on RHEL4 and have just tried this with the new version of mailparse released in November
$ get http://pecl.php.net/get/mailparse-2.1.2.tgz

My first problem was that phpize wasn't a recommended command. up2date php-devel fixed that problem. Secondly when I ran "make test" a hundred error messages appeared. Should I be concerned about this?

See the results of the make test:


PHP Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_odbc.so' - modules/pdo_odbc.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_odbc.so' - mod ules/pdo_odbc.so: cannot open shared object file: No such file or directory in U nknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_pgsql.so' - modules/pdo_pgsql.so: cannot open shared object file: No such file or directo ry in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_pgsql.so' - mo dules/pdo_pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so ' - modules/pdo_sqlite.so: cannot open shared object file: No such file or direc tory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pdo_sqlite.so' - m odules/pdo_sqlite.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/pgsql.so' - m odules/pgsql.so: cannot open shared object file: No such file or directory in Un known on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/pgsql.so' - module s/pgsql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/xmlreader.so' - modules/xmlreader.so: cannot open shared object file: No such file or directo ry in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/xmlreader.so' - mo dules/xmlreader.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/xmlwriter.so' - modules/xmlwriter.so: cannot open shared object file: No such file or directo ry in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/xmlwriter.so' - mo dules/xmlwriter.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/xsl.so' - mod ules/xsl.so: cannot open shared object file: No such file or directory in Unknow n on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/xsl.so' - modules/ xsl.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/zip.so' - mod ules/zip.so: cannot open shared object file: No such file or directory in Unknow n on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/zip.so' - modules/ zip.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/mailparse.so' - modules/mailparse.so: undefined symbol: mbfl_convert_filter_new in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/mailparse.so' - mo dules/mailparse.so: undefined symbol: mbfl_convert_filter_new in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/dom.so' - mod ules/dom.so: cannot open shared object file: No such file or directory in Unknow n on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/dom.so' - modules/ dom.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modu les/gd.so: cannot open shared object file: No such file or directory in Unknown on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/gd.so' - modules/g d.so: cannot open shared object file: No such file or directory in Unknown on li ne 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/imap.so' - mo dules/imap.so: cannot open shared object file: No such file or directory in Unkn own on line 0

Warning: PHP Startup: Unable to load dynamic library 'modules/imap.so' - modules /imap.so: cannot open shared object file: No such file or directory in Unknown o n line 0
PHP Warning: PHP Startup: Unable to load dynamic library 'modules/json.so' - mo dules/json.so: cannot open shared object file: No such file or directory in Unkn own on line 0

rfarnell
12-14-2007, 06:29 PM
There was also a fair amount more unfound modules but I will save you that.

This appeared at the end if it is of any assitance.



================================================== ===================
CWD : /root/mailparse-2.1.2
PHP : /usr/bin/php
PHP_SAPI : cli
PHP_VERSION : 5.2.5
ZEND_VERSION: 2.2.0
PHP_OS : Linux - Linux 2.6.9-67.ELsmp #1 SMP Wed Nov 7 13:58:04 EST 2007 i686
INI actual : /etc/php.ini
More .INIs : /etc/php.d/dom.ini,/etc/php.d/gd.ini,/etc/php.d/imap.ini,/etc/php. d/ioncube-loader.ini,/etc/php.d/json.ini,/etc/php.d/ldap.ini,/etc/php.d/mbstring .ini,/etc/php.d/mysql.ini,/etc/php.d/mysqli.ini,/etc/php.d/odbc.ini,/etc/php.d/p do.ini,/etc/php.d/pdo_mysql.ini,/etc/php.d/pdo_odbc.ini,/etc/php.d/pdo_pgsql.ini ,/etc/php.d/pdo_sqlite.ini,/etc/php.d/pgsql.ini,/etc/php.d/xmlreader.ini,/etc/ph p.d/xmlwriter.ini,/etc/php.d/xsl.ini,/etc/php.d/zip.ini
Extra dirs :
================================================== ===================
Running selected tests.

jstanden
12-15-2007, 11:24 AM
Hey there!

You should be able to comment out any of the extensions you aren't using from your php.ini file. Depending on how your Apache is configured you may have an area like /etc/php.d/ being scanned for config files also.

Without looking at your config I can't say if the 'make test' output will affect your actual PHP scripts. Have you tried running the Cerb4 server checker yet?

rfarnell
12-15-2007, 03:41 PM
It still appears as the following:

Cerberus Helpdesk 4.0 - Server Environment Checker
The following problems prevent you from running Cerberus Helpdesk 4.0:

* upload_tmp_dir is empty in your php.ini file. Please set it.
* The 'MailParse' PHP extension is required. Please enable it.


Please correct these issues and try again.

I do have the php.d config file folder and have tried adding it as /etc/php.d/z-mailparse.ini and restarted Apache. It appears to be scanned in the phpinfo but no change in the environment checker.

Regards,

Rob

axlp
12-24-2007, 07:30 PM
Hi,

After i upgrade php including php-mbstring using yum (atomic) the following error showed up when i enabled mailparse
[root@XXXXX tmp]# /usr/bin/php -m
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/mailparse.so' - /usr/lib64/php/modules/mailparse.so: undefined symbol: mbfl_convert_filter_new in Unknown on line 0
PHP Warning: PHP Startup: (null): Unable to initialize module

I tried several version of mailparse but no luck.
Then I just went into /etc/php.d/
opened mbstring.ini and changed it from
extension=mbstring.so

to
extension=mbstring.so
extension=mailparse.so

[root@XXXX tmp]# /usr/bin/php -m
PHP Warning: PHP Startup: (null): Unable to initialize module
Module compiled with module API=20041030, debug=0, thread-safety=0
PHP compiled with module API=20060613, debug=0, thread-safety=0

[PHP Modules]
bz2
calendar
ctype
curl
date
dbase
dom
exif
filter
ftp
gd
gettext
gmp
hash
iconv
imap
json
ldap
libxml
mailparse
mbstring
mysql
mysqli
openssl
pcntl
pcre
PDO
pdo_mysql
pdo_sqlite
posix
pspell
readline
Reflection
session
shmop
SimpleXML
snmp
sockets
SPL
standard
sysvmsg
sysvsem
sysvshm
tokenizer
wddx
xml
xmlreader
xmlwriter
xsl
Zend Optimizer
zip
zlib

[Zend Modules]
Zend Extension Manager
Zend Optimizer

Now mailparse is showing in command line as well as phpinfo.

hope this helps ..

-Axl

peter_mcc
01-10-2008, 05:11 AM
On some machines I've had luck copying the mbstring source into mailparse/ext/mbstring/. In other instances I've edited the "#IFDEF" in the mailparse source to remove the error check for mbstring (after confirming mbstring was already compiled into PHP).Great work!

Where do I find the source for mbstring? Sorry if it's a dumb question but I didn't compile Apache from source... I'm using ClarkConnect 4.2 which is based on RHEL 5

peter

jstanden
01-10-2008, 10:34 PM
Where do I find the source for mbstring? Sorry if it's a dumb question but I didn't compile Apache from source... I'm using ClarkConnect 4.2 which is based on RHEL 5

Hey Peter!

If you have the 'php5-dev' and 'php5-cli' packages installed, you should have a pecl command in your shell.

You can download the mailparse source with the command:
pecl download mailparse

peter_mcc
01-12-2008, 10:20 AM
Hi

You can download the mailparse source with the command:
pecl download mailparse

My problem is that Mailparse won't install because of a bug with RHEL 5's PHP 5.1.6 install - it's missing the header files for mbstring. So when I go to compile mailparse (from the source, which I have, via PECL) it spits out lots and lots of errors!!

So... I would like to know where to find the source for mbstring.

Regards
Peter

jstanden
01-14-2008, 07:07 AM
Hey Peter!

The mbstring source should be in the PHP 5.1.6 source distro in the /ext/ directory.

peter_mcc
01-15-2008, 03:11 AM
Hi

The mbstring source should be in the PHP 5.1.6 source distro in the /ext/ directory.

Ahhhh, ok. Downloaded the PHP source, extracted all the header files from /etc/mbstring (and subdirectories) into /usr/include/php/ext/mbstring and installed mailparse using pecl install -n mailparse (to ignore the "missing" mbstring dependancy).

After I added extension=mbstring.so & extension=mailparse.so (in that order!) to /etc/php.ini and restarted Apache (service httpd restart) it all worked!

Now I can try to install Cerberus 4...

Peter
PS I've put the steps I followed here incase it helps someone else...

tedora
03-21-2008, 06:20 PM
Hi Everyone,


I appologise, I don't have all the knowledge that you all have in regards to the installation of mailparse. I follow directions very well, and have installed so many programs on my server, including the older version of Cerberus Helpdesk, but I just can't get past this step.

Everything is ready accept that the installation won't recognize mailparse.

When I try to install mailparse, this is the message I get:
----------------------------------------------------------------------

Build complete.
(It is safe to ignore warnings about tempnam and tmpnam).

running: make INSTALL_ROOT="/var/tmp/pear-build-tedora.com/install-mailparse-2.1.3" install
Installing shared extensions: /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1/lib/php/20020429/
running: find "/var/tmp/pear-build-tedora.com/install-mailparse-2.1.3" -ls
228264572 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3
228266592 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr
228266593 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local
228266594 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1
228266595 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1/lib
228266596 0 drwxr-xr-x 3 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1/lib/php
228266597 0 drwxr-xr-x 2 tedora.c tedora.c 60 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1/lib/php/20020429
228266635 124 -rwxr-xr-x 1 tedora.c tedora.c 116713 Mar 21 10:03 /var/tmp/pear-build-tedora.com/install-mailparse-2.1.3/usr/local/php-4.4.8-1/lib/php/20020429/mailparse.so

Build process completed successfully
Installing '/usr/local/php-4.4.8-1/lib/php/20020429/mailparse.so'
ERROR: failed to write /usr/local/php-4.4.8-1/lib/php/20020429/mailparse.so (failed to open stream: Read-only file system)

I would very much appreciate some help from anyone who might be able to guide me through this a little more.

Thank you.

Al

thrca
03-24-2008, 04:19 AM
I wanted to post a followup on this thread in regards to compiling mailparse on a host that has both php4 and php5 installed, for example... MediaTemple.

It took a little playing, but finally got it.. It might be specific to (mt), but thought it might shed some light on getting it to cooperate for some other people.

The key parts here is that I used phpize5 instead of phpize, and used php-config5 instead of php-config. This allowed the ./configure script to locate the proper php headers.


cd /tmp
pecl download mailparse
tar xvzf mailparse-2.1.3.tgz
cd mailparse-2.1.3
phpize5
./configure --with-php-config=/usr/bin/php-config5
make
mkdir /home/#####/data/php5 && mkdir /home/#####/data/php5/lib && mkdir /home/#####/data/php5/lib/php && mkdir \
/home/#####/data/php5/lib/php/extensions
cp modules/mailparse.so /home/#####/data/php5/lib/php/extensions


Then... Edit php.ini and set...

extension_dir=/home/#####/data/php5/lib/php/extensions/
extension=mailparse.so

derr1ck
10-09-2008, 06:49 PM
thrca, thanks for the post about media temple setup worked great for me :)

How did you get cron script working on (mt) gridserver?