Apache, PHP, GD & Mod_Perl Guide

«»

12) Configuring, compiling and installing PHP
Untar the source, and prepare the script:

# cd /usr/local/src
# tar zxf php-5.2.8.tar.gz
# cd php-5.2.8

Create a file called run.sh with your favorite editor and copy-paste the following:

CPPFLAGS=”-I/usr/local/include”
LDFLAGS=”-L/usr/local/lib -lstdc++”
./configure –prefix=/usr/local
–with-apache=/usr/local/src/apache_1.3.41
–enable-exif
–enable-calendar
–enable-magic-quotes
–enable-wddx
–enable-ftp
–enable-inline-optimization
–enable-dbase
–enable-mbstring
–with-gd=”/usr”
–enable-gd-native-ttf
–with-ttf
–with-freetype-dir=”/usr”
–with-jpeg-dir=”/usr”
–with-png-dir=”/usr”
–with-zlib
–with-imap
–with-imap-ssl
–with-mhash=”/usr”
–with-mcrypt=”/usr”
–with-openssl=”/usr”
–with-kerberos
–with-curl=”/usr”
–enable-sysvsem
–enable-sysvshm
–enable-bcmath
–with-gettext=”/usr”
–with-mysql=”/usr/local/mysql”
–with-ldap
–with-iconv
–without-mm

Note: The above configuration is for a particular system. I recommend reviewing every single line and modify the script to suit your needs.

If you look at the above script, you will notice the last line that says “–without-mm”. Wonder what “mm” is? It’s a shared memory library that can be used in PHP. I strongly recommend you NOT to use it! EVER! Somebody told me that “mm” would increase the performance of PHP, since it would save sessions into memory rather than temporary files (which happens by default). I changed session.save_handler in php.ini to “mm” and all kinds of problems started coming up. First, I couldn’t figure out the source of those problems. Session-dependent sites that were running on arbuz.com were all screwed up. Sometimes they would work just fine, sometimes they wouldn’t. I finally tracked down the error – it was all in “mm”. Afterwards, I started adding that “–without-mm” line in every single PHP installation. Screw it!

Anyway, now run the configure script and install PHP:

# chmod 755 run.sh
# ./run.sh
# make
# make install
# cp php.ini-recommended /usr/local/lib/php.ini
# ln -s /usr/local/lib/php.ini /etc/php.ini

You might need to get libraries like cURL if they are not already present on your system. If configure gives an error saying that something is not found or missing, try to look for it in the system first – you might end up specifying the directory where the files are to be found by the configure script. If you can’t find it, either get it from the Internet and rebuild or remove that particular configuration line.

14) Last step – installing Apache
Now that we’re done with everything we need for Apache, the last thing to do is to configure, compile and install it:

# cd /usr/local/src/apache_1.3.41

Create a file called run.sh with your favorite editor and copy-paste the following:

export CFLAGS=”-I/usr/kerberos/include”
export LDFLAGS=”-lstdc++”
export SSL_BASE=”/usr”
export LIBS=” -lz”
./configure –prefix=/etc/httpd
–enable-suexec
–suexec-caller=nobody
–enable-shared=max
–enable-module=access
–enable-shared=access
–enable-module=digest
–enable-shared=digest
–enable-module=imap
–enable-shared=imap
–enable-module=mime
–enable-shared=mime
–enable-module=setenvif
–enable-shared=setenvif
–enable-module=auth
–enable-shared=auth
–enable-module=cgi
–enable-shared=cgi
–enable-module=headers
–enable-shared=headers
–enable-module=log_referer
–enable-shared=log_referer
–enable-module=log_config
–enable-shared=log_config
–enable-module=log_agent
–enable-shared=log_agent
–enable-module=rewrite
–enable-shared=rewrite
–enable-module=userdir
–enable-shared=userdir
–enable-module=asis
–enable-shared=asis
–enable-module=autoindex
–enable-shared=autoindex
–enable-module=negotiation
–enable-shared=negotiation
–enable-module=status
–enable-shared=status
–enable-module=actions
–enable-shared=actions
–enable-module=dir
–enable-shared=dir
–enable-module=include
–enable-shared=include
–enable-module=mime_magic
–enable-shared=mime_magic
–enable-module=alias
–enable-shared=alias
–enable-module=env
–enable-shared=env
–enable-module=ssl
–enable-shared=ssl
–disable-module=cern_meta
–disable-module=expires
–disable-module=proxy
–disable-module=vhost_alias
–disable-module=auth_anon
–disable-module=example
–disable-module=auth_dbm
–disable-module=unique_id
–disable-module=auth_digest
–disable-module=usertrack
–disable-module=auth_db
–disable-module=info
–disable-module=mmap_static
–disable-module=speling
–add-module=/usr/local/src/mod_bandwidth.c
–activate-module=src/modules/perl/libperl.a
–activate-module=src/modules/php5/libphp5.a

