PHP GD MYSQL Apache

   (8)
      
日本語/Japanese
Mon 2005/10/10 05:56
So I read most of the "penultimate-tutorial-to-installing-php-mysql-apache-gd-on-tiger" and you know what? They just don't work - most of those tutorials being about as useful as having a shovel of bat shite shoved up your left nostril. But many of them did provide pointers and after looking at a zillion of these tutorials, I managed to do the PHP with GD lirary, MYSQL and Apache on Tiger thang.

This may end up being one of those lousy tutorials but it works for me every time I need to set up clean on OSX Tiger - give it a whirl and if it does not work then be angry!

Before you start
Install the Xcode tools from the installation DVD that came with Tiger - Don't install the documentation if you don't need it and save yourself 733MB of disk space.
Installing the Xcode tools will install the compiler that you need to compile stuff - otherwise you will just end up with some "compiler not installed" or some similar annoying error message.

Installing MYSQL
Get "mysql-standard-4.1.11-apple-darwin7.8.0-powerpc.dmg" from mysql.com - mount and click on installer package. Create a file called ".my.cnf" (Don't forget the dot in front of the file name) with the following 3 lines and stick it in your /etc/ directory.

[mysqld]
datadir=/Volumes/store/data/websites/mysql_data
port=10101

Note that the "datadir" should point to your mysql data directory if you dont want it the default location. I wanted my mysql directory on a seperate volume which is why I do this - if you are just after a plain installation, you do not have to do any of the above.
At this point, you should really have some tool like InVisibles to show all invisible files on your hard drive (those beginning with a dot). When you do this however, many of your other file icons will look kind of faded out - I have no idea why this happens. You also get that annoying ".DS_Store" file everywhere - its the file which contains information on the folder that you are looking at.

Installing Apache
Apache actually comes with OSX Tiger - all you have to do ia a few wee tweaks
Under " /private/etc/httpd/ " you will find the "httpd.conf" file. Open it and uncomment the following 2 lines by removing the hash before them. Doing this allows you to use PHP by loading the PHP modules.

LoadModule php4_module  libexec/httpd/libphp4.so
AddModule mod_php4.c

About half way down the httpd.conf file, you will see the following comment...

# This controls which options the .htaccess files in directories can
# override. Can also be "All", or any combination of "Options", "FileInfo",
# "AuthConfig", and "Limit"
#
AllowOverride None

Change where it says "AllowOverride None" to "AllowOverride All". This allows you to do stuff such as freely use mod_rewite - I put all my mod_rewrite comments in the .htaccess file. mod_rewrite is an Apache module which allows you to do a ton of things include feed the cat and rewrite URLS to be search engine friendly - more on how to do this in a future post. Don't worry about this if you don't know what I am babbling on about.

If you are developing a zillion sites on your machine - you should add virtual directories in httpd.conf. Near the bottom-ish of the httpd.conf file, you will see the following.

#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for requests without a known
# server name.
#

Just below the above comment, you can add lines like the following...
Listen 1116
<VirtualHost localhost:1116>
DocumentRoot "/Volumes/store/guncannon/Sync/websites/somesite"
</VirtualHost>

Listen 1117
<VirtualHost localhost:1117>
DocumentRoot "/Volumes/store/guncannon/Sync/websites/dannychoo/"
</VirtualHost>

What this means is that I can have a site called "dannychoo" located at "/Volumes/store/guncannon/Sync/websites/dannychoo/" - I would access this site from my browser using "http://localhost:1117"
I can have another site called "somesite" located at "/Volumes/store/guncannon/Sync/websites/somesite" accessable on port 1116.
You can have as many sites set up this way in your httpd.conf file - just remember to restart apache after you make changes.
Two notes:
1. Restart apache using "sudo apachectl restart" - you have to make an alias first though (see bottom of this post)
2. Use a text editor like TextWangler to edit your httpd.conf file because other text editors may give you a crummy "do not have permission to save file."

Installing GD graphic Libraries
If you are going to manipulate images in PHP you need to install the GD libraries - namely the libjpeg and libpng source distributions.
Fire up Terminal located in your Utilities directory and do the following - "guncannon$" is my prompt - yours will probably be yourusername$

guncannon$ cd ~/Desktop
guncannon$ mkdir gdbuild
guncannon$ cd gdbuild
guncannon$ curl -O ftp://ftp.uu.net/graphics/jpeg/jpegsrc.v6b.tar.gz
guncannon$ curl -O http://heanet.dl.sourceforge.net/sourceforge/png-mng/libpng-1.2.5.tar.gz
guncannon$ gnutar xzf jpegsrc.v6b.tar.gz
guncannon$ gnutar xzf libpng-1.2.5.tar.gz

New we need to build libjpeg - get back to the terminal and do the following...

guncannon$ cd jpeg-6b
guncannon$ sudo mkdir -p /usr/local/include
guncannon$ sudo mkdir -p /usr/local/bin
guncannon$ sudo mkdir -p /usr/local/man
guncannon$ sudo mkdir -p /usr/local/lib
guncannon$ sudo mkdir /usr/local/man/man1

The above commands create directories that may be missing (for some reason) from your OSX Tiger. If for example you already have a "/usr/local/bin" directory - you Don't need to create it again.
Now that these directories are ready, time to lock, load, wash your armpits then build and install...

guncannon$ ./configure
guncannon$ sudo make install
guncannon$ sudo make install-lib
guncannon$ sudo ranlib /usr/local/lib/libjpeg.a
guncannon$ cd ..

Now that libjpeg is installed, we need to install libpng which is ever so slightly a pain in the left earlobe. Do the following at the terminal.

guncannon$ cd libpng-1.2.5
guncannon$ cp scripts/makefile.macosx ./Makefile

Now open the file "Makefile" that you just copied to your libpng-1.2.5 directory in TextWrangler.
Look for the following comments...

# Where the zlib library and include files are located
#ZLIBLIB=/usr/local/lib
#ZLIBINC=/usr/local/include
ZLIBLIB=../zlib
ZLIBINC=../zlib

Change the above so that it looks like the below...

# Where the zlib library and include files are located
ZLIBLIB=/usr/local/lib
ZLIBINC=/usr/local/include
#ZLIBLIB=../zlib
#ZLIBINC=../zlib

Now search for the following

LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz -current_version $(PNGVER)

and change it to...

LDFLAGS=-L. -L$(ZLIBLIB) -lpng -lz

Save the changes and then go and watch Gundam Seed Destiny. When you get back, go to the terminal again and unleash the following...

guncannon$ make
guncannon$ sudo make install
guncannon$ sudo ranlib /usr/local/lib/libpng.a
guncannon$ cd ..

Now everything up until now should have gone smoothly - if not then stick in a comment to this post and tell me how angry you are.

Building and Installing PHP
We are nearly there - in no time you will be making a ton of affiliate sites to pay for your expensive hobbies (like mountain climbing with a toilet strapped to your back - expensive stuff).
Time to fire up that terminal again and do the following...

guncannon$ cd ~/Desktop
guncannon$ mkdir phpbuild
guncannon$ cd phpbuild
guncannon$ curl -O http://museum.php.net/php4/php-4.3.6.tar.gz
guncannon$ gnutar -xzf php-4.3.6.tar.gz
guncannon$ cd php-4.3.6

The next step is to configure, build and install PHP. Enter the following

guncannon$./configure --with-xml --with-zlib --with-gd --with-jpeg-dir=/usr/local --with-png-dir=/usr/local --with-apxs=/usr/sbin/apxs
guncannon$ make
guncannon$ sudo make install

The above takes a bit of time to run after each command so go and make yourself a cup of tomato soup with croutons - everything should be ready when you get back.
If you are a bad programmer like me, you will want to erm turn global variables on (gulp) - You will need to configure your php.ini file - do the following at the terminal...

guncannon$ cp php.ini.default /usr/local/lib/php.ini

This makes a copy of the php.ini-dist file and saves it as php.ini in your /usr/local/lib/ folder. Open the file in TextWrangler and change the line where "register_globals = Off" to "register_globals = On"
And after you have done that, make sure you spend time learning how to program without using global variables - doh!

Other stuff to do
Create some aliases to make your life just that much easier.

alias mysqladmin=/usr/local/mysql/bin/mysqladmin
alias mysqld_safe=/usr/local/mysql/bin/mysqld_safe
alias apachectl=/usr/sbin/apachectl

Which now means you can....

guncannon$ sudo apachectl start
guncannon$ sudo apachectl stop
guncannon$ sudo apachectl restart
guncannon$ sudo mysqld_safe (starts mysql)
guncannon$ mysqladmin -u root shutdown (stop mysql)

I hope this works for you as it worked for me on a clean installation of Tiger. If it does not work then you are permitted to get all wound up as I did reading other bods tutorials on the same subject.
Join Danny Choo
Up until now I used Mapion for when I needed to look up directions in Japan. Google has re...(more)
Sun 07/24 16:03 comments (2)
If you are a heavy internet user, you may have already come across the "All Your Bas...(more)
Sun 07/10 09:32 comments (3)
I have been using CSS as far back as I can remember but it seems like I have not been usin...(more)
Sun 07/10 09:19 comments (1)
I sought to try out Skype to see what the fuss was about and was very curious about the ...(more)
Sun 07/10 09:18 comments (2)
Brock in Seattle WA
Works for me - great stuff.
What about the permissions on MYSQL?
(ID #33241) Posted on 2007/01/02 02:11
Bob Terry in London
Just what I was looking for - thanks :-)
(ID #33242) Posted on 2007/01/02 02:11
Cronus in 群馬
これの日本語版が欲しい。
お願いします。
(ID #33251) Posted on 2007/01/02 02:11
Danny Choo in Meguro Tokyo
BTW, when installing XCode tools, choose a custom install and leave out documentation to save yourself 700MBs of disk space.
(ID #33297) Posted on 2007/01/02 02:11
Mel Beckman in Santa Barbara, CA
Bless you, Danny! This was precisely what I needed to get ACID up and running for Snort!
(ID #33321) Posted on 2007/01/02 02:11
Emil Babin in Denmark
Hi Danny Choo
You probably get a lot of this, but I'll give it shot anyway:

I followed your tutorial on installing the gd lib on OSX Tiger and everything went fine up untill the point where you build and install libraries:

guncannon$ ./configure
guncannon$ sudo make install
guncannon$ sudo make install-lib
guncannon$ sudo ranlib /usr/local/lib/libjpeg.a
guncannon$ cd ..

When I hit "emil$ ./configure", this is what I get in return:

emil-babins-imac-g5:~/Desktop/gdbuild/jpeg-6b emil$ ./configure
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH

... what gives?
If you have any idea, it will be very much appreciated as I don't have a clue of what I'm doing...

thx Emil
(ID #33371) Posted on 2007/01/02 02:11
Danny Choo
Hi Emil,

Yep I saw these errors when i first started off - you are getting these messages because you do not have a compiler installed - installing all of the xcode tools from the DVD that came with your mac should fix these problems.

Let me know how it goes.
(ID #33372) Posted on 2007/01/02 02:11
Brock in Seattle WA
Works for me - great stuff.
What about the permissions on MYSQL?
(ID #75245) Posted on 1999/11/30 15:00
Bob Terry in London
Just what I was looking for - thanks :-)
(ID #75246) Posted on 1999/11/30 15:00
Cronus in 群馬
これの日本語版が欲しい。
お願いします。
(ID #75255) Posted on 1999/11/30 15:00
Danny Choo in Meguro Tokyo
BTW, when installing XCode tools, choose a custom install and leave out documentation to save yourself 700MBs of disk space.
(ID #75301) Posted on 1999/11/30 15:00
Mel Beckman in Santa Barbara, CA
Bless you, Danny! This was precisely what I needed to get ACID up and running for Snort!
(ID #75325) Posted on 1999/11/30 15:00
Emil Babin in Denmark
Hi Danny Choo
You probably get a lot of this, but I'll give it shot anyway:

I followed your tutorial on installing the gd lib on OSX Tiger and everything went fine up untill the point where you build and install libraries:

guncannon$ ./configure
guncannon$ sudo make install
guncannon$ sudo make install-lib
guncannon$ sudo ranlib /usr/local/lib/libjpeg.a
guncannon$ cd ..

When I hit "emil$ ./configure", this is what I get in return:

emil-babins-imac-g5:~/Desktop/gdbuild/jpeg-6b emil$ ./configure
checking for gcc... no
checking for cc... no
configure: error: no acceptable cc found in $PATH

... what gives?
If you have any idea, it will be very much appreciated as I don't have a clue of what I'm doing...

thx Emil
(ID #75375) Posted on 1999/11/30 15:00
Danny Choo
Hi Emil,

Yep I saw these errors when i first started off - you are getting these messages because you do not have a compiler installed - installing all of the xcode tools from the DVD that came with your mac should fix these problems.

Let me know how it goes.
(ID #75376) Posted on 1999/11/30 15:00
UPDATE!!!! Sorry! There is actually 43 figures as pointed out by Meimi132! Sorry for th...(more)
Sat 11/22 19:30 comments (53)
Me has been invited by comrades at Google to attend YouTube Live Tokyo being held tomorrow...(more)
Sat 11/22 11:42 comments (38)
This is one of the slides that I had in my presentation at Animax. The purpose of the slid...(more)
Sat 11/22 05:15 comments (71)
Internet idol Mimi shows us her legs - wallpaper version at her burogu. Mmmmmmmm. Akih...(more)
Fri 11/21 22:24 comments (120)
Subscribe
Subscribe to RSS or get dannychoo.com delivered to your inbox.
dannychoo.com in your inbox
AddThis Feed Button
Recommended
(refresh)
View advertising info
and site stats here.
Full list of partners in this slot are listed below.