# [HOWTO] -  Setup PHP & MySQL



## yoshi (Jan 12, 2002)

Okay before we start I would like to mention that if you screw on any of these commands php will not work. If you wish to get to the document root of apache and use it as real webserver on the net the root of it is located at /library/webserver/documents and the CGI-BIN is located at library/webserver/cgi-executables. I do hope that this HowTo on PHP and MySQL helps you guys learn the terminal and its commands a bit better if you are new to MacOS X. As always please ask any questions you may have. My sources for info will be at the bottom of this HowTo.

PHP PART OF THE HOWTO:
Step 1) Start the Terminal Application.

Step 2) Type "curl -O http://www2.entropy.ch/download/libphp4.so.gz", wait for download to finish

Step 3) Type "gunzip libphp4.so.gz"

Step 4) Type "sudo mv libphp4.so /usr/libexec/httpd/"

Step 5) Type "cd /etc/httpd"

Step 6) Type "sudo apxs -e -a -n php4 libexec/httpd/libphp4.so"

Step 7) Type "sudo perl -p -i.bak -e 's%#(AddType \S+-php[ -])%$1%i' httpd.conf"

Step 8) Type "sudo apachectl graceful" to restart the web server

MYSQL PART OF THE HOWTO:

Step 1)  Download and install the package http://www.machowto.com/mysql-3.32.47.pkg.tar

Step 2) Create a new user in the "Users" System Prefs pane:
         1. Name: "MySQL User"
         2. Short Name: "mysql"
         3. Password: whatever you want

Step 3) Open a terminal window and type in the following commands (without the double quotes):

Step 4) type "cd /usr/local/mysql"

Step 5) type "sudo ./scripts/mysql_install_db", enter administrator password when asked

Step 6) type "sudo chown -R mysql /usr/local/mysql/*"

Step 7) type "sudo ./bin/safe_mysqld --user=mysql &"

Step 8) Use it with "mysql test"


Now you should have a perfect web hosting machine that runs PHP and has MySQL on it. It should also run any industry stand scripts such as a forum or a website. Credits are below.

I would like to credit http://www.entropy.ch for most of the infomation used and thanks to jadey for the links.

`Dave


----------



## kilowatt (Jan 12, 2002)

I've been down this road before, never could get MySQL to actually start.

Thanks Yoshi for the how-to, I'l be trying it later on today.

I think its critical that we get MySQL and PHP working for every mac os x user who wants it, and I'm glad you wrote a how-to.

I hope Swizcore gets this moved to the Archive, because its quite good!


----------



## Mac Write (Jan 13, 2002)

Or you could just uncomment the php lines in the httpd.conf, add index.php to the line with index.htm index.html, and PHP will work.


----------



## yoshi (Jan 13, 2002)

actually no you couldn't, the php module isn't in apache by default... it wouldn't work right if at all.. trust me I tried..


`Yoshi


----------



## Mac Write (Jan 13, 2002)

Actually that is how it works. Know how i know? I actaully did it. After a 10.1 Clean install, I opened up httpd.conf uncommentedthe following lines, restarted Apache and BOOM. PHPworked.


```
LoadModule php4_module        libexec/httpd/libphp4.so

AddModule mod_php4.c

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

Then added .php to the following line


```
DirectoryIndex index.html
```

Then restart Apache and boom PHP will work.

Make sure you have a 10.1 Clean install.


----------



## ScottW (Jan 13, 2002)

Very NICE. It all worked. Great!


----------



## yoshi (Jan 13, 2002)

> _Originally posted by Mac Write _
> *Actually that is how it works. Know how i know? I actaully did it. After a 10.1 Clean install, I opened up httpd.conf uncommentedthe following lines, restarted Apache and BOOM. PHPworked.
> 
> 
> ...



The built in Apple php module isn't really compiled well which is why I ut the extra 30 seconds of work in the above HowTo: I reccomend it for optimal performance. You  are indeed right it will work this way, but it works better with the newer module in apache and honestly I feel its safer.

`Yoshi


----------



## lcwid (Feb 2, 2002)

Thank you for the instruction. The PHP install worked out great. However, I'm having trouble with install of MySQL. I've always been a Mac user, but I'm a newbie at Unix. After I did the instructions to install MySQL and restarting, I typed the "mysql test" in the terminal and go this reply.
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Any suggestions? Could you recommend a good book for using mysql for newcomers to Unix?
thanx


----------



## lcwid (Feb 2, 2002)

I used my brain and got it to work. But I'm still looking for a good book or two to help.


----------



## lisamac (Feb 7, 2002)

<snip>ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2) </snip>

k. I'm really trying to use my brain too - but my hair is falling out... can you provide some insight on how you solved this problem? I'd love to know - really :-D

Thanks in advance -
LisaMac


----------



## yoshi (Feb 7, 2002)

okay that means mysqld isn't running . This tells me one of two things, one you didn't do the install right and the dameon isn't running right or at all or two you didn't do the below step and mysql isn't running .

try this:
Step 1) CD to the mysql install directory
Step 2) type "sudo ./bin/safe_mysqld --user=mysql &" 

that should start mysql and allow you to do the test 

Hope this helps

`Yoshi


----------



## lisamac (Feb 7, 2002)

[localhost:/usr/local/mysql] lisamac% sudo ./bin/safe_mysqld --user=mysql &
[1] 428
[localhost:/usr/local/mysql] lisamac% Password:******
******: Command not found.
[localhost:/usr/local/mysql] lisamac% 

is what i get when I try to run the above command (password is not all stars , but i tend to reuse my passwords for things like discussion forums, so i put them in instead of my password)- when i type in my password i get the command not found error...... i suck, i know... please help!

btw, thanks for getting back to me so fast :-D You're a lifesaver!

Cheers,
LisaMac


----------



## lisamac (Feb 7, 2002)

I downloaded the nice installation app from Marc Liyanage and installed as requested. did the steps maticulously ( i think ). I know that i've installed wrong though, cause I knew enough to try to start it. I think I understand the process... i got the error message "sorry the host 'blah blah' could not be looked up. Please configure the host command... etc etc." so i realized that my network guys had applied a hostname to me when i plugged in. Thinking i'm going to be working offline most of the time anyway i unplugged the network connection and restarted... this took me out to [localhost] so i tried to run mySQL again... now i'm getting the socket error.

I'm sure this makes no sense... i still suck... thanks for those who might try to decipher this though...

should i uninstall mysql and try again? if so, which files do i get rid of? or is there a simple way to actually re-configure the host command?

Thanks again m8's,
cheers,
LisaMac


----------



## yoshi (Feb 7, 2002)

[localhost:/usr/local/mysql] lisamac% sudo ./bin/safe_mysqld --user=mysql & 
[1] 428 
[localhost:/usr/local/mysql] lisamac% Password:****** 
******: Command not found. 
[localhost:/usr/local/mysql] lisamac% 


Okay thats something with the sudo command, it might give you that error if you enter you password wrong, at this point I would try redoing all the steps from #1 and see if it duplicates the error, get back with me  

`Yoshi


----------



## lisamac (Feb 8, 2002)

Seems I just needed to sleep on it... thanks so much for your help yoshi - I ran the process from the beginning, just like you said and it worked! 

I now have mySql and PHP running! :-D I'm so happy!

Thanks,
LisaMac


----------



## yoshi (Feb 8, 2002)

Your very welcome . If you do need any more help please don't hesitate to ask.

~Yoshi


----------



## DigiScript (Feb 13, 2002)

Man this is frustrating. I did something wrong when installing MySQL. I think I screwed up or skipped resetting the root password. Now I can not create databases. I can play with the "test" database all I want, but that ain't gonna cut it.
This is what it says to do to reset the password:

```
./bin/mysqladmin -u root -p password 'new_password'
./bin/mysqladmin -u root -h localhost -p password 'new_password'
```

But that does nothing. I have re-installed multiple times and still no luck. I am familiar with using PHP and mySQL, but have never done ANYTHING with Unix before, so I am pretty lost.

Side note: It still has 'mysql user deleted' folders in my Users' folder from the users I deleted in my attempt to figure out this mess. It wont let me get rid of them. Any help on this would be greatly appreciated.

If someone, anyone can help me get all this figured out I will be your bestest friend for ever and ever.

Thanks,
Digi


----------



## yoshi (Feb 14, 2002)

hey j00, if resetting your mysql password failed then you have no password for root is should be blank.. if you want to reset your password try this from the terminal its what I used to set my password:

/usr/local/mysql/bin/mysqladmin password new-password

type the directory exactly as I did only change new-password to the password you want!

This should work if you followed the directions above!

~Yoshi


----------



## laron8 (Feb 17, 2002)

ok the php install isnt working. Someone please help me. I am about to copy and past everything it says.
Welcome to Darwin!
[localhost:~] nate% curl -O http://www2.entropy.ch/download/libphp4.so.gz
  % Total    % Received % Xferd  Average Speed          Time             Curr.
                                 Dload  Upload Total    Current  Left    Speed
