[HOWTO] - Setup PHP & MySQL

Status
Not open for further replies.
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?
 
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

:eek: UNTIL YOU ENTER THAT ROOT USER HAS NO PASSWORD!!:eek:

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
 
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?
 
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.
 
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.
 
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
 
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
 
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,

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
 
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
 
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)
 
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
 
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
 
PHPMyAdmin rocks. It is by far the most useful little open source web app I have come across.
 
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.
 
i m looking for some help installing PHP.

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

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

i get this error:

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

can anyone offer any advice? thanks
 
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.
 
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!!:D )

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.:D
 
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.
 
Status
Not open for further replies.
Back
Top