Apache 2.4 + PHP

  • Thread starter Thread starter cj
  • Start date Start date
I've installed apache and php but I'm not able to make it work as it should. I could write every detail about the process but I would rather hear from someone that was able to make it work. Can someone briefly explain what was done to make phpwork with apache 2.4.4. I know there is an option when you port it: PROXY_FCGI FastCGI support module for mod_proxy but when I enable the compiled module in httpd.conf there is an error. (as seen below)

Code:
/root # service apache24 configtest
Performing sanity check on apache24 configuration:
httpd: Syntax error on line 119 of /usr/local/etc/apache24/httpd.conf: Cannot load libexec/apache24/mod_proxy_fcgi.so into server: /usr/local/libexec/apache24/mod_proxy_fcgi.so: Undefined symbol "proxy_module"


Code:
/root # apachectl -v
Server version: Apache/2.4.4 (FreeBSD)
Server built:   Jun  1 2013 11:02:40

Code:
/root # /usr/local/bin/php-cgi -v
PHP 5.3.25 with Suhosin-Patch (cgi-fcgi) (built: May 24 2013 14:51:50)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2013 Zend Technologies
 
Although I don't speak from personal experience (I use www/apache22) I have looked into this (see below) to make me feel confident enough to try and answer your question anyway.

The straight forward way to set this up is all about the order. You see, by default an environment such as lang/php5 has no specific dependencies on Apache unless you set them:

Code:
root@backup:/usr/ports/lang/php5 # make run-depends-list
/usr/ports/devel/pcre
/usr/ports/textproc/libxml2
So the solution is quite easy: start by installing www/apache24 and once that environment is setup use # make config in the appropriate PHP port and make sure to tell it to build the Apache module (this is assuming the straight forward approach, of course you could also chose to utilize cgi or maybe even FastCGI instead).

When you're done the PHP port should have detected which Apache was installed and configured and then selected that.

If it doesn't (it would be a wrong assumption on my end in that case): you want to use the APACHE_PORT build flag. You could have found out about this by looking through the Makefile in the PHP port directory:

Code:
.if ${PORT_OPTIONS:MAPACHE}
PHP_SAPI+=      mod
USE_APACHE=     22+
.include "${PORTSDIR}/Mk/bsd.apache.mk"
And if you then check out bsd.apache.mk:

Code:
# Parameter APACHE_PORT (user controlled):
#
# The parameter APACHE_PORT can be used in /etc/make.conf to
# overwrite the default apache port.
#
# This parameter should never be used in the Makefile of a port!
#
# Example entry in /etc/make.conf:
#  APACHE_PORT= www/apache22
#
# To get a list of "possible" valid values execute the command:
#  $> egrep 'apache[12]' ports/www/Makefile | awk '{print "www/" $3}'
In general: when looking for specific ways to build (or tune) ports then always look through the Makefile to look for some useful parameters which you might be able to (ab)use.

Also note that /etc/make.conf is basically a 'mere' Makefile. Therefor you should normally also be able to use build options on the commandline itself.

So, when building PHP5 you should be able to use: # make APACHE_PORT='www/apache24' build (or install clean instead of build if you're feeling lucky).

Edit:
Everything I mentioned above, including the part about automatic detection of Apache, seems to be true. However, I'd like to expand on it a little bit because it is easy to overlook. As you can see in the snippet I pasted above the USE_APACHE flag is set to 22+. This means so much that this particular port can be used with Apache 2.2 and up, so including 2.4 and any future versions as well.

You can find more information about this behaviour in the previously mentioned bsd.apache.mk file.
 
  • Thanks
Reactions: cj
The ports system takes care of dependencies. If you build PHP with the Apache option, it will automatically install Apache.

missing is another make(1) target for ports. It shows the missing dependencies that will have to be installed for the current port. For example, my system does not have Apache installed. No new dependencies have to be installed to just install PHP:
Code:
# cd /usr/ports/lang/php53
# make showconfig
===> The following configuration options are available for php53-5.3.25:
     AP2FILTER=off: Use Apache 2.x filter interface (experimental)
     APACHE=[color="Red"]off[/color]: Build Apache module
     CGI=on: Build CGI version
     CLI=on: Build CLI version
     DEBUG=off: Install debug symbols
     FPM=off: Build FPM version (experimental)
     IPV6=on: IPv6 protocol support
     LINKTHR=on: Link thread lib (for threaded extensions)
     MAILHEAD=off: mail header patch
     MULTIBYTE=off: zend multibyte support
     SUHOSIN=on: Suhosin protection system
===> Use 'make config' to modify these settings
# make missing
#

After setting the Apache option:
Code:
# make showconfig
===> The following configuration options are available for php53-5.3.25:
     AP2FILTER=off: Use Apache 2.x filter interface (experimental)
     APACHE=[color="Red"]on[/color]: Build Apache module
     CGI=on: Build CGI version
     CLI=on: Build CLI version
     DEBUG=off: Install debug symbols
     FPM=off: Build FPM version (experimental)
     IPV6=on: IPv6 protocol support
     LINKTHR=on: Link thread lib (for threaded extensions)
     MAILHEAD=off: mail header patch
     MULTIBYTE=off: zend multibyte support
     SUHOSIN=on: Suhosin protection system
===> Use 'make config' to modify these settings
# make missing
www/apache22
#
 
  • Thanks
Reactions: cj
Thank you both. After reading both responses, it made me retrace my initial install steps. I basically ran # make config in the /usr/ports/lang/php53 directory and selected APACHE Build Apache module. I then ran make reinstall. Restarted apache and php is working.

I have no idea why I made this more complicated than what it really is. I have to review what I did wrong. Thanks again!
 
Back
Top