100 4723k  100 4723k    0     0  20165      0  0:03:59  0:03:59  0:00:00 14145
[localhost:~] nate% gunzip libphp4.so.gz
[localhost:~] nate% sudo mv libphp4.so /usr/libexec/httpd/
Password:
[localhost:~] nate% cd /etc/httpd
[localhost:/etc/httpd] nate% sudo apxs -e -a -n php4 libexec/httpd/libphp4.so
[activating module `php4' in /private/etc/httpd/httpd.conf]
cp /private/etc/httpd/httpd.conf /private/etc/httpd/httpd.conf.bak
cp /private/etc/httpd/httpd.conf.new /private/etc/httpd/httpd.conf
rm /private/etc/httpd/httpd.conf.new
[localhost:/etc/httpd] nate% sudo perl -p -i.bak -e 's%#(AddType \S+-php[ -])%$
Unmatched '.
[localhost:/etc/httpd] nate% sudo perl -p -i.bak -e 's%#(AddType \S+-php[ -])%$1%i' httpd.conf
[localhost:/etc/httpd] nate% sudo apachectl graceful
/usr/sbin/apachectl graceful: httpd not running, trying to start
Syntax error on line 240 of /etc/httpd/httpd.conf:
Cannot load /usr/libexec/httpd/libphp.so into server: (reason unknown)
/usr/sbin/apachectl graceful: httpd could not be started
[localhost:/etc/httpd] nate% 


See I did everything right.  and also my mysql install aint work either...here is what I got. 


Welcome to Darwin!
[localhost:~] nate% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] nate% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] nate% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] nate% cd /usr/local/MySQL
/usr/local/MySQL: No such file or directory.
[localhost:~] nate% cd /usr/local/mysql
/usr/local/mysql: No such file or directory.
[localhost:~] nate% 


Whats up? This is starting to get on my nerves. Please help.


----------



## yoshi (Feb 17, 2002)

> See I did everything right. and also my mysql install aint work either...here is what I got.
> 
> 
> Welcome to Darwin!
> ...



Are you sure you did that MySQL Install right? because I don't see the transcript there and you can't just /usr/local/mysql and hope its there, you have to download and follow the directions. 

Now as for your PHP problem you DID NOT follow my directions and here is what you did wrong, you did this:
cp /private/etc/httpd/httpd.conf /private/etc/httpd/httpd.conf.bak 
cp /private/etc/httpd/httpd.conf.new /private/etc/httpd/httpd.conf 
rm /private/etc/httpd/httpd.conf.new 

That screwed up your apache config and I did not specify any commands like those. All you needed to do to add the php config lines to the httpd.conf was this:
[localhost:/etc/httpd] nate% sudo perl -p -i.bak -e 's%#(AddType \S+-php[ -])%$1%i' httpd.conf

Now I have no clue what httpd.conf has in it since you replaced it but look at line 240 for your problem.


Sincerely
~Yoshi


----------



## laron8 (Feb 18, 2002)

ok..I have no idea what your talking about. I copied and pasted every last thing you said to make sure i didnt type it wrong. When I copied ans psated sudo apxs -e -a -n php4 libexec/httpd/libphp4.so this stuff below came up on its own.

[activating module `php4' in /private/etc/httpd/httpd.conf] 
cp /private/etc/httpd/httpd.conf /private/etc/httpd/httpd.conf.bak 
cp /private/etc/httpd/httpd.conf.new /private/etc/httpd/httpd.conf 
rm /private/etc/httpd/httpd.conf.new 

it gave me another prompt and I copied and pasted 
sudo perl -p -i.bak -e 's%#(AddType \S+-php[ -])%$1%i' httpd.conf 
so I dont see where i went wrong. 
and with the mysql..yea I forgot to install it..my bad...but when I do..where do I install it to? Can you give me a command on that? 

 I am very very very new to this. I been looking for tutorials on this stuff...but I found yours and it seemed easy enough. lol I followed step by step..and still somehow mess up.


----------



## yoshi (Feb 18, 2002)

what version of OS X are you using?
 10.1.2
 10.1.1
 10.1
 10.0.x

lemme know


----------



## laron8 (Feb 18, 2002)

10.1.2 hey im me on aim at ree122


----------



## yoshi (Feb 18, 2002)

Okay after half an hour on your computer via SSH I have got Apache + php working .

After step 7 a unique step for you is required since the apache server was complaining about not being able to find libphp.so which is and should be named libphp4.so I just simply typed this:
sudo mv /usr/libexec/httpd/libphp4.so /usr/libexec/httpd/libphp.so

to fix the problem. After that you could go to step 8 normally. I reccomend anyone else having the same php + apache problem to try that. Now everything should be working. I will do mysql if you wish as well..

Cheers

~Yoshi


----------



## laron8 (Feb 19, 2002)

This is what I am getting when trying to do mysql
Welcome to Darwin!
[localhost:~] nate% cd /usr/local/mysql
[localhost:/usr/local/mysql] nate% sudo ./scripts/mysql_install_db
Preparing db table
Preparing host table
Preparing user table
Preparing func table
Preparing tables_priv table
Preparing columns_priv table
Installing all prepared tables
Installation of grant tables failed!

Examine the logs in ./data for more information.
You can also try to start the mysqld daemon with:
./bin/mysqld --skip-grant &
You can use the command line tool
./bin/mysql to connect to the mysql
database and look at the grant tables:

shell> ./bin/mysql -u root mysql
mysql> show tables

Try 'mysqld --help' if you have problems with paths. Using --log
gives you a log in ./data that may be helpful.

The latest information about MySQL is available on the web at
http://www.mysql.com
Please consult the MySQL manual section: 'Problems running mysql_install_db',
and the manual section that describes problems on your OS.
Another information source is the MySQL email archive.
Please check all of the above before mailing us!
And if you do mail us, you MUST use the ./bin/mysqlbug script!
[localhost:/usr/local/mysql] nate%


----------



## metropol (Feb 19, 2002)

I followed your instructions and as soon as I enter the "sudo apachectl graceful" command I get the following response in Terminal:

/usr/sbin/apachectl graceful: httpd not running, trying to start
Syntax error on line 240 of /etc/httpd/httpd.conf:
API module structure `php4_module' in file /usr/libexec/httpd/libphp4.so is garbled - perhaps this is not an Apache module DSO?
/usr/sbin/apachectl graceful: httpd could not be started

I've downloaded the module and installed it a few times. Any suggestions?

metropol


----------



## lcwid (Feb 20, 2002)

I ran into a little trouble. I had trouble starting MySQL. I thought it maybe something I screwed up while poking around. So I downloaded it again, installed and took the steps. I also installed the automatic start. However I went to "/usr/local" and found two different versions. I downloaded the newer one, 3.23.49. I tried to delete the 3.23.47 but it would not let me. This is the reply"rmdir: mysql-3.23.47: Directory not empty" I'm new to the command line. What should I do?


----------



## yoshi (Feb 22, 2002)

sudo rm -r filename


----------



## paradoxchild (Mar 6, 2002)

I got these installations to work without a hitch and "mysql test" worked fine that first time. However, I have restarted my computer and now I get this error message when I try to test or use mysql in any way:
ERROR 2002: Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)

I don't have a clue what might of happened.  Any help would be appreciated.

Thanks!


----------



## yoshi (Mar 6, 2002)

Okay buddy, here is whats up, MySQL by default doesn't startup at startup time so after you restart your MacOSX machine you need to enter a few command in the terminal to startup MySQL. The steps you need to follow are under this paragraph. Do them every time your restart!

Step 1) Start Terminal and type cd /usr/local/mysql

Step 2) type "sudo ./bin/safe_mysqld --user=mysql &

Step 3) Enter your Password

and thats it, you can close the terminal and mysql should be started.

Hope this helps 
*Note*
The link for the package no longer works and I am putting up a mirror on my own server for you guys to download it at okay.
*/NOTE*


----------



## laron8 (Mar 6, 2002)

Or just download this package and it will load mysql on startup.
http://www2.entropy.ch/download/mysql-startupitem.pkg.tar.gz


----------



## d-mac-d (Mar 10, 2002)

I cannot seem to download the MySQL package.  I get this:


Not Found
The requested URL /download/mysql-3.23.47.pkg.tar.gz was not found on this server.


Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request. 
------------------------------------------------------------------------
Apache/1.3.22 Server at www.www2.entropy.ch Port 80


----------



## yoshi (Mar 10, 2002)

Okay I have offically setup a Mirror to get the mysql package:

You can download it here:
http://www.machowto.com/mysql-3.32.47.pkg.tar

Sorry about that folks~


----------



## d-mac-d (Mar 10, 2002)

thanks for the quick reply.  Everything's running smooth now. thanks.

- dm


----------



## d-mac-d (Mar 11, 2002)

Thanks for the great help on mysql.  It works fantastically!

Now, php is not working.  I have done all of the steps exactly, and it appears that apache is configured (at least partially) because I get this in the error_log when I do a graceful restart:

[Mon Mar 11 11:31:10 2002] [notice] Apache/1.3.22 (Darwin) PHP/4.1.2 configured -- resuming normal operations

I am trying to test it with a document called test.php containing:

<?php phpinfo() ?>

help!

- dm


----------



## yoshi (Mar 11, 2002)

Use this script

################
#Php Information Page #
################
<?php
phpinfo();
?>


~Yoshi


----------



## Nitro (Mar 16, 2002)

I had the same problem a lisamac, and this solved the problem for me..
I just ran steps 6 and 7 again after I rebooted, and I could access my databases.

Type "cd /usr/local/mysql"
type "sudo chown -R mysql /usr/local/mysql/*"
type "sudo ./bin/safe_mysqld --user=mysql &"

then type "mysql test"

to use the database test in mysql.

I just hope I don't have to run this every time I reboot, anyone know how to have it automaticaly initiate at startup?

-Eric


----------



## jkestr (Mar 26, 2002)

Nevermind


----------



## rmdxx (Apr 4, 2002)

i've been able to install mysql and query the sever. however, i seem to be unable to shut it down or make any password changes. i get the "access denied for user: '@localhost'.

i've checked the manual included with the distribution and the web and am stuck. when i tried to set a password for the root account using 
"mysqladmin password" it told me i was "using mysql as an anonymous users and anonymous users are not allowed to change passwords"

any help would be greatly appreciated.

thanks!


----------



## yoshi (Apr 4, 2002)

Come to irc and we can help you as this requires a lot of typing 

~Yoshi


----------



## rmdxx (Apr 4, 2002)

yoshi,

thanks for the reply. i went to look for some type of chat add-on to this site but couldn't find anything. also checked your profile and such for more icq details. i jsut found the site this morning and i don' tknow where you guys hang out.

let me know more details if you can..i'd lvoe to catch up with you guys.

-


----------



## yoshi (Apr 4, 2002)

oh weird!

come on in at irc.press3.com #macintosh for support & chat!



~Yoshi


----------



## vic (Apr 6, 2002)

would the php tutorial work for os x server also?


----------



## yoshi (Apr 7, 2002)

it *Should*


----------



## uoba (Apr 7, 2002)

I am newer than the newest to all of this...

The PHP part went fine, but the MySQL part won't budge. At the command:

cd usr/local/mysql

...I get:

usr/local/mysql: No such file or directory.

I did setup MySQL User correctly. Please help.


----------



## uoba (Apr 7, 2002)

further to this (after just reading Admiral's excellent Unix intro commands), I realise the cd command is to just get me into a directory. Assuming this, I navigated to the mysql user folder which is:

[localhost:/Users/mysql]

Am I right?


----------



## uoba (Apr 7, 2002)

Sorry to bore you, but my knowledge of this is expanding every minute.

I realised the above directory is not the one I want. I managed to navigate to:

[localhost:/usr/local]

When I do an ls command I get:

bin  etc  info man

... Sooo, obviously no mysql directory! Can you tell me why? (Again, I followed the simple User setup instructions).


----------



## uoba (Apr 7, 2002)

I created the missing mysql direcotry using: 

mkdir mysql

then went in to the directory and carried on with the instruction:

sudo ./scripts/mysql_install_db

but go:

sudo: ./scripts/mysql_install_db: command not found

???


----------



## uoba (Apr 7, 2002)

Installing the MySQL package helped!!

It's all up and running according mysql test


----------



## yoshi (Apr 7, 2002)

Okay so we are all working and okay now  ?


----------



## lcwid (Apr 7, 2002)

I've time to play with both MySQL and PHP separately. I'm trying to connect PHP to MySQL and having trouble. This is what I'm using

mysql_connect("localhost","nothing","password") or
	die ("Could not connect to database");
mysql_select_db("guestbook") or
	die ("Could not select database");

I've tried using mysql_connect("localhost","root","mypassword"), but no luck.
Is there another step to the install of MySQL and PHP for the two to work together or is the script wrong?


----------



## MrHappyMonkey (Apr 8, 2002)

I successfully installed PHP, but I can't install the mySQL portion of this tutorial. I created the mySQL user exactly as it said, but I can't do a "CD" to the /usr/local/mysql folder. 

I don't understand what I should do. I am running OS 10.1.3. Is there software that needs to be installed other than the sql setup and php setup?


----------



## uoba (Apr 8, 2002)

If you followed my escapades, I had exactely the same problem.

What I did was go to AdmiralAK's Unix command tutorial on this forum, and learnt the (very simple) commands to create the directory.

First use:

cd ..

Several times until you go back to the topmost directory (the cd command being the navigation command into a directory, cd .. takes you back 1 directory). Then, do:

ls

This list the directory your in. You should see the usr directory. Do the:

cd usr/local

Then do another:

ls

You should see a mysql directory... No, neither did I, so I created it!

Type:

mkdir mysql

The mkdir is basically make directory. Then:

cd mysql

You are now in the mysql directory, just as the part you where stuck on intended.

I did worry about going off and doing this, but everything installed fine after that and worked! (Don't forget to install the MySQL package file once you've downloaded it) I say this 'cause I forgot that part!


----------



## uoba (Apr 8, 2002)

Okay, so I have all up and running as per the instructions. My question is this:

I have a finished web site (finished a few months ago for a client), my tech person developed a MySQL and PHP database for reports to be published, updated, added, deleted etc. He has since left (we have also since decided to take the client to court ). Anyway, how can I test the site on my new fantatic discovewry of a MySQL and PHP enabled MacOSX!?

Is this a relatively simple answer, or is too much of a question and I should go get a book or hire another techy?


----------



## vic (Apr 8, 2002)

u should ak your tech person to come over and give you a short tour of mysql and create the dataases for the php script.


----------



## MrHappyMonkey (Apr 8, 2002)

I went to the /usr/local folder and tried to mkdir, but I got a "permission denied" message. I am logged in as an Administrator. I also got a "permission denied" error when trying to chmod a CGI script.

How do I get permission to make these changes?


----------



## Captain Code (Apr 8, 2002)

I'm not uoba, but just use sudo in the terminal:

sudo mkdir mysql

enter your adminisitrator password

(I assume that's the command you're talking about, but it'll work for other commands as well anyways)


----------



## MrHappyMonkey (Apr 8, 2002)

thank you. Now I have the mysql folder there, but I can't execute the next commad. This is what I get

```
[localhost:~] lchakov% cd ..
[localhost:/Users] lchakov% cd..
[localhost:/] lchakov% cd /usr
[localhost:/usr] lchakov% cd /usr/local/mysql
[localhost:/usr/local/mysql] lchakov% sudo ./scripts/mysql_install_db
Password:
sudo: ./scripts/mysql_install_db: command not found
[localhost:/usr/local/mysql] lchakov%
```

I don't think I installed the correct mySQL files. Can anyone link me to the correct setup for mySQL?


----------



## Captain Code (Apr 8, 2002)

I don't claim to know anything about setting up MySQL, but instead of doing

sudo ./scripts/mysql_install_db

you can try

cd scripts

sudo ./mysql_install_db

that might work, but if not then there's probably some missing files like you say.


----------



## uoba (Apr 9, 2002)

My tech person is in Bulgaria, I am in the UK!! 

MrHappyMonkey, here's the link to the MySQL download I used: 

http://www2.entropy.ch/download/mysql-3.23.49.pkg.tar.gz

Once you download it, uncompress it until it becomes the package (signified with the box package icon), then double-click that, which takes you to the installer. Follow the installation instructions from there. Once done, try your command again.

I think that was the message I was getting when I neglected to actually install MySQL.

If you've done this already, and you still get that message, then my knowledge ends there I'm afraid.


----------



## rmdxx (Apr 9, 2002)

mrhappy,

i beleive the paths and the set-up procedures are different depending on whether you use the source or the package installations. if you use the entropy pacakage install...the one in uoba's link, the directory path should be:

/usr/local/mysql/scripts/mysql_install_db

have you verified the contents of each directory along the way to ensure the files are where you expect them to be?


----------



## yoshi (Apr 10, 2002)

this howto is not for the source version. The source version should be avoided by anyone who fears the visiting the command line unhelped. I do not reccomend the source version just yet. I will be updating the how to to accomodate one as soon as I get it to compile correctly.

~Yoshi


----------



## uoba (Apr 10, 2002)

if the PHP side of things are working?


----------



## rmdxx (Apr 10, 2002)

are  you familiar with the phpinfo function?


----------



## uoba (Apr 10, 2002)

I just guessed:

[localhost:/] co% phpinfo
phpinfo: Command not found.

...obviously wrong! 

Can you enlighten me?


----------



## yoshi (Apr 10, 2002)

<?php
phpinfo();
?>

use that script.


----------



## vic (Apr 10, 2002)

put it in text file, and save the file as test.php then put it in a web accesible lcation and call it through the browser


----------



## rmdxx (Apr 11, 2002)

uoba,

how are you coming on the php? have you been able to test it yet?

btw, it looks as if the april security update made some changes to the .conf file. so if you are still having troubles, that might be part of the problem.


----------



## uoba (Apr 12, 2002)

Well, I loaded up the php script yoshi supplied, and it seemed to work okay -- reporting a few errors, but seemingly working. 

Unfortunately I think I've been playing around so much that I have come to the conclusion that I need a clean install of OSX on one of the machines, and use it specifically for testing this sort of thing.

Fortunately, my girlfriend/business partner is taking maternity leave (my fault!), so there is now an unused G4 400 sitting there... I wonder if she'll mind!


----------



## drewb2b (Apr 15, 2002)

First off - I am on an 800MHz G4 iMac.  I've got Apache working, installed a new PHP module, and even installed MySQL.

(Thanks Marc - http://www.entropy.ch/software/macosx/)

So my question is, can I only use this when I am connected to the Internet.  My first reaction would be yes, of course.  You are sitting on a webserver, why couldn't you use it.  I have a dial-up connection, and whenever I want to see any of my site files -- they only will pull up when I am connected.  I usually put in 127.0.0.1/~drew/test.php (or whatever other folder I want to access) and it works great.  The above file shows the data for my php installation, I can get into phpmyadmin and browse/edit/create databases for MySQL.   I've even installed a module (thanks again Marc) that starts MySQL on start-up automatically for me.  This is perfect for when I'm developing and testing my websites at home.  My httpd.conf file is up-to-date with the php extensions and everything. 

Then came the bad news.  I disconnected from the internet (damn I need a cable modem... anyway...).  And went back to IE to play in phpmyadmin and MySQL again.  it told me that the pages or site couldn't be found.  I thought 127.0.0.1 was a local address?  I've tried using localhost/~drew... nothing.  
Again - my whole set-up works perfectly, but only when I'm connected to the Internet.  NOT when I am sitting "locally" at my machine.

How - please tell me - can I use my machine with PHP, and MySQL without being on the internet?  Or can't I?  Do I have to be on some way or another?  

What (if anything) did I do wrong - or didn't yet do??


thanks for any help from you guys(and girls) out there..
** first time poster **
- drewb2b


----------



## drewb2b (Apr 15, 2002)

Not that anyone has read this yet - being it's at the end of the list, but I think I've found an answer to anyone else that is having this problem.  I just asked my boss, (who is a big time Mac OS X user) and he told me the problem is with my machine thinking that it's not on a network.

Bascially, He said I should put in some fake address numbers for the Ethernet port (like the ones on my machine at work here) so that my machine "thinks" it's on a network.  That way, I should be able to access 127.0.0.1 or localhost via the browser.  Since my PPP connection basically says 'This machine is a dead paper-weight until you hit connect...' I can see how this would work.  I have't tried it yet, but will be checking it out when I get home tonight.

If any of you have any reason why this wouldn't work - do you have any other suggestions?

thanks
drewb2b


----------



## uoba (Apr 15, 2002)

That seems to make sense, since the Network System Pref always seems to go hand-in-hand with Modem and Ethernet connections. I guess you really only need to assign your computer an IP address from the Ethernet prefs. Just to let your machine know it has one.

Anyone else?


----------



## aquamanx (Apr 30, 2002)

I have ran through this and I can't seem to find anyone with the knowledge to fix it. The post in response said come to IRC.  I keep getting

Access denied for user: '@localhost'

Anyone have any clue as too why this happens???

Thjanks,
Spencer Parker


----------



## yoshi (Apr 30, 2002)

let me guess you tried to change your password but something went wrong?


----------



## ebolag4 (May 1, 2002)

Yoshi,

I still cannot get php to run on my G4. I got it running on my iMac without any problems.

On the tower I'm still getting the apache module started, but when I place any php files in the Sites folder, I still get the "not found" page.


----------



## ebolag4 (May 2, 2002)

OK,

Now php does not work on either machine. I came to work this morning and php would not work on my iMac. The only new thing on the iMac is that I upgraded to 10.1.4. But I checked php out right after the install, and it still worked. Now it does not. My G4 tower was running 10.1.4 before I put php on it, and it has not worked yet.

Is there an incompatibility between php4.2 and OS X 10.1.4?


----------



## yoshi (May 2, 2002)

I myself have had issues with 4.2, use 4.1.2 for the best compatibility..


----------



## ebolag4 (May 3, 2002)

Do I need to uninstall 4.2, or can I just install 4.1.2 right over it?


----------



## earla (May 4, 2002)

Yoshi:

I tried the URL for the MySql files at machowto.com but the files aren't there. There isn't even a mailto button to find out if perhaps they are just moving things around or perhaps the server is down? Any clues?

Thanks,
Earl


----------



## elmimmo (May 4, 2002)

I am totally new to either UNIX and MySQLm and have some doubts about what exactly I did when following these instructions to install MySQL.

Can someone please explain what the following line tells the system to do?


```
sudo ./bin/safe_mysqld --user=mysql &
```

Also, why there is a need to create a MySQL user in the Users system preferences? I thought system users and mysql users were not the same thing and that mysql dealt with its own user authentication, l/p, privileges to read/write databases and all that stuff despite what user was logged into Mac OS X.


----------



## Nummi_G4 (May 7, 2002)

This is the third time I have tried to install PHP in a year.  Once again... it did not work.  I copied and pasted the terminal stuff right from my browser to the terminal app.  It still did not work.  Do I have the php file in the wrong folder or something?  I have it in: Library>WebServer>Documents.  Good enough?  WTF?


----------



## Nitro (May 8, 2002)

Ah HA!!  After looking around for a while, I found the page which the steps to install php and MySQL came from:

http://www.entropy.ch/software/macosx/mysql/

There is one step which is VERY IMPORTANT which was omited:

you should run in the terminal the following

mysqladmin -u root password  _new_password_here_ 

 UNTIL YOU ENTER THAT ROOT USER HAS NO PASSWORD!! 

This will create the root password, which will let you login as root using the command:  

mysql -u root -p

Another nice feature is on that page, you can download a file which will start mysql at system start...  here is the url for that file...

http://www2.entropy.ch/download/mysql-startupitem.pkg.tar.gz

I also recommend phpMyAdmin available at www.phpmyadmin.net/
It is great for easy mysql database management, using php... looking at the scripts it uses will give you a good understanding of how things work...


Hope this helps!! 

-Nitro


----------



## earector (Jun 4, 2002)

Yoshi,

You were responding to someone else, but this has happened to me! I'm getting this MySQL error. Not only that, I've managed to completely hose my uid 501 preferences....shebang!

However, I can still do some admin functions, login, etc. and have created a new user with Admin priviledges so that I could, among other things, logon to macosx.com to find some hep!

If something has gone wrong when trying to change the pwd, what is your advice?

Thanks a bunch.



> _Originally posted by yoshi _
> *let me guess you tried to change your password but something went wrong? *


----------



## Squintel (Jun 5, 2002)

I have followed instructions and cannot complete the sequence becuase of the following:

Syntax error on line 287 of /etc/httpd/httpd.conf:
Cannot add module via name 'mod_php4.c': not in list of loaded modules
/usr/sbin/apachectl graceful: httpd could not be started


I am running OS X Server with the 10.1.5 update added last night.

Any suggestions are greatly appreciated.


----------



## WhateverJoe (Jun 13, 2002)

I have several boxes up and running.. but all are live and in use... So after one experience of trying to quickly upgrade to newer versions.. I quick with trying :-(

Everything broke and broke hard when trying to upgrade to a newer version of PHP because I orginally did it the hard way... long before the easy pre-compiled .so how-to's ... and I need --with-gd in my php module...

It would be very helpful to have a how-to on upgrading a pre-installed and working php/mysql instalation that has GD.

php and GD are the best things I ever ran into  and I never want to go back to the third party web graphing package I was using on IIS/NT.


----------



## yoshi (Jun 13, 2002)

Squintel:
I sympathize your situation . Unfortunately I do not have a legal copy of Mac OSX Server to help you on. This how-to was designed for the regular version of Mac OS X. Even still I may be able to help you. Try my below suggestion.

Make sure that this line (around 239) is uncommented:
_#LoadModule php4_module        libexec/httpd/libphp4.so_ 

Also Make sure that this line (around 289) is uncommented:
_#AddModule mod_php4.c_ 

When you uncomment that first line, make sure that you have moved the libphp4.so file into the /usr/libexec/httpd/ folder.

That should make apache + php work. If not reply tell me the error and we will take it from there. I apologize for the late reply I was out of the country.
Sincerely

~Yoshi


----------



## yoshi (Jun 13, 2002)

Whateverjoe:

To update php all you need to do is compile a new libphp4.so file and move it into the /usr/libexec/httpd/ folder. I can safely assume the machine your having problems with is a MacOSX one? If so just compile php on it using the developer tools and just replace the libphp4.so file. From the looks of things that is all thats needed. Just make sure you compile the options you need in there. If that doesn't work for you just come on back and we will fix it 


~Yoshi


----------



## yoshi (Jun 13, 2002)

earector:
I also sympathize with you since I have had this problem many times in the past (ask kilowatt or gplex). My solution to using the command line version, which often messed up, was to do a fresh install of mysql and leave the root password blank as default and then install phpmyadmin. With phpmyadmin you can easily setup new mysql accounts and change passwords. If you need help with phpmyadmin please reply. 

Thanks.

~yoshi

P.S. I am assuming you have apache and php working correctly as they are needed for phpmyadmin to work at all.


----------



## yoshi (Jun 13, 2002)

Nummie_G4:

could you please be more specific as to the nature of your problem.

Thanks

~Yoshi


----------



## earector (Jun 13, 2002)

Yoshi,

Yep, I had to do a clean install of OSX. Luckily I didn't really have that much stuff on my machine...I did find out during the course of this debacle that Mac's CD Burner won't burn to a CD-R more than once! Guess I need to buy Toast. Also, I didn't install OS 9 at all...so we'll see how that works out for me.

I should probably install mysqladmin. I did figure out a way to modify the mysql database (the one that has all the users in it). Instead of gettting the mysql prompt by typing "mysql" (after starting the db server, of course) I type "sudo mysql" and am prompted for my admin password. Then I can add users, etc. till my heart's content.

<I figure you know this, Yoshi, it's for all the other folks banging their heads like me out there>

Anyway, I still fighting with permissions and such, and have taken a break from mysql for a few days...to much failure gets under my skin. I'll be back at it within a week, of course.

Thanks for taking the time to respond to all our Qs.

-Eric


----------



## Nitro (Jun 23, 2002)

I know there is a way to set up mac os x to have index.php as the default (as a pose to index.html).  Is it a setting in Netinfo?  Thanks for the help.

-Eric


----------



## rinse (Jun 23, 2002)

> _Originally posted by Nitro _
> *I know there is a way to set up mac os x to have index.php as the default (as a pose to index.html).  Is it a setting in Netinfo?  Thanks for the help.
> 
> -Eric *



Perhaps, but you can use terminal to edit it in /etc/httpd/httpd.conf

it should be located somewhere around line number 440 (my .conf is highly editted, so your mileage may vary)


----------



## yoshi (Jun 24, 2002)

yes you can use .html and here are some exact instructions to do it . Now these instructions are for a fairly stock version of the httpd.conf file so if you have edited yours heavily then I am not gunna say this will absolutely work even though it should. Your gunna need admin access to do this so make that a note. OKay lets get started.


Step 1. Open your terminal and type without quotes: "sudo pico /etc/httpd/httpd.conf"

Step 2. hit control-w and then put (without quotes) "DirectoryIndex index.html" then hit enter. This should take you to the part you need to edit.

Step 3. delete the .html part and add .php or if you want both add index.php

Step 4. Press Control-o to save then control-x to exit

Step 5. type apachectl restart

then your done. Your apache webserver will then be able to have index.php as a default page.

Hope this helps

~Yoshi


----------



## Nitro (Jun 24, 2002)

Thanks for the help!  I had eddited this a little when I installed phpmyadmin, and excelent website which can assist in managing a mysql database very well.

-Eric


----------



## rinse (Jun 24, 2002)

PHPMyAdmin rocks. It is by far the most useful little open source web app I have come across.


----------



## uoba (Jun 28, 2002)

remove the MySQL & PHP installation, so I can reinstall again?

I stupidly installed them from the Adobe Web Wrokgroup CD that came with GoLive, and now realise, this was not the best route.


----------



## lethe (Jun 29, 2002)

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:


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

can anyone offer any advice?  thanks


----------



## sixthring (Jul 1, 2002)

The easiest way I have found to get both php and mysql to run is by using the instructions for enabling php found in Apple's Knowledge Base and downloading SQL4X.  Just follow the directions in the Knowledge Base article (106485) and you will have php4.  All you need is a good text editor to edit the httpd.conf file.  As for mysql,  I downloaded the evaluation package called SQL4X.  This software installs mysql through an Apple installer package.  Just answer a few questions in a nice gui and the installer does all the work.  Before I ran the installer I created a user called mysql, which is required.


----------



## uoba (Jul 2, 2002)

Haven't tried that SQL4X... is it new?

Anyway, I found part of the fun learning how to do it all in the terminal (until it goes wrong!! )

As for editing the httpd.conf, nothing is quicker than the terminal's own editiors such as pico; just type pico filename, and you'll see.


----------



## sixthring (Jul 2, 2002)

No SQL4X is not new just not well known.  As for pico yes it is fairly simple, most people that may be considering setting up php and mysql may feel mor comfortable using a program such as bbedit, because it is familiar to them.  At least that is the impression I get from reading this thread.  I was only trying to provide the easiest and cleanest method of setting up php and mysql for a newbie.


----------



## uoba (Jul 2, 2002)

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).


----------



## yoshi (Jul 11, 2002)

> _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.
> ...



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


----------



## lethe (Jul 12, 2002)

libjpeg is installed:


```
% 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
```


```
% 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


----------



## owaters (Jul 15, 2002)

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


----------



## owaters (Jul 15, 2002)

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?


----------



## barrowman (Jul 16, 2002)

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?


----------



## yoshi (Jul 16, 2002)

> _Originally posted by owaters _
> *Summin wierd is going on here.....
> 
> No .php file works!
> ...



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

<?php
phpinfo();
?>

That should work


----------



## yoshi (Jul 16, 2002)

> _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
> ...



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


----------



## barrowman (Jul 17, 2002)

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


----------



## twister (Jul 24, 2002)

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


----------



## yoshi (Jul 24, 2002)

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


----------



## twister (Jul 25, 2002)

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.


----------



## uoba (Jul 25, 2002)

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! 

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.


----------



## twister (Jul 25, 2002)

"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


----------



## uoba (Jul 25, 2002)

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!!

 )

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!).


