PHP / Apache install with 10.1

slur

Geek / Hedonist
I understand that 10.1 comes with PHP 4.0.6 pre-installed. That's fine, but I'd like to re-install Apache and PHP to get support for the maximum number of libraries. However, I just downloaded the latest developer tools and now I can get neither Apache nor PHP to successfully compile! (They seem to be unable to find certain libraries.) Has anyone had any luck getting these items to compile and install using the latest Dev Tools?

Interestingly I had no trouble getting these items to compile and install using the older Dev Tools, so I think it might have something to do with the version of 'make' that's included in the newer package.

Hmm, I have this nagging feeling that at some point I might have replaced my copy of make with gnumake when I was still using 10.0.4, and this was somehow the key to my success at earlier installs of Apache and PHP. Would this make any difference or am I just grasping at straws?
 
I dl'ed 'em and compiled them last night w/ fink, but haven't started them up yet so I can't be positive all the correct modules got installed.
 
I tried Fink last night also and used it to install MySQL, PHP, and Apache in one fell swoop. I had no trouble whatsoever with MySQL, but getting Fink's Apache and PHP up and running together is going to take some work. It's not even close to a totally automated process.

Fink downloads its stuff to a separate folder from the rest of your system (/sw) and everything lives there: executables, libraries, config files, even .pid files. After I used Fink to install Apache it was still the original Apple copy that was running, not Fink's. But I managed to get the Fink copy to run with the Web Sharing button by replacing the original apachectl with a symbolic link:

mv /usr/sbin/apachectl /usr/sbin/apachectl_old
ln -s /sw/sbin/apachectl /usr/sbin/apachectl


...but Web Sharing couldn't see the .pid file so it didn't know Apache had started. Another symbolic link fixed that:

rm /sw/var/run/httpd
ln -s /sw/var/run/httpd /var/run/


Even after this the Web Sharing button still can't stop Apache, so there's more yet to do!

There are lots of steps involved getting the Fink copy of Apache to run and integrate with PHP. I'm still mucking around to get it working.

I had a much easier time with the source distributions of Apache and PHP, but I'm going to keep pushing at this Fink thing. It may be worth it in the long run and maybe Fink will adopt the changes.

As for getting just PHP installed and integrating that with the existing Apache, that's something I haven't bothered to try yet. Again, Fink's copy of PHP leaves the pre-installed version intact, so you have to muck with the httpd.conf file to get Apache to find it in the right place. I imagine this would be much easier than trying to get a whole new Apache running with a whole new PHP.
 
...yeah, I figure I need to familiarize myself with all the innards of that crap anyway & troubleshooting is a great way to maintain focus while you learn, but I'm looking forward to just typing "fink update-all" in the future.
 
I managed to get the Fink version of Apache working seamlessly with MacOS X. It wasn't as simple as simply choosing "Update" but it wasn't all *that* difficult either. In order to be totally integrated with MacOS X the Fink install of Apache needed to have several things made to work:

1. Startable and stoppable with the button in the Sharing control panel.
2. Able to start at bootup time.
3. Able to see my user directories.
4. Able to use the Fink-installed version of PHP.

So here's what I did. Before you follow these steps you should open the terminal and become super-user:

su
<root password>


1. Start and Stop with the Web Sharing button.
When you press the Web Sharing Start button MacOS X starts Apache by invoking apachectl. If MacOS X can't find apachectl it won't start it, and if you've installed Apache using Fink this button will still start the original installed version. The simplest way to get this working is to replace the original apachectl with a symbolic link:

rm /usr/sbin/apachectl
ln -s /sw/bin/apachectl /usr/sbin/apachectl


Now it'll start with the Web Sharing Start button. However, the Web Sharing panel still can't tell that Apache is running, so the button just sticks in a grayed-out position forever. This is because it can't find the httpd.pid file where it expects it to be (/private/var/run/httpd.pid). Another symbolic link fixes this:

rmdir /sw/var/httpd/run/
ln -s /private/var/run /sw/var/httpd/run


2. Starting up at boot time
In order to start Apache at bootup MacOS X only needs to be able to find apachectl, and we've already taken care of that by making the first symbolic link. No step 2 required...

3. and 4. Configuration Stuff
All these concerns are handled in the httpd.conf file. The simplest way I could see to make the appropriate changes was to compare the Fink version of httpd.conf with the original httpd.conf that Apple supplies and then choose which things to change and which to leave alone. So I used the diff command and then opened the resulting file in TextEdit:

