FreeBSD 10: Installing Apache 2.4, MySQL 5.5, and PHP5.5 — Missing libphp5.so

Continuing my quest with FreeBSD.

Today, I was installing Apache 2.4, MySQL 5.5, and PHP 5.5 (php55-5.5.11) on newly installed system. I've done this kind of installation many times on Linux so I didn't expect much of problems. Boy, I was wrong...

Apache and MySQL installation were straight forward and had no problem. After PHP installation, I couldn't find libphp5.so in /usr/local/libexec/apache24/! A little googling found articles/forums on older version of FAMP. They said its installation should be automatic or "Build Apache module" option needs to be selected, which I did not have such an option any where.

Then one thread mentioned something about configuring php conf file. So, I opened Makefile for PHP55: # vim Makefile ------------------------------------- ... OPTIONS_DEFINE+=APACHE CLI CGI FPM... OPTIONS_DEFAULT=APACHE CLI CGI FPM...

Compiled PHP55 again: # make install config ===> php55-5.5.11 doesn't install the Apache module anymore: update your OPTIONS and build www/mod_php55 port instead. *** Error code 1

Aha! www/mod_php55. I wonder if php installation didn't install mod_php55 but now I know what I need to do: # cd /usr/local/www/mod_php55/ # make install clean ... --- Zend/zend_dtrace_gen.h dtrace: failed to compile script /usr/ports/www/mod_php55/work/php-5.5.11/Zend/zend_dtrace.d: line 30: failed to resolve INP_IPV4: Unknown variable name ...

Hmm... I wonder if this was causing php55 installation to fail creating libphp5.so. Well, another googling found a suggestion/solution to load the dtraceall module: # kldload dtraceall # echo 'dtraceall_load="YES"' >> /boot/loader.conf

Now, mod_php55 was successfully installed as well as libphp5.so!

Here is the whole steps to install apache, mysql, and php:

NOTE: The steps below are not suitable for production use. Be warned!

Disclaimer:
The information in this site is the result of my researches in the Internet and of my experiences. It is solely used for my purpose and may not be suitable for others. I will NOT take any responsibility of end result after following these steps (although I will try to help if you send me your questions/problems).

Apache 2.4 - Installation and Configuration:

# cd /usr/ports/www/apache24/ # make install clean

Edit /etc/rc.conf to make the Apache server will start automatically at system boot. # vim /etc/rc.conf ------------------------------------- apache24_enable="YES"

Test the Apache server installation using the following command: # /usr/local/etc/rc.d/apache24 start

MySQL - Installation and Configuration:

# cd /usr/ports/databases/mysql55-server/ # make install clean

Start MySQL # /usr/local/etc/rc.d/mysql-server onestart

Update /etc/rc.conf # vim /etc/rc.conf ------------------------------------- mysql_enable="YES"

Set root password # rehash # mysqladmin -uroot password '<password>'

Create my.cnf # cp /usr/local/share/mysql/my-small.cnf /etc/my.cnf

Restart mysql # /usr/local/etc/rc.d/mysql-server restart

PHP Installation and Configuration:

Here is the moment of truth. First, load the dtraceall kernel module, update the /boot/loader.conf file, and then install php55. # kldload dtraceall # echo 'dtraceall_load="YES"' >> /boot/loader.conf # cd /usr/ports/lang/php55 # make install clean

Check to see if libphp5.so is there # ls /usr/local/libexec/apache24/ httpd.exp mod_include.so mod_access_compat.so mod_info.so ...

Nope, it's not there. Then manually compile www/mod_php55/ # cd /usr/ports/www/mod_php55/ # make install clean

Now, check to see if libphp5.so is there again # ls /usr/local/libexec/apache24/ httpd.exp mod_include.so libphp5.so mod_info.so ...

Copy the PHP configuration file # cp /usr/local/etc/php.ini-production /usr/local/etc/php.ini

