[HOWTO] - Setup PHP & MySQL

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

http:www.weboddities.com

Does apache and mysql crash at all? ;)
At least, here's an extension to make mysql automatically start on system startup :)
 
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?
 
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
 
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
 
Status
Not open for further replies.
Back
Top