[HOWTO] - Setup PHP & MySQL

Status
Not open for further replies.
Just mentioning pico 'cause it's worth learning for extremley quick edits;)

(I was a newbie too about 2 months ago, learning pico was a life saver).

:rolleyes:
 
Originally posted by lethe
i m looking for some help installing PHP.

i am trying to install it with GD support, according to instructions from this article.

i installed all the prerequisits fine, but when i configure PHP. like this: ./configure --with-gd=/sw/lib --with-jpeg-dir=/sw/lib --with-zlib-dir=/sw/lib

i get this error:

Code:
checking for the location of libjpeg... yes
configure: error: libjpeg.(a|so) not found.

can anyone offer any advice? thanks

Yes I can ;). The problem is that you do not have the libjpeg library installed. This is easily fixable as the only thing you must do is download and install it. You can download the source here.

If you need help installing it please reply and I will include instructions.

~Yoshi
 
libjpeg is installed:

Code:
% ls /sw/lib/libjpeg.*
/sw/lib/libjpeg.62.0.0.dylib       /sw/lib/libjpeg.a                  /sw/lib/libjpeg.la
/sw/lib/libjpeg.62.dylib           /sw/lib/libjpeg.dylib

Code:
% fink list | grep jpeg
 i  libjpeg         6b-5        JPEG image format handling library
 i  libjpeg-bin     6b-5        JPEG image format handling library
 i  libjpeg-shlibs  6b-5        JPEG image format handling library

that s why the error message seems so puzzling to me. thanks for the help though, yoshi. i started a new thread for this, so if you can help more, perhaps thats a better place to reply?

thanks
 
Absolutely Excellent How To!

Just a bit I wuld like to add though for people brand new to this....
After installing Apache on ya system, to view the localhost (ie your webserver)

simply type "localhost" (without "") in you browser.
This will show you all your files etc in your root folder:
/library/webserver/documents

One thing for Yoshi or anyone else,

Is there a quick way to start Apache, for example an AppleScript??
Any ideas?

If I wanted Apache to start when I logged in for example.... how?
Thanks :cool:
 
Summin wierd is going on here.....

No .php file works!
I have started the server and it seems to be recognised by my browser fine.
There always sems to be an error with whatever php file it tries to load though!

I put:

<?php_phpinfo();_?>

into a new BBedit file, saved it as first.php and it came up with the error:

Fatal error: Call to undefined function: phpÊphpinfo() in /Library/WebServer/Documents/1st.php on line 1

Why is this?
 
this is what came up when I tried to restart apache...

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
/usr/sbin/apachectl graceful: httpd started


and any idea of how I would fix it?

also once Ive downloaded the mysql thing and set up a new user I get this...

[localhost:~] wilyum% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] wilyum%


any idea what is going wrong?

Then after I go and physically create a dir called mysql in usr/local...etc In fact apart from the dir that I created "mysql" there is absolutely nothing in the library... :(

And try and install the .db

It says command not found. I've installed the package, but when I do a search with sherlock it finds nothing??????

Why does Unix always seem like a lottery to the ignorant? :)
 
Originally posted by owaters
Summin wierd is going on here.....

No .php file works!
I have started the server and it seems to be recognised by my browser fine.
There always sems to be an error with whatever php file it tries to load though!

I put:

<?php_phpinfo();_?>

into a new BBedit file, saved it as first.php and it came up with the error:

Fatal error: Call to undefined function: phpÊphpinfo() in /Library/WebServer/Documents/1st.php on line 1

Why is this?

You typed it wrong. Copy and past this for the info file:

<?php
phpinfo();
?>

That should work
 
Originally posted by barrowman
this is what came up when I tried to restart apache...

httpd: Could not determine the server's fully qualified domain name, using 127.0.0.1 for ServerName
/usr/sbin/apachectl graceful: httpd started


and any idea of how I would fix it?

also once Ive downloaded the mysql thing and set up a new user I get this...

[localhost:~] wilyum% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] wilyum%


any idea what is going wrong?

Then after I go and physically create a dir called mysql in usr/local...etc In fact apart from the dir that I created "mysql" there is absolutely nothing in the library... :(

And try and install the .db

It says command not found. I've installed the package, but when I do a search with sherlock it finds nothing??????

Why does Unix always seem like a lottery to the ignorant? :)

Try reinstalling the mysql package, it sounds like you didn't install it. Above that this is weird. Now the apache thing is normal ;) Ignore it

~Yoshi
 
Ah I sorted it all out, turned out to be that the links were downloading nothing or a startup item installer and not the real thing, searched for the real thing on entropy and sorted it out.

Might be an idea to edit the links at the start of this thread though :)

Thanks for the help
 
Do you have to install both? I installed the PHP one and my php pages won't work. Nothing show's up. I did screw up the install the first time but i started over. When that didnt' seem to work i did it all over again. I haven't installed SQL though. I just want PHP for now.

??
Twister
 
Yes you can run just one. If you messed up the first time be sure to remove the php module and try again. If you need further assistance, I will be here to help.

~Yoshi
 
I don't understand whats going on here. I have php installed because i can get it to echo a phrase and i can get it to echo the PHP version. But when i put my form up it doesn't send the variables across. Could someone take a look at this. It's the first php form i've ever tried and it works on different servers, but i can't get it to run off my OS X machine running the web server. What's my problem now?