In the above script, I am assuming that your path to SSL is /usr. If you want to have Apache somewhere other than /etc/httpd, modify the –prefix.

If you expect to have a lot of traffic on your server and have enough resources, I recommend altering the HARD_SERVER_LIMIT in src/include/httpd.h from 256 (default) to 512.

Now all we need to do is run the configure script we created and install Apache:

# chmod 755 run.sh
# ./run.sh
# make
# make certificate TYPE=custom
# rm -Rf /etc/httpd
# make install

If there were no errors during compilation, Apache should now be installed. Now we need to place this script into the startup directory /etc/rc.d/init.d to run apache at startup. Don’t forget to set correct permissions and startup behavior:

# chmod 755 /etc/rc.d/init.d/httpd
# chkconfig –add httpd
# chkconfig httpd on

Now you need to modify Apache configuration file. Make sure that everything is set up as needed and there are no errors in the configuration file. If something goes wrong with the configuration, the server will refuse to start. Therefore, take your time while editing this file. After you are done editing the configuration, start Apache by running /etc/rc.d/init.d/httpd start.

That’s it! You’re done! Congratulations :-)


Be Sociable, Share!

No related posts.

About Nasim Mansurov

is a professional photographer based out of Denver, Colorado. He is the author and founder of The Mansurovs, along with a number of other online resources. Read more about Nasim here.