diff >httpd_diff.txt /sw/etc/httpd/httpd.conf /private/etc/httpd/httpd.conf
open httpd_diff.txt


Armed with this information I was able to make the appropriate changes and get PHP working without a hitch. What follows is a synopsis of the changes I made, in a semi-diff format. Each line that begins with '-' was removed, and each one beginning with '+' was inserted. So each pair of lines indicates a line that was replaced, dig?

To make these changes use your favorite text editor, such as pico:

pico /sw/etc/httpd/httpd.conf

Of course if you've customized your Apache configuration you should make the appropriate adjustments.

---------- BEGIN LIST OF CHANGES ----------

- ScoreBoardFile /sw/var/httpd/run/httpd.scoreboard
+ ScoreBoardFile /private/var/run/httpd.scoreboard

- MinSpareServers 5
+ MinSpareServers 1

- MaxSpareServers 10
+ MaxSpareServers 5

- StartServers 5
+ StartServers 1

- MaxRequestsPerChild 0
+ MaxRequestsPerChild 100000

- ServerAdmin root@localhost.fellowship.de
+ #ServerAdmin webmaster@example.com

- #ServerName localhost.fellowship.de
+ ServerName 127.0.0.1

- DocumentRoot "/sw/share/httpd/htdocs"
+ DocumentRoot "/Users/my_user_name/Sites"

- &lt;Directory "/sw/share/httpd/htdocs"&gt;
+ &lt;Directory "/Users/my_user_name/Sites"&gt;

- UserDir public_html
+ UserDir "Sites"

- DirectoryIndex index.html
+ DirectoryIndex index.html index.php index.pl

- ErrorLog /sw/var/httpd/log/error_log
+ ErrorLog "/private/var/log/httpd/error_log"

- CustomLog /sw/var/httpd/log/access_log common
+ #CustomLog "/private/var/log/httpd/access_log" common

- ScriptAlias /cgi-bin/ "/sw/share/httpd/cgi-bin/"
+ ScriptAlias /cgi-bin/ "/Library/WebServer/CGI-Executables/"

- &lt;Directory "/sw/share/httpd/cgi-bin"&gt;
+ &lt;Directory "/Library/WebServer/CGI-Executables"&gt;

Remove this line:
AddLanguage zh-tw .tw

Add this line to the end for individual user privileges:
Include /private/etc/httpd/users

For PHP add these lines to the appropriate sections of httpd.conf:

AddType application/x-httpd-php .php .phtml
AddType application/x-httpd-php-source .phps

LoadModule php4_module lib/apache/1.3/libphp4.so
AddModule mod_php4.c

---------- END LIST OF CHANGES ----------
 
The apache install by apple seems fine,
but I wanted to have my own customized php.

first, youshould

type
<code>setenv LDFLAGS -flat_namespace</code>

into a terminal window

then

in the php-4.0.6 directory which is the result of downloading and unpacking the source package, ::::

find the file ltconfig

that means library tool configuration
it explains to the ld program how to work with the cc to make library files which is what you want.
<hr><b>
search for:

rhapsody*|darwin*)
archive_cmds='$CC -bundle -undefined suppress -o $lib $libobjs $deplibs $linkopts'

change it to:

archive_cmds='$CC -bundle -flat_namespace -undefined suppress -o $lib $libobjs $deplibs $linkopts'
hardcode_libdir_flags_spec='-L$libdir'
hardcode_direct=yes
hardcode_shlibpath_var=no

</b>
<hr>

be sure you are changing the directive for rhapsody|darwin as other places will be ignored

so if you have been through the compile process and find that you have thrown an error right at the end it is during that final step making the library, that the library tool finds out that "-undefined suppress" is not a valid flag for "-twolevel_namespace" which is the new default for the making of apple compatible libraries.

Most(if any) unix libraries don't use the (possibly conflicting namespace) Apple api's so you don't need it.

there is more....

the configure script file evidentally needs ths minor adjustment
<hr><b>
search for:

APACHE_INSTALL="\$(mkinstalldirs) \"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" && $APXS -S LIBEXECDIR=\"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" -i -a -n php4 $SAPI_SHARED"

change to:

APACHE_INSTALL="\$(mkinstalldirs) \"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" && $APXS -S LIBEXECDIR=\"\$(INSTALL_ROOT)`$APXS -q LIBEXECDIR`\" -i -n php4 $SAPI_SHARED"
</b>