----------



## twister (Jul 25, 2002)

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


----------



## yoshi (Jul 25, 2002)

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


----------



## twister (Jul 25, 2002)

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


----------



## yoshi (Jul 25, 2002)

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

~Yoshi


----------



## twister (Jul 25, 2002)

> _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


----------



## uoba (Jul 25, 2002)

yoshi came at the right time there!

By the way, i was presuming we all knew what ~user meant 

Anyways, good luck!


----------



## Willex (Jul 27, 2002)

Thanx to you all and of course to Marc Liyanage. I can use PHP and Mysql on my MACOSX 10.1.5 and (almost) everything works fine! 

I have only one problem: Sometimes when I start my web server, no ip-adress appears. When this happens, it's also not possible to enter the server with 'localhost'. How is this possible?

The strange thing is that suddenly (e.g. one hour later) the ip-adress appears and my server is running, BUT not with my fixed ethernet ip-adress, but another variable ip-number. 

Can anyone help me with this.

Thanx!

Willex


----------



## yoshi (Jul 31, 2002)

What ip address is it?


----------



## twopeak (Aug 5, 2002)

I'm really getting frustrated about this... I tried several time, but always this:
[d577a1eb:~] bertrand% curl -O http://www2.entropy.ch/download/libphp4.so.gz    curl: (7) Timeout while accepting connection, server busy: 60