Edit /usr/local/etc/apache24/httpd.conf file and add the following lines # vim /usr/local/etc/apache24/httpd.conf ------------------------------------- AddType application/x-httpd-php .php AddType application/x-httpd-php-source .phps

Add the following line under the LoadModule section if it's not there LoadModule php5_module libexec/apache24/libphp5.so

Edit the DirectoryIndex section DirectoryIndex index.php index.html

Now restart the apache server # /usr/local/etc/rc.d/apache24 restart

Let's see now if it can show a php page # vim /usr/local/www/apache24/data/index.php ------------------------------------- < ?php phpinfo(); ?>

Voilà! It's working now!

phpinfo

That's all!
-gibb

32 comments

    • Laurent

      Da, mcy also for your tip.
      May you should also know to tell us how to search “PHP not staring in Apache24 on FreeBSD” in that /usr/ports/UPDATING – UPDATING ages ago, as it took me almost two days to find this answer for installation.
      Very clever anyway.

  1. Bob

    Fixed my problem working great – except when I run “pkg upgrade” now it wants to install “apache22”. I am running apache24-2.4.9_2, mysql56-server-5.6.19, and php55-5.5.13. I just skip installing the “apache22” thru the “pkg upgrade”. “pkg upgrade” also wanted “php-filter” installed now too, which I installed with no issues.

    • tom

      if you build from ports, setting DEFAULT_VERSIONS in your make.conf solves this problem. for example:
      DEFAULT_VERSIONS+=php=5.6 postgresql=9.3 apache=2.4
      DEFAULT_VERSIONS+=python=2.7 python2=2.7
      DEFAULT_VERSIONS+=ruby=2.0

      (note the “+=”) This is also documented in UPDATING
      Not sure if pkg respects this variable.

  2. Melinda

    Thanks for the post. Its really good.
    But cd /usr/local/www/mod_php55/ should be /usr/ports/www/mod_php55 for me too.
    Cheers 🙂

  3. hoodies men

    If some one wants expert view on the topic of blogging and site-building after
    that i advise him/her to pay a quick visit this web site, Keep up the nice
    job.

  4. graphic tees

    Hi there, I think your site might be having browser compatibility problems.
    When I take a look at your website in Safari,
    it looks fine but when opening in Internet Explorer, it’s got
    some overlapping issues. I merely wanted to provide you
    with a quick heads up! Besides that, great blog!

  5. hanoli.com.vn

    whoah this blog is fantastic i love studying
    your articles. Keep up the good work! You understand, lots of individuals are hunting round for
    this information, you can aid them greatly.

  6. web.dote.vn

    Woah! I’m really enjoying the template/theme of this blog.
    It’s simple, yet effective. A lot of times it’s very hard to get that “perfect balance”
    between superb usability and visual appearance. I must say you have
    done a excellent job with this. Also, the blog loads super fast for me on Firefox.

    Outstanding Blog!

  7. Doalwa

    Thanks a ton, couldn’t get roundcube to work after upgrading to Apache 2.4.

    After following you guide, it’s woking fine again!

  8. viaplay og chromecast

    Good post. I learn something totally new and challenging
    on sites I stumbleupon every day. It will always be interesting to read articles from other authors and practice a little something from other sites.

  9. hema kortingscode foto

    A fascinating discussion is definitely worth comment.

    I believe that you need to publish more about this issue, it might not be a taboo matter but usually folks don’t
    discuss such issues. To the next! Kind regards!!

  10. lisseur

    I just like the helpful info you provide to your articles. I’ll bookmark your blog and
    test once more right here frequently. I’m fairly sure I will
    be informed plenty of new stuff right right here! Best of luck for
    the next!

  11. Luz

    Having read this I thought it was really enlightening.

    I appreciate you taking the time and effort
    to put this article together. I once again find myself spending a significant
    amount of time both reading and leaving comments.

    But so what, it was still worthwhile!

Post a comment

You may use the following HTML:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>