that little "-a" evidentally needs to be removed
<hr>

much thanks to

Christoph Pfisterer and the fink team on the clues to solving this one.

One more hint about Fink.

The reason I don't compile some things with fink is that I want some things outside of my /sw fink tree. and also, I get more control over the configuration process.

here is my example config string for php
showinf the use of files installed by fink and also standard system files.
<hr><b>
./configure --prefix=/usr \
--sysconfdir=/etc \
--localstatedir=/var \
--mandir=/usr/share/man \
--enable-mbstr-enc-trans \
--enable-mbstring \
--with-jpeg=/sw \
--with-xml \
--with-apxs=/usr/sbin/apxs \
--with-mysql=/usr/local/mysql \
--with-gd=/sw \
--enable-gd-native-ttf \
--with-png=/sw \
--with-zlib \
--with-freetype-dir=/usr/X11R6 \
--enable-trans-sid \
--with-readline=/sw \
--with-gettext=/sw/bin \
--enable-ftp \
--with-gdbm=/sw \
--with-pgsql=/usr/local/pgsql
</b><hr>

now the 10.1 machine is exactly back to where it was before the update
 
Say jimr, looks as if you've got a basic understanding of what's going on with the linker and Apple's changes from 10.0.x to 10.1. Maybe you can help me with this one!

I tried to compile BSD fortune on 10.1 using the same package I set up for 10.0.4. It worked perfectly before the 10.1 update. Now I get the following nasty error:

make
cc fortune.c -o fortune regexpr.o
/usr/bin/ld: /usr/lib/libSystem.dylib load command 6 unknown cmd field
make: *** [fortune] Error 1


I found another person in the forums on macosx.org having the same trouble.

Do you have any idea what's going on with the compiler environment? It used to be such a friendly place!
 
can't seem to find the source of the fortune package....seen it thousands of times...

got a pointer.
 
I will look at your files...

here is something which I found

http://www.peak.org/apple/macosx/server/New/all.html

I just compiled it...

needs to manually install.

you could add -flat_namespace -undefined suppress to the LDFLAGS in the make file though it will compile either way.

follow additional instructions in the readme

though this is not the "official"
 
your source works for me ...did nothing before, after, or during........
installed and

fortune
As the poet said, "Only God can make a tree" -- probably because it's
so hard to figure out how to get the bark on.
-- Woody Allen


no errors during compile....

if I do a "strings ld" I get:

@(#)LIBRARY:ld PROJECT:cctools-384.obj~11 DEVELOPER:root BUILT:Sun Sep 2 15:59:09 PDT 2001

as one of the last lines.
check to see this is true
ls -alF /usr/lib/libSystem.dylib
shows
/usr/lib/libSystem.dylib -> libSystem.B.dylib

and
-r-xr-xr-x 1 root wheel 1173820 Sep 3 06:41 /usr/lib/libSystem.B.dylib*

you don't need any particular options to compile these files. Did you "install over" or fresh install?

the error you originally mention, I have never seen and is not related to the "namespace" issue.

reading it... seems a directive to load the system library is malformed.

what the "6" refers to...needs some research. As I cannot reproduce the error, it seems you must examine your system and your install until you find the culprit.

contact me by private message if you have more info or questions.

jim




 
That looks like what you get when you try to compile stuff in 10.1 with the old Dev Tools installed.

Did you upgrade to the 10.1 Dev Tools? You'll need to before you can compile anything in 10.1.

If you did, it looks like something may have gotten messed up, you might want to try re-installing it.
 
Originally posted by Darkshadow
That looks like what you get when you try to compile stuff in 10.1 with the old Dev Tools installed.

Did you upgrade to the 10.1 Dev Tools? You'll need to before you can compile anything in 10.1.

if you did not install the new tools...
better do that. then please go to the top directory of the forums and make a new thread to explain how much necessary it is to do that....
 
I tried to install my fortune package once more and this time it went without a hitch. The only thing I can speculate on is that I've rebooted since the last time I tried, which was immediately after installing the 10.1 Developer Tools.

But to answer your questions about whether the older Developer Tools could have been involved, they definitely weren't. I got this iBook the day 10.1 came out and it's never had any Developer Tools but 10.1. In fact I never even booted into the 10.0.3 that came on it... didn't want to taint the experience... :D
 
Back
Top