# web serving (apache and php)



## sollaires (Sep 21, 2000)

has anyone tried to serve web pages off of mac os x yet?  i have played a little bit with the pre-installed apache and it works fine.  

however, i have also gotten my own compiled version of apache to work also.  the problem i have is that i cannot get php working with apache.  i downloaded and installed it all, but i keep getting "save as" windows when i try to load a php page.  anyone else tried this?  gotten this to work?

check out my server.  tell me if it works.

http://137.22.100.86
or
http://137.22.100.86/sollaires.net/

david hendler


----------



## hotani (Sep 21, 2000)

i am running darwin and installed php4 recently - had some problems such as you are describing. php seemed to compile fine, but apache would not compile with the php module. 

messed with it quite a bit and reworked the ./config settings, also ran 'make clean' instead of just 'make', that seemed to clear up all the previously wacked settings.

in the INSTALL documentation, I followed the "QUICK INSTALL (static)" directions...

I am not sure what finally made it work, but when the error was occuring like yours, I did not have the php module installed correctly under apache; after running 'apache/bin/httpd -l', I would not see mod_php4.c ...


----------



## sollaires (Sep 21, 2000)

hmmm... i will try "make clean"

the only thing is that when i run "httpd -l" mod_php4.c shows up.  

another random thing.  whenever i try to kill my webserver by using "apachectl stop" it always tells me"stop: httpd (no pid file) not running."  is there a surefire way to kill my server and restart it?


----------



## hotani (Sep 21, 2000)

when you run 'ps -aux | grep httpd' does it show up in the processes?

and I dont know of any other way to stop and start the webserver except with apachectl...


----------



## sollaires (Sep 21, 2000)

got it working.  rebooted my machine and now php is working.  

thanks for the help.

so, check out

http://137.22.100.86/sollaires.net/


----------



## DigiD (Sep 21, 2000)

How interesting... does anyone know if MySQL compiles under OS X, that is sooo cool... looks like I will have a web development platform at home now. 

Scott


----------



## sollaires (Sep 21, 2000)

yes.  i have gotten mysql to install, though i haven't had time to play with it yet.  don't know if all the executables that compile will work afterwards, but the compilation was fine


----------



## spike (Sep 24, 2000)

Does anyone have or know where I can get instructions for installing PHP on the OSX PB?

I kinda new to unix and Im not sure what what I should be doing. 

I tried to download it from php.net but all I got was a file called "do_download.php".  I was expecting to get the file "php-4.02.tar.gz".
I cant seem to get it from the ftp site either. :-(

If I manage to get that file, I then need to compile it, right?

Is it true that there are no compilers in the public beta?

If so can i get a precompiled version from somewhere?

I've also read that It's easier if my version of Apache has been compiled with DSO support. Does the PB install of Apache have this?

As I mentioned Im kinda new to this and want to do some PHP coding and figured having my own local server was the way to go.  Feel free to tell me im being stupid if im completly on the wrong track. ;-)


Any help any one can offer is much appreciated.

Thanks, Alex.


----------



## hotani (Sep 24, 2000)

