image
image

Go Back   macosx.com > Mac Help Forums > HOWTO & FAQs

Closed Thread
 
Thread Tools
  #1  
Old January 12th, 2002, 12:17 PM
Official Green Dinosaur
 
Join Date: Dec 2001
Location: Longwood, FL
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
yoshi is on a distinguished road
[HOW-TO] - Setup PHP & MySQL

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
__________________
12" PowerBook G4: 1.5Ghz, 768MB/RAM, 60GB HDD, Combo Drive, 64MB GeforceFX 2 Go, Airport Extreme + BT

Quicksilver G4: 1.53Ghz G4, 1GB/RAM, 160GB HDD, SuperDrive, Radeon 9800 Pro (128MB), Airport Card, AppleVision 850AV, Applevision 1710AV

PowerMac G3 Server: 400Mhz G3, 512MB/RAM, Dual 40GB RAID 0, Dual 80GB RAID 0, 40GB Boot Drive, DVD/CD Optical Drive, Ultra2 SCSI Card hooked to a DDS-4 Tape Drive, No Monitor

PowerMac 8500: Vintage

Last edited by yoshi; March 10th, 2002 at 04:54 PM.
  #2  
Old January 12th, 2002, 12:23 PM
kilowatt's Avatar
mach-o mach-o man
 
Join Date: Mar 2001
Location: irc.lfnet.net #kilonet
Posts: 980
Thanks: 0
Thanked 0 Times in 0 Posts
kilowatt is on a distinguished road
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!
  #3  
Old January 13th, 2002, 01:30 AM
MacWrite.com
 
Join Date: Sep 2000
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Mac Write is on a distinguished road
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.
  #4  
Old January 13th, 2002, 01:41 AM
Official Green Dinosaur
 
Join Date: Dec 2001
Location: Longwood, FL
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
yoshi is on a distinguished road
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
__________________
12" PowerBook G4: 1.5Ghz, 768MB/RAM, 60GB HDD, Combo Drive, 64MB GeforceFX 2 Go, Airport Extreme + BT

Quicksilver G4: 1.53Ghz G4, 1GB/RAM, 160GB HDD, SuperDrive, Radeon 9800 Pro (128MB), Airport Card, AppleVision 850AV, Applevision 1710AV

PowerMac G3 Server: 400Mhz G3, 512MB/RAM, Dual 40GB RAID 0, Dual 80GB RAID 0, 40GB Boot Drive, DVD/CD Optical Drive, Ultra2 SCSI Card hooked to a DDS-4 Tape Drive, No Monitor

PowerMac 8500: Vintage
  #5  
Old January 13th, 2002, 01:57 AM
MacWrite.com
 
Join Date: Sep 2000
Posts: 93
Thanks: 0
Thanked 0 Times in 0 Posts
Mac Write is on a distinguished road
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.

Code:
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

Code:
DirectoryIndex index.html
Then restart Apache and boom PHP will work.

Make sure you have a 10.1 Clean install.
  #6  
Old January 13th, 2002, 02:20 AM
ScottW's Avatar
Founder
 
Join Date: Sep 2000
Location: Overland Park, KS
Posts: 3,175
Thanks: 0
Thanked 6 Times in 3 Posts
ScottW is on a distinguished road
Very NICE. It all worked. Great!
  #7  
Old January 13th, 2002, 07:59 AM
Official Green Dinosaur
 
Join Date: Dec 2001
Location: Longwood, FL
Posts: 213
Thanks: 0
Thanked 0 Times in 0 Posts
yoshi is on a distinguished road
Quote:
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.

Code:
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

Code:
DirectoryIndex index.html
Then restart Apache and boom PHP will work.

Make sure you have a 10.1 Clean install.
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
__________________
12" PowerBook G4: 1.5Ghz, 768MB/RAM, 60GB HDD, Combo Drive, 64MB GeforceFX 2 Go, Airport Extreme + BT

Quicksilver G4: 1.53Ghz G4, 1GB/RAM, 160GB HDD, SuperDrive, Radeon 9800 Pro (128MB), Airport Card, AppleVision 850AV, Applevision 1710AV

PowerMac G3 Server: 400Mhz G3, 512MB/RAM, Dual 40GB RAID 0, Dual 80GB RAID 0, 40GB Boot Drive, DVD/CD Optical Drive, Ultra2 SCSI Card hooked to a DDS-4 Tape Drive, No Monitor

PowerMac 8500: Vintage
  #8  
Old February 2nd, 2002, 12:21 PM
Registered User
 
Join Date: Feb 2002
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
lcwid is on a distinguished road
Trouble with MySQL

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
Closed Thread

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
PHP / MySQL Nynaeve Mac OS X System & Mac Software 6 December 21st, 2005 04:59 PM
PHP & mySQL revisited: Help needed MacLuv Design & Media 4 December 2nd, 2002 10:41 AM
PHP + MySQL running but not ZLIB lashampoo Mac OS X System & Mac Software 2 October 8th, 2001 05:58 PM


All times are GMT -5. The time now is 11:52 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.