I also tried another how to guide, who tells me to use the wget command but this command is "not found"


----------



## sixthring (Aug 6, 2002)

A search of apple knowledge base will reveal directions on how to enable PHP, which is alread installed with OS X (any version), but is disabled from loading by default.  It is a really simple process.


----------



## ekullhu (Aug 6, 2002)

Hey, did anyone sort out twister's problem with variables not being passed through php? I ask cos I have exactly the same problem. php works fine (so far as I can tell to this point) but variables from html forms are not being passed on submit. the exact same scripts works on my web hosting server. can't find that php.ini file either


----------



## twister (Aug 6, 2002)

Nope no answer.  I just upload my php files to my shool website.  They work there.

If you get an answer let me know.

Twister


----------



## ekullhu (Aug 6, 2002)

OK after doing a simple search on http://www.php.net I found the answer to why the variables were not being passed.

this is the answer:

there is a configuration register_globals which is set to off from php 4.2.0 and above by default. It was set to on by default on earlier versions of php.

The way this affects the use of variables is this:

say you pass a variable like so http://www.domain.com?myvariable=value the way to access it if register_globals is on is:
$myvariable
with register_globals  off you must access it like so:
$_GET['myvariable']

simmilarialy $_ENV, $_GET, $_POST, $_COOKIE, and $_SERVER.