this is quoted from the macnn board on installing php by FosterBass (http://forums.macnn.com/cgi-bin/Forum34/HTML/000004.html):

"I have PHP4 running now under apache on Mac OS X. 
First I installed the developer tools from darwin (as per the MacAddict article at http://www.macaddict.com/content/news/2000/09/13/18709 ). 

Then I downloaded the newest source for apache from http://www.apache.org/dist/apache_1.3.12.tar.gz into /tmp

Then I downloaded the newest PHP4 installation from http://www.php.net/downloads.php into /tmp

The directions at http://www.php.net/manual/install.unix.php couldn't be more simple."

I also installed a newer apache release than the one that came with my Darwin system, but the PB is probably more up to date. I dont know if it has the DSO support though. I installed php without it - 

as far as the 'do_download.php' page, i dont know what to do except try loading the page again, maybe it was not getting the full path...

hope that helps!


----------



## hotani (Sep 24, 2000)

oh, one more thing - you can check to see if you have the DSO support by typing 'httpd -l'. you may need to do this by calling the program locally; find it in its 'bin' directory and type './httpd -l'. if one of the modules listed says 'mod_so.c' then you can do the DSO install.


----------



## spike (Sep 24, 2000)

kewl 
Thanks for the help.
I'll give it try.

Thanks, Alex


----------



## iPLouis (Sep 26, 2000)

How did you compile mySql???

I've installed the darwin development tools with
the new install script (21/09) from macaddict.

Unfortunatly, I had some errors during the mysql
configure process (pid stage).
So, I tried to install the pthreads but the mach/
headers weren't found...

Can you help me?

regards,

Alex.


----------



## natepalmer (Sep 26, 2000)

I got that same file (do_download.php), but I just extracted it using gnutar -zxf and it worked fine.


----------



## natepalmer (Sep 26, 2000)

I'm having problems with PHP also.  And mod_php4 does show up.

I was trying to do a make clean and I noticed something that make be a problem.

I was following the instructions for a unix installation so I did

make clean
then
make install

and this is what it said.

http://www.pandacreations.com/phperror.tiff

I'm wondering if this is the problem?


----------



## sollaires (Sep 26, 2000)

about mysql:::

i actually did not get it to compile - i keep getting the ps/pid error and have not figured out a way to get the host issue resolved.  most of the hostnames did not work because the mysql source didn't understand them.  there is a binary download of mac os x mysql, though i haven't had time to play with it too much and have not gotten it to work.  so hopefully someone out there with more *nix/bsd experience has figured out how to compile it.

about php,

after several failed installations, i finally got it to work by following the instructions in one of the READMEs.  i did a default configuration of apache first (just ./configure with no arguments), then installed the php stuff, then did configured apache again with the arguments

here is the info from the INSTALL doc in the php folder.  so do these and hopefully it will work.  this requires a new installation of apache.  make sure you are logged in or su'ed to root.

$gnuzip < apache_1.3.x.tar.gz | tar xvf -
$cd apache_1.3.x
$./configure
$cd ..

$gunzip < php-4.0.x.tar.gz | tar xvf -
$cd php-4.0.x
$./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars
$make
$make install

$cd ../apache_1.3.x
$ ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
$ make
$ make install
$ cd ../php-4.0.x
$ cp php.ini-dist /usr/local/lib/php.ini

then edit your http.conf and add (or uncomment if the lines are already there) these

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

after this, i rebooted and things worked for me.  check your own files, and your own system, try these out.


----------



## natepalmer (Sep 27, 2000)

I have tried everything on this page, checking, re-checking, and installing, compiling.. still can't get PHP4 to work.  Any ideas?


----------



## christophercotton (Sep 27, 2000)

> _Originally posted by sollaires _
> *about mysql:::
> 
> i actually did not get it to compile - i keep getting the ps/pid error and have not figured out a way to get the host issue resolved.  most of the hostnames did not work because the mysql source didn't understand them.  there is a binary download of mac os x mysql, though i haven't had time to play with it too much and have not gotten it to work.  so hopefully someone out there with more *nix/bsd experience has figured out how to compile it.
> ...



Ok. Here is what I have found out so far. You can replace the config.guess and config.sub with the ones that are in /usr/libexec/  (they are both in there) At least on my system, and I have OSX + Dev Tools (these are the real dev tools since I am an ADC member)

that deals with all the hostname problems.

then for the "ps pid" problems. I am not sure why the test doesn't work correctly. But, in the ~mysql/configure script, edit the file and change it to have the following (just search for the # Linux style)


# lame darwin style. not sure why
if $PS p $$ 2> /dev/null | grep sh > /dev/null
then
  FIND_PROC="$PS p \$\$PID | grep mysqld > /dev/null"
# Linux style
elif $PS p $$ 2> /dev/null | grep $0 > /dev/null

All I know about this one, is that $$ returns the correct PID, but $0 returns "./configure" which seems right. But in the process list, the PID is listed as just "sh".

Then, be sure to type ./configure --with-named-curses-libs=""

I'll have another way of doing this, but that is the easiest way.

Now, you get the problem with __attribute__. and basically, I haven't fixed the problem yet. I know how to fix it -- it is just 1:15am and I am not going to work on this anymore. The problem is that __attribute__ is not supported by the gcc version that is on the OSX. you need to go through and create somewhere (not sure where yet) a macro that has:

#if defined( __Sometinglike_Darwin__)
#define mysql__attribute(x)
#else
#define mysql__attribute(x)  __attribute__(x)
#endif

and then, go through all the code and change all the __attribute__   to    mysql_attribute.

I haven't done this yet, so I don't know what the next problems will be. 

But I got that far.


----------



## massebasse (Sep 27, 2000)

I followed the advice and installed a new apache (+ php). I also quit the default apache. But when I start my installed apache it seems like it uses the first apache  ...

/Library/WebServer/    (this is Apple-Apache)

/www/bin/   (this is my Apache)

Should I change some conf. files?


----------



## sollaires (Sep 27, 2000)

make sure you turn "web server" OFF in the system settings.  otherwise, the preinstalled apache will start up.  when i boot my system up, i let it load, then immediately drop into a terminal and run /www/bin/apachectl start.

i am sure there is someway to make the installed apache start while booting, but this is beyond my knowledge.  anyone else played with this?


----------



## massebasse (Sep 27, 2000)

Yes, I do exactly as U ...

But it seems like "my" apache uses the other apaches conf. files and DocumentRoots ... hmmm strange


----------



## hotani (Sep 27, 2000)

i found that if i just type 'apachectl start' the original apache will start up instead of the one i installed. and of course it will use all the old conf files, document root, and original configurations. to remedy this i start apache by either going into the /bin directory inside my apache directory and typing './apachectl start', or by just typing the entire path: '/usr/local/apache/bin/apachectl start'


----------



## hotani (Sep 27, 2000)

oh yeah, this is because of the pathways setup in your user profile (i dont think you can change it from aqua, you have to use niutil or edit your profile script). One of the paths points to the directory that holds the original apache binaries. you can change this by editing(creating) a profile script that is read each time you start a new shell session. 

i have not yet gotten around to doing this myself, and am using zsh instead of the default tcsh so the line i add will be a bit different - maybe i will go do that now and report back later ...


----------



## hotani (Sep 27, 2000)

ok, edited my profile to include the new apache/bin directory - here is the line I added to my startup script (.zshrc):

path=(/bin /usr/bin /usr/local/apache/bin /sbin .)

it will be a different format for tcsh, but same idea. you can check paths by typing 'echo $PATH'

hope all this helps...


----------



## massebasse (Sep 27, 2000)

Oh yes ... Now it works ... stupid me 

Tnx alot!!


----------



## MacFreak (Sep 27, 2000)

How do you know where to install mySQL and PHP in right path? Does it automatically install in right path for us? 

I am dumb in unix.


----------



## sollaires (Sep 27, 2000)

MacFreak - 

generally, you use the --prefix argument when configuring a program.  for example, to set up apache (httpd) in a new folder at the top level called www, you would do something like this.

(while in the apache source/binary directory)
$ ./configure --prefix=/www

another usual one is

$ ./configure --prefix=/usr/local/apache

or some such thing.  same with mysql and php.  just go to the configure scripts (within the proper directory) and use the prefix argument. 

when installing php with apache, you need to know the directory of where you are.  you can always use the command 'pwd' to Print the Working Directory (where you currently are). 

example:

my apache is in my root download folder which i made, so when i 'pwd' in that directory, it prints this out

$ pwd
/private/var/root/downloads/apache-1.3.12

so with php i would do this

$ ./configure --with-apache=/private/var/root/downloads/apache-1.3.12

and then add whatever else needs to be there.

hope this helps


----------



## dfour (Sep 28, 2000)

I'm trying to follow your install HOWTO, which is somewhat similar to the Install PHP on Unix chapter in P. Dubois MySQL excellent book (New Riders).

The first problem I encounter is that issuing the "./configure" command returns me a "Command not found".

I'm logged in as root, my working dir is apache_1.3.12, and configure is x enable.

So where is the error ?
------
The Apache folder had been corrupted by StuffIt!
A new download, a clean gunzip and everything comes right.
configure script is executed.

By the way I had error -50 when StuffIt uncompress the tar file.  Is it a bug ?

[Edited by dfour on 09-28-2000 at 06:00 AM]


----------



## sollaires (Sep 28, 2000)

i don't know what the -50 error is all about, but stuffit really likes those errors when trying to un(stuff/zip/tar) .gzip.tar files.  i am sure it will be addressed at some point.  until then, stick with gunzip and tar from the command line.


----------



## dfour (Sep 28, 2000)

Thanks to yout precise "HOWTO" install Apache with PHP, all is now working on my G3.
 I have just run the phhinfo function and get all the variables and configuration of PHP fine.

But, the CSS for the HTML page is for a Windoze platform and the layout is bad. Did you checked it. It's hardly readable.
Should we complain to Zeev ? 

I have now to install MySQL.


----------



## Pascal (Sep 28, 2000)

I see that some of you have installed a new Apache server. Why isn't the standard one enough ?

Aside from PHP, is there anything else missing in the OS X PB version of Apache ?

Why is PHP so important ?


----------



## hotani (Sep 28, 2000)

(in homer voice...) mmmmmmmm - php - aaaaaahhhhhhh.....

php does stuff that microsoft asp does, but cooler. and its not microsoft. and its free. and it has perlish syntax, with some javaish syntax as well. (another homer: mmmmmm, multiline comment.... ahhhhhh)

it can do the simplest stuff like redirects (frikkin fast!!! about 100 times faster than an html meta redirect!!), and includes (write one menu file and include it in all the pages).

as well as complex stuff like querying mySQL databases (and many other DBs as well...), filesystem functions (this is what i mainly use it for..) such as reading files in a directory and printing them to html output

the list goes on and on. PHP SHOULD be included with os X!!!

<a href=http://php.net>check it out...</a>


----------



## dfour (Sep 28, 2000)

I need PHP to access MySQL database. It's the main strength of this scripting language. It runs server-side and is secure.

But I heavily use Javascript on the client-side for HTML layout and form validation. PHP and Javascript mix finely and have a very similar syntax (a la C) with object-oriented features.

Apache + PHP module + MySQL + Javascript + DHTML (+ XML) give you a very powerfull development environement.


----------



## iPLouis (Oct 3, 2000)

Do you think it is stable enought???

I've finished to compile the mysql 3.22.32 
(15hours to compile sql_yacc.cc! cool),
but it dont work better than your version.

I'd like to improve my ext_pthread.a but,
I dont want to break my HD by compiling
sql_yacc.cc again ;-)

*alex*


----------



## The DJ (Oct 3, 2000)

> _Originally posted by sollaires _
> */www/bin/apachectl start.
> i am sure there is someway to make the installed apache start while booting, but this is beyond my knowledge.  anyone else played with this? *



Actuallly i do.
Instead of turning apache off in the /etc/hostconfig.
Edit the /System/Library/StartupItems/Apache/Apache script. In here you have to change it thus, that it cd's in the directory in which you installed it. and let it do ./apachectl start

Now test the script before you reboot
type cd /System/Library/StartupItems/Apache
./Apache
And check with the processviewer if it starts up.

Do not reboot when this didn't work, cause i already had a lot of trouble with MOSX not booting because of a broken startup script. I had to put the disk in my other (OS9) mac and edit the file from there. You don't want to experience that. 

I don't garantuee a thing.
For the people who want to install a new Apache in the MOSX directory's go to this post.


----------



## devnul (Oct 4, 2000)

I am curious if anyone has tried and/or succeeded in getting Postgres to work with OS-X?...  Obviously MySQL has some *serious* problems for any real database sort-of work (which, respectfully do not seem to be apriority for the MySQL folks for some really strange reason..)...

It would be nice to have a database server for OS-X that is more then a fancy filesystem that can be queried...

- Greg


----------



## hotani (Nov 2, 2000)

ok, so this is a little plug for my page. I thought it would fit in here since it uses what we have been discussing in this thread. 

It is a freely downloadable php/apache web page template that has discussion forums, articles, and article connection to the discussions. Most of the work for it was done with Darwin, php4, and apache. 

No DB required, the page uses flat files and is not meant for high traffic sites.

thats all.  

http://ncaikido.org/hotani


----------



## iPLouis (Nov 3, 2000)

Well, you're right! I also spent some time on
postgresql with the *same* success...
The standard dl library was replaced by a *dyld*
library that seems to do the same thing.
The port should be easier but I'm very late on my
job. 
So I installed FrontBase that has php support,
and works on MacOS Xpb until I find some free time.

iPLouis




> _Originally posted by devnul _
> *I am curious if anyone has tried and/or succeeded in getting Postgres to work with OS-X?...  Obviously MySQL has some *serious* problems for any real database sort-of work (which, respectfully do not seem to be apriority for the MySQL folks for some really strange reason..)...
> 
> It would be nice to have a database server for OS-X that is more then a fancy filesystem that can be queried...
> ...


----------