Comments

  1. 1
    ) Craig White

    Nasim, are you planning to write a new guide for PHP 5? PHP 5.0.1 is now available on http://www.php.net. Waiting for your reply,

    Craig.

  2. 2
    ) MegaZ

    Craig: I’m planning to update this guide instead of writing a new one, since PHP 5.0.1 seems to be a pretty stable release. The development of 4.x branch will soon be discontinued anyway.

  3. 3
    ) David Taylor

    Thanks for your guide. I have been using it for a while now. However, I kept running into trouble compiling php, sablot, and expat. I ran across a doc that helped me located at http://www.protonicdesign.com/tutorial/faq.php#php2.

    Summary: You type this before you attempt to compile php with support for expat and sablotron, or you will get undefined references during php compilation:

    export LDFLAGS=-lstdc++

    I hope I can make a decent contribution to your excellent doc.

  4. 4
    ) David Taylor

    Also, you need the above export when you compile apache, just put it into your run.sh file, at the top.

  5. 5
    ) MegaZ

    David Taylor: Thanks for your contribution! What kind of OS were you installing on? I have compiled both on RedHat 9 and Fedora Core 2 and never got such errors.

    Nevertheless, I have updated the scripts above. Thanks again!

  6. 6
    ) David Taylor

    I am using Fedora Core 2, installed with minimal installation option. I didn’t need to export that variable the first time I followed your guide, but now I do (go figure). Maybe it has something to do with the minimal installation option, because I don’t think I used that option until recently.

    I am reworking my sources to include smbauth (http://tekrat.com), and I have to remove php from the apache sources to troubleshoot. I just recompiled Apache without php and I didn’t need to export that var.

    SMBauth still doesn’t work for my compiled apache, but it compiles on the redhat provided php, apache! Oh well. If you are interested, try to see if you can get it to work. Have fun!

  7. 7
    ) MegaZ

    David Taylor: What kind of error are you getting while compiling SMBauth? Instead of “doesn’t work”, could you give more details on what’s going on? Could it be something configuration related? Are you trying to compile SMBauth into apache or installing it as a loadable module with apxs?

  8. 8
    ) Gabriel Ortiz Lour

    Your how to is fantastic, but what about the GD lib. I dont have it instaled by default, and Im having some trouble on installing it for PHP.
    Please help, Ive looked all aropud and your how to rules…
    Gabriel

  9. 9
    ) Gabriel

    Sucessfully instaled on Slackware Linux 10.0 on text mode only.

    Thanks!

  10. 10
    ) MegaZ

    Gabriel Ortiz Lour: Use the following GD guide: http://mansurovs.com/russian-gd-2033-guide

    If you do not need the support for cyrillic characters in GD, just skip the russian patch.

  11. 11
    ) Julien

    Hello, I have install Mysql on my computer (slackware 10) and I have a ERROR 2002 : Can’t connect to Local Mysql server through socket ‘/tmp/mysql.sock’ (111)
    I don’t know how to fix this problem. I don’t see /etc/my.cnf.
    I am a beginner with Linux!
    Thank you very much for your help.

  12. 12
    ) tarbash

    I see that you have updated with the apache-1.3.33 …..nice …

  13. Hello,
    are you sure that php-5.0.2 is working with sablotron? I did a grap in the php-5.0.2 source tree wihout a match on the pattern “sablot”. This means that there is no configure option like –with-xslt-sablot in php-5.0.2, right?
    For me it builds fine with your option but the result is wihout sablotron xslt support in php-5.0.2.
    Maybe I’m wrong … then please correct me :-)

    Frank

  14. 14
    ) Fred Brende

    Is it possible to use mod_perl newer than the mod_perl-1.29.tar.gz? There are sevearl newer versions since 2003, or are those for apache 2?
    Thanks
    Fred

  15. 15
    ) Fred Brende

    When configuring IMAP for FreeBSD make sure to change ‘slx’ after the make to ‘bsf’, and for that matter whatever platform you are using make sure to change this flag to the appropriate setting by looking at the makefile.

  16. 16
    ) sanjay

    Hi ..

    I was trying this to use in at my Slackware 10 .
    I had apache 1.3.31 , mod_ssl , imap , mhash, php, xpat already install through default install . I removed them by ‘pkgremove’ . I didn’t find other problems but at time of apache install ..

    i don’t know why that gave and how to solve. I ‘m new to slack ..

    please help ..

    this is what i ‘ve got while compiling apache . :

    : undefined reference to `PL_op’
    modules/perl/libperl.a(Server.o)(.text+0xb73): In function `XS_Apache__Server_timeout’:
    : undefined reference to `PL_op’
    …………….
    …………….
    collect2: ld returned 1 exit status
    make[3]: *** [target_static] Error 1
    make[3]: Leaving directory `/usr/local/src/apache_1.3.33/src’
    make[2]: *** [build-std] Error 2
    make[2]: Leaving directory `/usr/local/src/apache_1.3.33′
    make[1]: *** [build] Error 2
    make[1]: Leaving directory `/usr/local/src/apache_1.3.33′
    make: *** [install-all] Error 2

    Those who ‘ve been successful in installing .. could you pls help regarding this..

    Sanjay Saha

  17. 17
    ) MegaZ

    Sanjay: seems like there is a problem with your perl installation. Try to remove mod_perl from the install scripts and see how it goes.

  18. 18
    ) MegaZ

    Frank: yes, you are right. Thanks for pointing that out! The new mod_perl files are for Apache 2. The latest version of mod_perl for Apache 1.3 is still 1.29.

  19. 19
    ) Dave Taylor

    David Taylor: What kind of error are you getting while compiling SMBauth? Instead of “doesn’t work”, could you give more details on what’s going on? Could it be something configuration related? Are you trying to compile SMBauth into apache or installing it as a loadable module with apxs?
    —————
    Just following up. The problem was smbauth would segfault when validating a password against Windows Active Directortory Server, while, if I remember correctly, it would authenticate successfully when used with the Red Hat provided php. I eventually recompiled the php sources with nothing else but:
    ./configure –with-apxs=/etc/httpd/bin/apxs –prefix=/usr/local

    and smbauth worked fine. Later, the project was delayed, then ended so I stopped persuing the issue. The conflict is to be found in one of the ./configure options for php.

    I’ll figure it out sooner or later ;-)

    Dave

  20. 20
    ) Andy Jackson

    Hi – can anyone give me some assistance – I’m totally new to Linux and trying to install MySql by following this guide as I’m trying to replace my WinXP email server with one running Mandrake 10.1. When I run /usr/local/mysql/bin/mysql -p I get the error 2002 (HY000): Can’t connect to local MySql server through socket ‘/tmp/mysql.sock’ (111)

    I’m stuck – can anyone help please?

    Thanks
    Andy

  21. 21
    ) bramez

    Great! It worked perfectly.

    Thanks for all!

    -bramez

  22. 22
    ) FunkyNet.cz

    Your “HOWTO” is very usefull and simple for understanding… Thank you!
    Only one problem occured, when I try to use Sablot-1.0.1.tar.gz (SSL error – undefined reference etc.). After use newer version of Sablot (1.0.2) problem fade away and now all working perfectly !!! Thank you very much!
    J.L

  23. Great piece of work ! Thanks. I ran into conflicting library versions and eventually decided to install XAMPP from apachefriends.org which contains all the pieces I need.

Speak Your Mind

*