http://www.twistermc.com/php/TMphp.zip

Also how do i get to the web sites folder in the users library? the help i read said you had to add ~User but that didn't work. I dont think i have something set up right.

Thanks
Twister

.o(Sorry for sounding so stupid.)o.
 
I'm no expert (I'm sure they'll be along soon;) ) but I downloaded your files and this is the resulting er result:

Hi uoba. Age 55 years old. Your height is 6ft. You claim to be human. You have head . Current PHP version: 4.2.2

Don't stress I go through this sort of stuff with PHP, MySQL, Apache etc., solving it is half the fun.

Have you tried the phpinfo script (generate a file called info.php with the script:

<?
phpinfo()
?>

and try it on your web server. This'll tell you all you need to know about your PHP setup.

Maybe you do not have your Apache PHP mod installed/working properly. Have you been messing with your httpd.conf file? Your right, to get to the Users folder normally is http://127.0.0.1/~user/

So, maybe your Apache is stuffed!:confused:

Can you restart Apache:

sudo apachectl restart

This'll normally throw up errors (won't restart for you) if the httpd.conf is messed with in the wrong way.

Finally (I'm just shooting ideas at you), check to see if you have the php.ini file in /usr/local/lib/

I spent ages trying to figure out why I couldn't get user authentification working (form data)... the php.ini file was missing for some bizarre reason (I copied it from my XP machine!)

Like I said I'm sure the experts will sort you out.;)
 
"Hi uoba. Age 55 years old. Your height is 6ft. You claim to be human. You have head . Current PHP version: 4.2.2"
-- That's what it is supposed to do!!! Must be my server is screwed up.

" http://127.0.0.1/~user/ "
-- Doesn't go anywhere =(

"Finally (I'm just shooting ideas at you), check to see if you have the php.ini file in /usr/local/lib/ "

-- Where? I searched for php.ini and found nothing on my machine


I've come to the conclusion that i screwed something up. Now what?

Twister
 
Did you do the phpinfo test??

Try that first. What do you get?

As for the ~user problem, here is the part of the httpd.conf file that covers the commands:

#
# UserDir: The name of the directory which is appended onto a user's home
# directory if a ~user request is received.
#
<IfModule mod_userdir.c>
UserDir Sites
</IfModule>

#
# Control access to UserDir directories. The following is an example
# for a site where these directories are restricted to read-only.
#
#<Directory /home/*/Sites>
# AllowOverride FileInfo AuthConfig Limit
# Options MultiViews Indexes SymLinksIfOwnerMatch IncludesNoExec
# <Limit GET POST OPTIONS PROPFIND>
# Order allow,deny
# Allow from all
# </Limit>
# <LimitExcept GET POST OPTIONS PROPFIND>
# Order deny,allow
# Deny from all
# </LimitExcept>
#</Directory>


Also, with the following directory should be the httpd files for all the users you have on your machine: /etc/httpd/users you can open any user.conf file and it should look something like:

<Directory "/Users/testuser/Sites/">
Options Indexes MultiViews
AllowOverride None
Order allow,deny
Allow from all
</Directory>

(By the way I'm 27 not 55!!

:D )

Anyway, do the following in the terminal:

cd /etc/httpd/users
ls
[ls will tell you which user conf files are available]

pico user.conf
[this'll open the file in the pico text editor but shouldn't be editable unless you use sudo]

Check the code to see if it looks like mine above (the <Directory> stuff)

But, do the phpinfo thing first as I said, but I reckon something is up with your Apache.




As for your php.ini file, I don't think this is essential at present as I was blissfully unaware of it's non-presence for weeks and getting through most things okay.
But if you want to check, then:

cd /usr/local/
ls
[at this point you should see a directory called lib. No? then you ain't got php.ini either since it is meant to be in the lib directory]

You can rectify this by copying an unedited version as I did, but you need to get that from someone you trust (and make sure it's for the same version of php!).
 
http://www.twistermc.com/php/PHPinfo.pdf

I'll check out the other things when i get time. Gotta work now.

UPDATE: Ok so i can restart using sudo apachectl restart

And uoba I tried looking at /etc/httpd/users but i think it was empty.

Please remember that if you want me to try anyting you gotta say 'type in the terminal: (enter command here)' because i'm new at all this.


Thanks for all the help so far.

Twister :)
 
Hi,
First off its not ~user literally its (example): http://www.machowto.com/~dbesade/ where ~dbesade is my user. As for your files I will have to take a look at them. If you need any help with apache or php please don't hesitate to ask as I or someone else with assuredly be here to help :).

~Yoshi
 
Ok i got the user thing to work . I just restarted the whole machine. But my forms will still not work. Yoshi you can download them at the link provided above. They are really simple forms. But won't work on my webserver for some reason.

Thansk
Twister
 
okay I see the link now. I will try to take a look tonight but tomorrow is a more realistic time frame.

~Yoshi
 
Originally posted by yoshi
okay I see the link now. I will try to take a look tonight but tomorrow is a more realistic time frame.

~Yoshi

That's cool. But there is nothing wrong with the files. They've worked before. It's my setup i think. I can get it to echo stuff but i can't get the forms to echo the answers after i hit submit. Weird. I'll ask my teach also.

Well i'm off to school (again) so i won't have time till tomorrow to play either.

Thanks for everything
Twister
 
Status
Not open for further replies.
Back
Top