register_globals off and the latter method of accessing variables is now the suggested way of doing things.

Hope this help other people.

links I found info at:
http://www.php.net/manual/en/configuration.php#ini.register-globals
http://www.php.net/manual/en/language.variables.external.php


----------



## uoba (Aug 6, 2002)

Hmm, well spotted ekullhu, I was worried about leaving globals on, since it's a security threat. However, some of the PHP scripts I have (from various places) would take me a life-time to change to the new way!

Oh well. Anyway, you can create the php.ini file with just  the line register_globals On if you want to test it. Do the following (in the terminal Twister ):

cd /usr/local/
ls

[if you don't see the lib directory when you do the 'ls' command, then do the following]:

sudo mkdir lib
cd lib

[you are now inside the lib directory (type pwd in the terminal to confirm this), if you did have the lib idrectory already, you don't need to do sudo mkdir lib] Next:

sudo pico php.ini

[If a file opens up with a load of code then you already have the php.ini file, if not then you should get a blank Pico screen, if so then type]:

register_globals On

[Then press Ctrl-O to save and then Ctrl-X to exit Pico. You now have the php.ini file with Globals on. If you already had the php.ini file with the code already in it, then within Pico, type Ctrl-W and type: register_globals.(Without the full-stop). This'll jump to the line with the command on, just change to On if Off.]

Remember! Finally, you have to restart Apache from the terminal with:

sudo apachectl restart


----------



## twister (Aug 6, 2002)

Thanks.  But my variables still don't make it across.  Weird.  Maybe i need to restart the whole computer.

Twister


----------



## twopeak (Aug 13, 2002)

I was following the stepwise intallation (updating apache), because it's what apple.com says I should do, but when I enter the command "make" I get as reply: 
make: Command not found.

I have no other idea where to get more info...
in the apache.org files to install it (under unix, I suppose) it also suggests using make


----------



## uoba (Aug 13, 2002)

Can u give the link to the stepwise instructions, I'll have a look?


----------



## twopeak (Aug 13, 2002)

http://www.stepwise.com/Articles/Workbench/2001-03-24.01.html
the problem happens in the second gray box


----------



## yoshi (Aug 13, 2002)

all due respect this thread is for PHP problems only.. please do not litter with request for unrelated help.

To All who have done this howto.. I am going to update it sometime this week or next week so stay tuned.

Thank you

~David


----------



## uoba (Aug 13, 2002)

Waiting in anticipation


----------



## Nummi_G4 (Aug 19, 2002)

hey guys, I finally got PHP running. I have a tip. Someone might have said this, but I missed it. once you follow the tutorial, make sure you turn on the web sharing, webserver or whatever it is called. (The option is in the system prefs) And go to http://127.0.0.1/yourscript.php in your browser.


----------



## twister (Aug 30, 2002)

Could someone help me?  I installed PHP on my Powerbook & 10.2 but it doesn't work 100%.  

Here's what i did to install.  http://www.entropy.ch/software/macosx/php/

According to php phpinfo() i'm running 4.2.2, the same as my hosting company. But when i try to run the attached files, it only goes through the loop once and doesn't repeat.  Why?  What might i have set up wrong?  I know php is working, just not 100%.  And i know the files are coded correctly because they work on my internet site just not locally on my computer.

Please help.  I really want this to work.

Thanks
Twister

Files:  http://www.twistermc.com/fun.zip


----------



## earector (Aug 31, 2002)

Twister,

I'll take a look at this file to see if I can find anything wrong with it.

Also, for those of you who recently upgraded to 10.2 (Jaguar), and had php stop working, there's an osx.com thread that helped me: 

http://www.macosx.com/forums/showthread.php?s=&threadid=21627 

I looked here for the answer first, because this is the thread that originally helped me set up php and mysql.

-e


----------



## twister (Aug 31, 2002)

I have found my issue!!  In searching i found a comment someone made about PHP not noticing Mac like breaks.  So i saved out my text file with UNIX line breaks and it worked!!

Twister


----------



## earector (Aug 31, 2002)

DOH! I had that problem with a perl script not too long ago. Why didn't I think of that? 

BTW, it's a neat bit of code.

-e


----------



## twister (Sep 1, 2002)

Humm.  Now i have the same problem i used to.  I can't pass variables.  I tried to follow the instructions on the previous page, create a php.ini file with register_globals On and it didn't help. 

Any ideas with this one?

Twister

[ UPDATE ]  I searched the net for php.ini and found out it's supposed to be register_globals = On.  Not register_globals On


----------



## paleafterglow (Sep 4, 2002)

im running mac os 10.2 with mysql 3.23.51

whenever i try to "log into" mysql with the terminal to create a new database, edit permissions or whatever .. i always recieve this error:


```
dyld: ./bin/mysql Undefined symbols:
./bin/mysql undefined reference to _BC expected to be defined in /usr/lib/libSystem.B.dylib
./bin/mysql undefined reference to _PC expected to be defined in /usr/lib/libSystem.B.dylib
./bin/mysql undefined reference to _UP expected to be defined in /usr/lib/libSystem.B.dylib
Trace/BPT trap
```
if anyone could point the problem or what not.. it would be greatly appreciated... thanks much


----------



## flash (Sep 5, 2002)

dyld: ./bin/mysql Undefined symbols:
./bin/mysql undefined reference to _BC expected to be defined in /usr/lib/libSystem.B.dylib
./bin/mysql undefined reference to _PC expected to be defined in /usr/lib/libSystem.B.dylib
./bin/mysql undefined reference to _UP expected to be defined in /usr/lib/libSystem.B.dylib
Trace/BPT trap

I run into the same problem. 

Though I've searched all over, I have found a few other references to this problem, but no solutions. It's starting to hamper me, because I can't dump client databases into my local mysql.

Anybody know what's going on?


----------



## DigiScript (Sep 14, 2002)

OK, let me start by saying a HUGE thank you to Marc Liyanage, yoshi, and everyone else in the thread who has helped out. This thread got me running back when I first installed 10.1, and I am hoping it can get me over a hump now that I (clean) installed 10.2. 

I used Marc Liyanage's page for everything and now PHP is installed and running, and so is MySQL, but I can only access MySQL with the root user. I have tried adding rows to the users table through phpMyAdmin as well as GRANT statements in the terminal- obviously neither worked.

Last time I installed these things, somewhere along the way I had to create an actual MySQL user for OSX- this time I did not see that step listed anywhere. I tried to go into the profiles anyway and create a mysql user and it said there was already a user with the short name 'mysql'. However, my main user profile is the only that shows up.

I feel like I am so close... can anyone help me?
Digi


----------



## metaneovurt (Sep 16, 2002)

Hello all...

I am running 10.2 and have both PHP/MySQL running. Don't ask me how. I used Marc L.'s mysql installer, HOWEVER it seems there is a built in mysql user on OS 10.2. When I tried to add a mysql user, there was already an existing account. I used NetInfo to figure out the password, but to no avail. It just has an asterick.

Here is the order of what I did:
1. Turned Apache on.
2. Installed PHP
3. Installed MySQL
4. Restarted Apache
5. Installed Marc's auto startup for mysql
6. Restarted Apache
7. Restarted iBook

This is a hashed together sequence of events that occurred over a period of four days.

I now have a db named 'test' that I have NO IDEA how it came to be. I also am able to use phpMyAdmin to work on it and have set up everything on my iBook that I have online.

The only thing I can figure out is that we no longer need to *do* as many things with 10.2 as we did in 10.1 to get Apache/MySQL/PHP running. I have a sneaking suspicion that because MySQL is in the Apache directories, that the mysql user name was automatically created upon software installation.

But we seriously need someone who understands all sides of this situation to explain fully what's going on. I can only tell you that I'm working, that I'm happy, and that I consider myself to have had a bit of luck.

regards,
-+vurt


----------



## DigiScript (Sep 16, 2002)

By no means am I an expert, but I did recently get all of this working under 10.2

As far as I can tell, you are right- the mysql user is created automatically, thereby reducing the steps required. The test database is always installed with MySQL. The problem I had was getting access to other databases with any user besides the mysql root user. To fix this I did:

//log in as root in terminal
sudo su
//enter password for system root user- should log you into terminal as root
//then log in to mysql as the mysql root user (remember mysql and system each have their OWN root user)
mysql -u root -p
//enter password for mysql root user- should take you to mysql prompt
//then use a simple grant statement
grant all privileges to me@localhost identified by 'myPassword';


Hope this helps someone who may be stuck at this point.
Digi


----------



## metaneovurt (Sep 18, 2002)

Digi...

Thanks a lot! That helps clarify some things. One question: since there is already a mysql user set, how do i find out and change the root user for mysql? That's where I got miserably stuck.


----------



## DigiScript (Sep 18, 2002)

meta, I think maybe you are getting confused a little (kinda like I was for a long time). The mysql user is set by default by OSX for OSX, ie- I login to my comp as bclink, it creates another user named mysql.

When you install MySQL it creates a default root user for MySQL with no password attached. You should give the MySQL root user a password, and then create another MySQL user (see my previous post) to use for everyday db access.

There are pretty good instructions at http://www.entropy.ch/software/macosx/mysql/ (where you probably installed from), but you basically do this:

mysqladmin -u root password new_password_here

replacing new_password_here with whatever you want the password to be of course. Let me know if this doesn't clear things up.

Digi


----------



## paleafterglow (Sep 18, 2002)

digi, my problem is that i cant even log in as the root user.  i even have a password set for the root user.  every time i try to log into mysql, i just get the errors that i listed in my post above.  you have any idea what is wrong?

thanks much for the help


----------



## DigiScript (Sep 18, 2002)

honestly I have no idea what those messages mean, sorry. If you are sure you set the mysql root users pass already and it is still not working I would just reinstall MySQL from the link I posted above. If there is a chance the MySQL root user has remained untouched, try logging in like this:

mysql -u root

if there is no password for the root it should bring up the mysql> prompt, and then you can set the password by following the process I mentioned above.

Sorry if I am not much help. It took me several tries to get mine working so dont be afraid to try reinstalling MySQL to get a fresh start. As for creating databases and stuff I would HIGHLY recommend installing phpMyAdmin. It creates a GUI for MySQL and makes it much easier to manipulate your databases and data.
http://www.phpmyadmin.net/


----------



## paleafterglow (Sep 19, 2002)

hey digi.... thanks much for the reply, i really appreciate it... i was planning on just going ahead and reinstalling MySQL... that brings me to one more question... what is the best way to uninstall MySQL?

again, thanks much for everything.


----------



## DigiScript (Sep 19, 2002)

I am pretty sure you don't need to uninstall. I think that reinstalling will just overwrite the old copy.

Check the entropy site (link is in previous posts) for more details. Anyone else know for sure about this?

Digi


----------



## Kinniken (Sep 21, 2002)

First, a great thanks to Yoshi! With your instructions, I installed PHP and MySQL without problems in 15 min 

However (there is always a "however" in CS  ), I get an error when trying to create a new database in MySQL:

mysql> select user();
+----------------+
| user()         |
+----------------+
| root@localhost |
+----------------+
1 row in set (0.00 sec)

mysql> create database pastiches;
ERROR 1006: Can't create database 'pastiches'. (errno: 13)

As you can see, I logged in as root to make sure I would have the permissions, and simply tried to create a databse, as explained in the MySQL manual...
Anyone has an idea of what went wrong?

TIA,

Kinniken


----------



## yoshi (Sep 23, 2002)

Hey all,
First off to those who needed help in the last few weeks I apologize I have been busy (and still am) with things like moving out, getting an internet connection and whatnot.

Second of all I plan on getting a copy of MacOSX 10.2 and updating this howto. Until then its basically 10.1.x only. So I apologize for the inconvinence, just know the update is coming.

Now to kenniken:
Try installing phpmyadmin and see if you get a simular issue because as far as I see your all good there.


~Yoshi


----------



## Greystroke (Oct 11, 2002)

well i guess it's just a waiting game now...

hurry back


----------



## twister (Oct 16, 2002)

Ohh no... I went to add something to the php.ini file and it didn't work well here's what happened

----------------
[MacMan:~] work% cd /usr/local/
[MacMan:/usr/local] work% ls
bin             lib             mysql-3.23.51
include         mysql           share
[MacMan:/usr/local] work% cd lib
[MacMan:/usr/local/lib] work% sudo pico php.ini
Password:
dyld: pico Undefined symbols:
pico undefined reference to _AL expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _CE expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _CL expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _CM expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _CS expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _DC expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _DL expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _DM expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _ED expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _EI expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _IC expected to be defined in /usr/lib/libSystem.B.dylib
pico undefined reference to _IM exTrace/BPT trap
---------------------------

Now what?  How do i erase the existing file and create a new one?  Of fix this one?

Twister


----------



## charleskline (Oct 17, 2002)

I think I have MySQL installed ok, but I can't seem to test this thing. Here is my terminal transcript, what am I doing wrong?

[Charles-Klines-Computer:/] root# cd /Library/MySQL/
[Charles-Klines-Computer:/Library/MySQL] root# sudo chown -R mysql /Library/MySQL/*
[Charles-Klines-Computer:/Library/MySQL] root# sudo ./bin/safe_mysqld --user=mysql &
[1] 1255
[Charles-Klines-Computer:/Library/MySQL] root# A mysqld process already exists
mysql test
mysql: Command not found.
[1]  + Exit 1                        sudo ./bin/safe_mysqld --user=mysql
[Charles-Klines-Computer:/Library/MySQL] root# mysql test
mysql: Command not found.


Thanks
Charles


----------



## charleskline (Oct 17, 2002)

Update! I finally got it all working. I was trying to get this all setup from my standard user. I created a user called root and went through the setup steps again and now everything is working!! 

The funny thing is, I was not able to actually use MySQL until I logged out from the root account and back in with my normal login which is an ADMIN but still... is this normal?

Also, when I tried to create a database I got a 1044 error. Any thoughts on this?

Thanks for all the help here.
Charles


----------



## Racer D (Oct 19, 2002)

I followed the ules to install php, all went fine, then i went to check if it works. I see the php code in browser, instead of seeing the script right. I open the page and i see <?php phpinfo(); ?>as if it was the content

anyone else experienced this?

btw I´m using: iMac 700mhz, OS X 10.2


----------



## sixthring (Oct 22, 2002)

I get the same error on Mac OS 10.2.1.  Everything worked fine until I updated to this version of the OS.


----------



## charleskline (Oct 22, 2002)

I was able to fix my 1044 error by logging in as root and trying again. See if this works for you.


----------



## binkybink (Oct 22, 2002)

I've followed all the instructions (been struggling for days now) and everything seems to go fine until i try to test and write http://localhost... blah blah into my browser.  it claims it can't find it, or that no connection can be made.  personal web sharing is enabled, the php is set up, mysql is set up and apache should be golden.

what in the world am i doing that is wrong?  (besides being a total knucklehead)

thanks


----------



## twister (Oct 22, 2002)

http://localhost...  ?? what's that for?

To access your files on your machine you type in http://127.0.0.1/~username

Hope that helps.

Twister


----------



## pry3i (Oct 22, 2002)

FOUND: yet another gotcha.

if you have changed your machine name by modifying
the /etc/hostconfig file and try to run the mysql_install_db
with the  ethernet jack unplugged, the script will bomb 
and tell you how much you suck (or something like that)

iii


----------



## binkybink (Oct 23, 2002)

I figured out the IP thing just after i wrote that.  the problem was i installed pMachine and it wouldn't recognize everything all together unless i was using Localhost.

got that straight now though.

thanks!


----------



## sixthring (Oct 28, 2002)

Although Apple builds Apache and support for PHP into OS X.2, it doesnt actually turn these features on. Youll have to do that part yourself. Heres how:

*Turn PHP Support On* 

To activate Apaches PHP module, youll first need to modify the Apache configuration file. Since the configuration file is hidden from the Finder, youll have to make a trip to the command line.
Open Terminal (Applications: Utilities: Terminal). Before you make any changes, youll want to create a backup of your Apache configuration filejust in case something goes wrong. To do this, type the following commands into the Terminal window:

cd /etc/httpd

sudo cp httpd.conf httpd.conf.orig

Enter your administrator password when prompted, and then type sudo pico httpd.conf.  This command opens your Apache configuration file in pico, a Unix text editor. In pico, press control-W to open the Find command, and then type php. When you hit the return key, your cursor should land on the line:

 #LoadModule php4_module libexec/httpd/libphp4.so

Using the left-arrow key to move your cursor, remove the # character at the beginning of this line.  Press control-W again. This time, type the string:

mod_php4.c and press return. 

Remove the # character from the beginning of this line as well. Press control-W a third time and search for the string x-tar. When you land on it, move your cursor to the end of the line, press return, and then add the line:

AddType application/x-httpd-php .php

Once youve made these three changes, save the file by pressing control-O and then the return key.  Press control-X to exit pico.  Apache should now automatically load the PHP module on start-up. When the Web server encounters pages ending in .php, itll send them to the PHP module for interpretation.

*Start Apache*

With PHP enabled, youre ready to flip the switch on your Web server. Open your System Preferences and select Sharing. Click on the Services tab, and select the Personal Sharing option. Click on Start. (If Web sharing was already on, youll need to turn it off and then back on to activate the changes youve made.)

*Testing*

To find out whether the PHP module has been correctly activated, open your favorite text editor and create a new document. (If youre using Apples TextEdit, make sure youve turned off the pro grams Rich Text features, in Preferences, first.) In your blank document, type <? Phpinfo(); ?>.  Save the file as test.php in the Sites folder in your users folder.  Open your Web browser, and type in the address http I host/ ph p, where username is your short name on the OS X machine. (Because PHP is a server-parsed language, nothing will happen if you open a PHP file in your Web browser via the File menu or by double-clicking. To execute PHP pages, you must access them through a PHP-enabled Web server.)
Your browser should display tables packed with arcane data about your new PHP environment. If you see only one line of raw PHP code, repeat this step.


----------



## binkybink (Oct 28, 2002)

thanks so much.  i actually got it all up and running and now i'm just whirrling away


----------



## mwesterl (Oct 28, 2002)

Ola People,

I've got a big problem activating PHP on my OSX10.2 Apache. When I follow the steps and want to restart my apache it give the following problem:

[westerlaak:/etc/httpd] martijn# apachectl restart
/usr/sbin/apachectl: line 171:  1419 Trace/BPT trap          $HTTPD -t >/dev/null 2>&1
/usr/sbin/apachectl restart: configuration broken, ignoring restart
/usr/sbin/apachectl restart: (run 'apachectl configtest' for details)

apachectl configtest gives:

[westerlaak:/etc/httpd] martijn# apachectl configtest
Processing config directory: /private/etc/httpd/users
 Processing config file: /private/etc/httpd/users/frank.conf
 Processing config file: /private/etc/httpd/users/martijn.conf
Syntax OK
dyld: /usr/sbin/httpd Undefined symbols:
_XML_ErrorString
_XML_GetErrorCode
_XML_Parse
_XML_ParserCreate
_XML_ParserFree
_XML_SetCharacterDataHandler
_XML_SetElementHandler
_XML_SetUserData
/usr/sbin/apachectl: line 171:  1424 Trace/BPT trap          $HTTPD -t


Anyone a solution??

Greetings,
Martijn van Westerlaak



Found the Solution, thanks anyway


----------



## Hype.it (Nov 23, 2002)

Thanks for all your help fellas. 

Been trying to get MySQL on autostart for a while... I'm finally happy and very greatful to have people like you folks around.

Keep up the great work!


----------



## elspif (Dec 2, 2002)

For those still using this tutorial that are still running 10.1, the php module at www2.entropy.ch/ only works for 10.2.

If you need a version that runs on 10.1.x, the older 4.2.2 version is still available. Make sure to rename it to the name "libphp4.so.gz" after downloading and before uncompressing with the "gunzip" command.

It can be downloaded at http://www2.entropy.ch/download/libphp4.so.gz-10.1

For more info check www.entropy.ch


----------



## gerberad (Dec 3, 2002)

I have tried many things, but with this info I finally got the mysql server going.  But now when I use "/usr/local/mysql/bin/mysql" it tells me:

dyld: mysql Undefined symbols:
mysql undefined reference to _BC expected to be defined in /usr/lib/libSystem.B.dylib
mysql undefined reference to _PC expected to be defined in /usr/lib/libSystem.B.dylib
mysql undefined reference to _UP expected to be defined in /usr/lib/libSystem.B.dylib
Trace/BPT trap


----------



## gerberad (Dec 3, 2002)

I was looking through the past posts, and I see how the whole thing works now.  This is the first time posting.  But I saw that someone else had the exact SAME Issues.  But I didn't see any solution.  Is there no solution, or am I just over looking something.

Thanks!


----------



## ether7 (Dec 3, 2002)

I have the MySQL and PHP installed and running, now is there something that i can do so that the system will restart apache or mysql if they crash for some reason?  Also, how do i make mysql start automatically?

Thank you for your help.

http:www.weboddities.com


----------



## ksv (Dec 4, 2002)

> _Originally posted by ether7 _
> *I have the MySQL and PHP installed and running, now is there something that i can do so that the system will restart apache or mysql if they crash for some reason?  Also, how do i make mysql start automatically?
> 
> Thank you for your help.
> ...



Does apache and mysql crash at all? 
At least, here's  an extension to make mysql automatically start on system startup


----------



## Da_iMac_Daddy (Dec 10, 2002)

Does it require anything different to install PHP on 10.2.2? I followed the steps exactly but when I try a sample form page and hit submit it prompts me to download action.php.

Anyone know whats going on?


----------



## Da_iMac_Daddy (Dec 10, 2002)

HEHE I geuss you would need to plop the sites into the webserver folder in order for them to work


----------



## twister (Dec 10, 2002)

Ohh yea that might help.   

Glad you got it to work though.

Twister


----------



## nelson (Dec 27, 2002)

I'm trying to get mysql & php up and running

I've used the terminal window to enable php on macosx 
To make sure php is working i've created a test file in /Library/Webserver/Documents.

<html>
<head>
<title>PHP Test</title>
</head>
<body>
<?php
    phpinfo()
?>
</body>
</html>

When I enter  http;//localhost/test.php in the address field l should get the php information page indicating php is running on the computer instead l get 

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /Library/Webserver/Documents/test.php online 12
Parse error: parse error in /Library/WebServer/Documents/test.php online 13

appreciate any help, thanks


----------



## twister (Dec 28, 2002)

Try putting a ; after phpinfo()

phpinfo();

Also the url should be http://127.0.0.1/~username/test.php

See if that helps

Twister


----------



## nelson (Dec 28, 2002)

I put ; after phpinfo()  l don't think it makes any difference

and also moved the file to Users, and I'm now getting 

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /Users/Nelson/Sites/test.php online 12
Parse error: parse error in /Users/Nelson/Sites/test.php online 13

I think there is something wrong on the last line, but it only goes down 10 lines


----------



## twister (Dec 28, 2002)

get rid of all HTML and just put in the PHP.  PHP doesn't need HTML to work.  Just put 

<?php phpinfo() ?>

Try that and see if it works.

Twister


----------



## nelson (Dec 28, 2002)

terrific, it works

thanks, Twister

Nelson


----------



## owaters (Dec 29, 2002)

I have just upgraded to 10.2 and now Apache doesn't seem to be working.
When I goto local host it presents the Library:Webserverocumentation directory but non of the PHP files work. It just shows the code.
It was working before.

How do i go about re-installing?
Thanks


----------



## owaters (Dec 30, 2002)

Managed to get it working  

One query though, when someone connects to my computer they get taken to the 'Library/WebServer/Documentation' directory.
I thought they were supposed to be taken to the 'Sites' directory in my home folder  

Can someone clear this up for me? Thanks


----------



## twister (Dec 30, 2002)

how are they connecting?  If you tell them the URL they should go into the sites folder.  http://yourIP/~username/


----------



## owaters (Dec 30, 2002)

I am simply telling them my IP address.
If i tell them to connect to my IP address with /~username then they goto the sites folder. Can I get them to goto my sites folder automatically just by putting my IP address in and not including the /~username bit?

Also how come browsers dont automatically goto index.php?
Instead i just get a directory/file list view when viewing in Internet Explorer.

Thanks


----------



## twister (Dec 30, 2002)

I don't know those answers. Sorry. The inxex.php is in some config file but i don't know where.  You could put a 1 second refresh tag on your index.html page that takes them to the index.php page.

Twister


----------



## larry98765 (Dec 30, 2002)

Hi all.

I very carefully followed part 1 (PHP) of the install process with no apparent hitch. I created some test php code to test the php server: 
<?php phpinfo() ?>

in a file called "test.php"

1st I saved it to the root, library, webserver, documents folder and tried running it by http://localhost/test.php and just got the line, unprocessed, spit back in my web browser. So the file was found and accessed, but the php was not processed.

Then I tried putting it into my sites folder in my own user directory and tried http://127.0.0.1/~myusername/test.php and the same thing happened.

So in other words, my pages are there but not being processed by php. 

Any thoughts would be appreciated. -- Larry

EDIT: OK. I figured it out. Sixthring's post helped a lot. I had everything right in my config file except this line was missing:

AddType application/x-httpd-php .php 

Thanks, Sixthring!  -- Larry


----------



## Thaiâ¢ZX-6R (Jan 1, 2003)

I think I have MySQL installed properly..... I think. Now I'm trying to install a message board. PHP works as the install file is install.php.... now it gets to the point where it's asking me for my:

1. Database server
2. Database name
3. Database user
4. Database password

As default my Database server was filled in as 'localhost'.

What is my Database name/user/password?

Would it be MySQL User/mysql/*******?

I'm trying everything I can think of and nothing seems to work. Thanks for any help!


----------



## twister (Jan 1, 2003)

ok you have to set up a database first.  Some hosts come with that.  You just have to go in and set it up.  Usually give it a name and your done.  Then the usernname and password is the same as it is to log into that database.  Mine is the same as my hosting username and password.

Does that help?


----------



## roguephp (Jan 11, 2003)

Is there a way to get mysql running without having to cd into the mysql directory first? to start apache all i need to do is type apachectl start - why all the directory stuff for mysql?


----------



## wiz (Jan 11, 2003)

look here 
http://www.macosx.com/forums/showthread.php?s=&threadid=26634

well that explains how to start the server when the computer starts


----------



## roguephp (Jan 11, 2003)

I don't actually mind starting apache and mysql when i need them, just was wondering why i had to start mysql from its install directory and not apache. also, is there a way to make it so i don't have to sudo to start apache/mysql?


----------



## wiz (Jan 12, 2003)

i don't think u have to sudo them, try it out. but i'm not sure.


----------



## roguephp (Jan 12, 2003)

definately need to sudo them to get them to start. see:

ckline% apachectl start
Processing config directory: /private/etc/httpd/users
 Processing config file: /private/etc/httpd/users/ckline.conf
fopen: Permission denied
httpd: could not open error log file /private/var/log/httpd/error_log.
/usr/sbin/apachectl start: httpd could not be started

and this is what i get for mysql:

ckline% cd /usr/local/mysql/
 ckline% ./bin/safe_mysqld &
[1] 484
[Charles-Klines-Computer:/usr/local/mysql] ckline% The file /usr/local/mysql/libexec/mysqld doesn't exist or is not executable
Please do a cd to the mysql installation directory and restart
this script from there as follows:
./bin/safe_mysqld.

See... now if I sudo both of those, everything starts just fine. ...why is that? are those services installed incorrectly? do i need to change something? should i change something?


----------



## wiz (Jan 12, 2003)

permissions!

thats your answer


----------



## roguephp (Jan 12, 2003)

ah yes... that much I assumed. after i installed both apache and mysql (got the instructions to do this off http://www.phpmac.com/

the last step of which for mysql is to do this:

sudo scripts/mysql_install_db
sudo chown -R root  /usr/local/mysql
sudo chown -R mysql /usr/local/mysql/data
sudo chown -R root /usr/local/mysql/bin

is this not the right way to set the permissions?


----------



## roguephp (Jan 13, 2003)

Sorry... more on this.

So... I am trying to get MySQL to load at startup so I followed the instructions in another thread and created the necessary files, but MySQL does not load. 

The script has this to start mysql:

        cd /usr/local/mysql ; /usr/local/mysql/bin/safe_mysqld --user=mysql &

but trying this in the terminal does not start mysql so i am not sure if that is the problem. anyone wanna help?

thanks
ck


----------



## ListerMint (Jan 27, 2003)

I did a real dumb thing. I forgot to create a MySQL user account BEFORE I installed MySQL. The installer created one, called Other..., for me. But  I have no idea what the password is so that I can start up MySQL. Is the a way to fix this? 

ListerMint


----------



## roguephp (Jan 27, 2003)

Just create the MySQL account now, and delete the other.


----------



## ListerMint (Jan 27, 2003)

Hey roguephp,

How do I delete the other one? It is hidden. I know it is called MySQL so I cannot create another one with the same name. Does it have to be called MySQL?

Shouldn't I delete "Other..." first, then create a new user?

ListerMint


----------



## byronfunk (Jan 29, 2003)

OK. Having issues...

Did the whole php setup from www.entropy.ch/. I'm getting the following message:

httpd not running, trying to start
Syntax error on line 368 of /etc/httpd/httpd.conf:
Cannot add module via name 'mod_php4.c': not in list of loaded modules
/usr/sbin/apachectl graceful: httpd could not be started


What am I doing wrong? I'm using OS X 10.2.3 on an B&W G3 with 768 RAM. And, I'm a newbie.


----------



## roguephp (Jan 29, 2003)

Use the NetInfo Manager...  take a look at this site for some good info:

http://www.phpmac.com/articles/view.php?id=41

If you go to the homepage of that same site, there is a new how-to on getting MySQL and PHP running for the total newbie and there are other how-to articles if you browse them that are a bit more hands on.



> _Originally posted by ListerMint _
> *Hey roguephp,
> 
> How do I delete the other one? It is hidden. I know it is called MySQL so I cannot create another one with the same name. Does it have to be called MySQL?
> ...


----------



## ListerMint (Jan 29, 2003)

Roguephp,

Thank You! I will check it out. I needed something for a newbie.

ListerMint


----------



## wiz (Jan 29, 2003)

> _Originally posted by byronfunk _
> *OK. Having issues...
> 
> Did the whole php setup from www.entropy.ch/. I'm getting the following message:
> ...




well just make sure you have this line in the  /etc/httpd/httpd.conf file:
LoadModule php4_module        libexec/httpd/libphp4.so

it is located somewhere under the sub heading:
Dynamic Shared Object (DSO) Support


----------



## ListerMint (Jan 29, 2003)

roguephp.



> How do I delete the other one? It is hidden. I know it is called MySQL so I cannot create another one with the same name. Does it have to be called MySQL?
> 
> Shouldn't I delete "Other..." first, then create a new user?
> 
> ListerMint





> Use the NetInfo Manager... take a look at this site for some good info:
> 
> http://www.phpmac.com/articles/view.php?id=41



I tried it step by step exactly as instructed. I still have the hidden user account, mysql, that I can't access. Now I can't find the one I just created. This is becoming a nightmare! 

Any other ideas?

ListerMint


----------



## Quicksilver (Feb 8, 2003)

How and where can i tell its running? and if i restart dose it still run? i didnt entirely understand the "mysql test" part  it just said:

[Quicksilver:/usr/local/mysql] quicksilver% Starting mysqld daemon with databases from /usr/local/mysql/data

then i typed "mysql test"

and i got this:

mysql: Command not found.

yeah i know im still learning UNIX etc but doeas that look like it installed? what do i do next?

Cheers..


----------



## yoshi (Feb 12, 2003)

Okay guys, I have updated this thread and more, except I moved it here:
http://www.machowto.com/viewtopic.php?p=5#5

Please take all questions regarding this howto there. Think of the topic here as closed.

Cheers

Yoshi


----------



## jcady (Mar 27, 2003)

I did a cut n paste following of php setup, but something went whacked.  Anyway, the result is that I think I messed up my Apache server. 

For instance, Terminal tells me:

"/usr/sbin/httpd can't open library: /usr/lib/libiodbc.2.1.6.dylib  (No such file or directory, errno = 2)"

Figuring that I really messed things up, should I try to reinstall the server? Any favorite starting points?

Joe


----------



## LogicMan (Mar 27, 2003)

cool.  i got php to work. but where can i find the php.ini or config file?


----------



## roguephp (Mar 27, 2003)

> _Originally posted by LogicMan _
> *cool.  i got php to work. but where can i find the php.ini or config file? *



Depending on which insallation you did, one may not have been created. I know I had to make my own. Do a search on google for php.ini and you will find instructions.


----------



## TRITON (Apr 15, 2003)

ok i am a linux user, used to run linux mandrake 7.2 with my web site on it, i was useing phpweblog.org, and now i am working on setting it up on my PB500
i installed mysql, mafe the user, followed the steps at the start of the thread, and i cant do the test, also, if i open index.php, i get the text,, HELP,, lol


----------



## mkwan (Apr 25, 2003)

I recently installed mysql 4.0.12 on my Power Mac G4 running Mac OS X Server 10.2.5.   I believe that mysql version 3.23.51( ? ) is still installed(came with the OS). My questions are:

1) How do I know if the older version of mysql is still on the computer?

2)if it still is on the computer, how do I take it out without touching mysql 4.0.12?

thanks


----------



## wiz (Apr 27, 2003)

mkwan did u do an upgrade install? or a full install?


----------



## Shyos (May 29, 2003)

Hi, I think I've got a problem.....

After trying several times t install MySQL I found that I've been istalling different version.

This is what the terminal is showing me:

include
lib
mysql
mysql-debug-4.0.13-apple-darwin6.4-powerpc
mysql-debug-4.1.0-alpha-apple-darwin6.4-powerpc
mysql-standard-4.0.13-apple-darwin6.4-powerpc

Another thing is when I type: 
sudo ./bin/safe_mysqld --user=mysql &

I get the message:
Starting mysqld daemon with databases from /usr/local/mysql/data
030529 21:52:27  mysqld ended


Could one of you please help me out here... Ihave installed Mac os x 10.2.6

Thanks,

Shyos


----------



## delsoljb32 (Mar 16, 2004)

Here's an interesting one, when i go to "gunzip libphp4.so.gz" after the download, it tells me that it is not in "gzip format" ? ever heard of this?

-J-


----------



## johnd0e (Mar 17, 2004)

You might want to take a look here:

http://developer.apple.com/internet/opensource/php.html
or here (easier way)
http://www.entropy.ch/software/macosx/php/

Hope it helps a bit


----------



## osxmatrix (Apr 1, 2004)

Take a look:

http://scirocco.altervista.org 

You can find some usefull information about "php" and "MySQL" in Panther


----------



## monktus (May 2, 2004)

I installed PHP again recently with the centropy installer but after a while it just stops working. This happened to me a while ago but I thought I'd give it another go since I had the latest version of Panther with the newest centropy install. As far as I remember, PHP just stopped working, I'm not sure there was even a restart in between.

It's a bit much to ask, "Why isn't my PHP not working?!" but can anyone help me with troubleshooting? For example, how can you check if Apache is loading the module and what the error messages mean, if there are any. I've already tried reinstalling the centropy package but no dice.

Thanks,
Craig


----------



## nerv82 (May 3, 2004)

Panther comes allready with php4 you just have to open the terminal and type => $cd /etc/httpd/
here is were you configure your Apache

Second step is to check if you uncomment the module
$cat httpd.conf | grep php4
#LoadModule php4_module        libexec/httpd/libphp4.so
AddModule mod_php4.c
<IfModule mod_php4.c>

if it's like the above with the # you should delete the # 

open the system preferences and restart apache in the sharing tab or
do
$sudo apachectl restart


----------



## owaters (Jun 15, 2004)

Hi guys,

I think I have completely screwed up the installation of MySQL. I used the OSX binary package from the mysql.com website and followed their rather lengthly and to me complicated instructions which sent me from one page to another and eventually completely losing track of where I was in the installation process. I am now basically getting errors left, right and center!

I don't understand why they can't have a page that says, installing on Mac OSX in simple terms! Half of those pages bang on about installing on Mac OSX Server.

Anyahoo, I think I am in need of a complete reinstallation of mysql. What is the safest and easiers way of doing this? I am running OSX version 10.3.4.

Thanks


----------



## owaters (Jun 15, 2004)

Does anyone know the answer to this?

I think there is a conspiracy going on........are people not allowed to uninstall MySQL? I have looked over the internet all day trying to find an answer but there is none! I have posted this message on forums all over the place and no replies what so ever....I thought someone would know....


----------



## pds (Jun 15, 2004)

You seem desperate, so any advice may be helpful. I "accidentally" trashed my original install of mysql trying to get it going. I had installed the entropy version. 

I had just erased everything in the directories that mysql was sitting in using a sudo rm command (usr/bin/local/mysql IIRC). 

I installed the serverlogistics version. I think it was installed in a different place, but fixed/created all the links, aliases, symbolic whatevers and whatnot to make it work correctly. I also installed their PHP, but not Apache, since it's 2.x. I also installed CocoaMySQL. 

Everything works like a charm and I haven' t had any trouble at all since then. I use it daily and haven't needed to go to terminal for anything related to mysql.


****
Installed on an iBook 800


----------



## owaters (Jun 16, 2004)

Thanks. I ended up using the script from entropy.ch to remove MySQL. I then followed his installation instructions and installed his PHP module as well. Working great.

I took your advice with CocoaMySQL, great piece of freeware! Thanks for that


----------



## nerv82 (Jun 17, 2004)

I use fink to install mysql.
fink is very usefull for that type of things. If i want to install mysql i just need to open terminal then 
user%fink install mysql 

if i want to remove it i just
user%fink remove mysql

downloaded from 
http://fink.sourceforge.net


----------



## bossa nova (Jan 2, 2005)

I am looking at getting started with MySQL. I note there are some i.d.'s when I get info on my files that have an identity "mysql" which leads me to believe that it's already installed but when I search under /usr/local/ I don't see mysql listed. Is it necessary to install MySQL under Panther?

thanks!
Jon


----------

