PHP, Apache 2, MySQL on Leopard

bbarnhart

macrumors 6502a
Original poster
Jan 16, 2002
824
1
I'm running PHP, Apache2 and MySQL on Tiger doing some personal web development work and was wondering if there's any changes coming along with Leopard. If I install Leopard, will I have to adjust my settings for web development or should they continue to work?
 

Nugget

macrumors 68000
Nov 24, 2002
1,855
863
Houston Texas USA
Fundamentally there's no change in how that all works in Leopard. If you're using the Apache that ships with OS X, though, be aware that there's been a pretty dramatic version jump. Apache is version 2.2.6 in Leopard (a huge leap from 1.3.33 in Tiger). Similarly, php in Leopard is php5, not php4 like in Tiger.

It's unlikely you'll run into any serious problems as a result of these upgrades, but it's quite possible that you will have a few hiccups.
 

Kebabselector

macrumors 68030
May 25, 2007
2,819
1,135
Birmingham, UK
Noticed that! none of my sites (which are hosted on my Mac) no longer work.

It seems to be an issue with the virtual host. It was in the httpd.conf file (in the httpd folder). Not too sure if it should be in the apache2 folder now.

I'll attempt to have a look in the morning, unless someone else knows. Help!!
 

UltraNurd

macrumors newbie
Aug 3, 2003
16
0
Watertown, MA
I copied and pasted my VirtualHost directive from my old /etc/httpd/httpd.conf to my new /etc/apache2/users/myname.conf, which is automatically included by /etc/apache2/httpd.conf by default; that "just worked", in terms of getting my main domain name to point to my ~/Sites/ directory, although I still have to futz with SSL and MySQL. I'll get back to you.
 

UltraNurd

macrumors newbie
Aug 3, 2003
16
0
Watertown, MA
Got SSL working; I was mostly able to just copy in the directives from my SSL <VirtualHost> that was in /etc/httpd/httpd.conf into /etc/apache2/extra/httpd-ssl.conf; I did have to uncomment one line in /etc/apache2/httpd.conf to include the above SSL configuration, and I had to edit the paths to my server certificates and copy them into /etc/apache2/ssl.key/.

I am getting this warning (IP elided), but it seems to be working, so...

Code:
sudo apachectl configtest
[Fri Oct 26 23:55:32 2007] [warn] NameVirtualHost xxx.yyy.zzz.qqq:443 has no VirtualHosts
Syntax OK
 

UltraNurd

macrumors newbie
Aug 3, 2003
16
0
Watertown, MA
MySQL doesn't have an OS X Installer package for 10.5 yet, so I grabbed the source tarball and modified the configure line they specify on their OS X platform notes to combine with Apple's instructions, followed my a make and a sudo make install.

Code:
CC=gcc CFLAGS="-O3 -fno-omit-frame-pointer" CXX=gcc CXXFLAGS="-O3 -fno-omit-frame-pointer -felide-constructors -fno-exceptions -fno-rtti" ./configure --prefix=/usr/local/mysql --with-extra-charsets=complex --enable-thread-safe-client --enable-local-infile --disable-shared --with-unix-socket-path=/usr/local/mysql/run/mysql_socket --with-mysqld-user=mysql
Note that the mysql user and group appear as _mysql in directory listings... not sure why that is.

I continued with Apple's instructions to set permissions properly.

I then copied my old data directory into place, started mysqld, and then I had to point phpmyadmin's config.inc.php to use the socket specified on the command line above.

You don't get the nice pref pane server starter, though, so I'm not sure what happens when I restart; I doubt it's using launchd properly. I might try adding an entry with Lignon, or editing /System/Library/LaunchDaemons/.
 

davermont

macrumors newbie
Oct 27, 2007
1
0
Noticed that! none of my sites (which are hosted on my Mac) no longer work.

It seems to be an issue with the virtual host. It was in the httpd.conf file (in the httpd folder). Not too sure if it should be in the apache2 folder now.

I'll attempt to have a look in the morning, unless someone else knows. Help!!
I had been using virtualhosts under 10.4, so cloned my /etc/httpd/virtualhosts/ folder at /etc/apache2/ and copied the lines to the end of the /etc/apache2/httpd.conf file:
NameVirtualHost 127.0.0.1
Include /private/etc/apache2/virtualhosts/*

Under Leopard I also needed to add entries to the /etc/hosts file as well:
127.0.0.1 mysite
127.0.0.1 anothersite

At that point all my virtual hosts started working:
http://mysite/
 

colocolo

macrumors 6502
Jan 17, 2002
443
4
Santiago, Chile
If you currently use PHP4 and use short tags ("<?" instead of "<?php"), keep in mind you will either have to update all your code to use the long tag or go to your php.ini file and change set the useshorttags (or something to that extent) to On.
 

dave261

macrumors newbie
Oct 29, 2007
1
0
PHP, Apache 2, Leopard

I upgraded my MacBookPro to Leopard with no issues. I then downloaded and installed xcode 3.0. I then followed the instructions Building and Installing Apache 2.2.4 and PHP 5.1.4 on Max OS X 10.4.6 (http://www.phpmac.com/articles.php?view=252). Apache appears to be working correctly however php scripts will not execute. When I try, the source is displayed. Any suggestions anyone?
 

colocolo

macrumors 6502
Jan 17, 2002
443
4
Santiago, Chile
I upgraded my MacBookPro to Leopard with no issues. I then downloaded and installed xcode 3.0. I then followed the instructions Building and Installing Apache 2.2.4 and PHP 5.1.4 on Max OS X 10.4.6 (http://www.phpmac.com/articles.php?view=252). Apache appears to be working correctly however php scripts will not execute. When I try, the source is displayed. Any suggestions anyone?
Go to the Apache conf file (Apache 1.1 in OS X is /etc/https/httpd.conf), and uncomment the two lines referring to php, the "load" one and the "mod" one.
 

TheReef

macrumors 68000
Sep 30, 2007
1,888
166
NSW, Australia.
Is there a way to open php files in Safari directly from the Finder without having to navigate through the web server (running on my Mac)? The files are stored in library>webserver
 

elppa

macrumors 68040
Nov 26, 2003
3,230
108
Is there a way to open php files in Safari directly from the Finder without having to navigate through the web server (running on my Mac)? The files are stored in library>webserver
If I understand correctly, you just need to type in localhost or 127.0.0.1?

This points to /Library/Webserver/Documents/
 

bbarnhart

macrumors 6502a
Original poster
Jan 16, 2002
824
1
Is there a way to open php files in Safari directly from the Finder without having to navigate through the web server (running on my Mac)? The files are stored in library>webserver
Safari can't render a php file. In your case, Apache needs to recognizes it's a php file and help it get rendered.
 

TheReef

macrumors 68000
Sep 30, 2007
1,888
166
NSW, Australia.
Yes, I can access it by typing localhost, but for quickly previewing a file is what I'm after :)

In Panther, Safari would render the page without the PHP (so I am missing portions of the page that have been 'included') but it still gave me a glimpse of the main content on the page. Is there any way to change Safari to not display the source?
 

bbarnhart

macrumors 6502a
Original poster
Jan 16, 2002
824
1
Yes, I can access it by typing localhost, but for quickly previewing a file is what I'm after :)

In Panther, Safari would render the page without the PHP (so I am missing portions of the page that have been 'included') but it still gave me a glimpse of the main content on the page. Is there any way to change Safari to not display the source?
I didn't know it did that in Panther.
 

elppa

macrumors 68040
Nov 26, 2003
3,230
108
Yes, I can access it by typing localhost, but for quickly previewing a file is what I'm after :)

In Panther, Safari would render the page without the PHP (so I am missing portions of the page that have been 'included') but it still gave me a glimpse of the main content on the page. Is there any way to change Safari to not display the source?
If you grab TextMate (free Trial) and open it in there and then chose Show Web Preview (Window > Show Web Preview) then you can see how the rest of the page will look (roughly) without the php elements.
 

TheReef

macrumors 68000
Sep 30, 2007
1,888
166
NSW, Australia.
I didn't know it did that in Panther.
Oh sorry, I think it was Tiger actually.

If you grab TextMate (free Trial) and open it in there and then chose Show Web Preview (Window > Show Web Preview) then you can see how the rest of the page will look (roughly) without the php elements.
I found that KompoZer does exactly that - opens php files on double click and displays them properly minus the php (I chose to always open php files with Kompozer from the get info window.) The good news is that it's free :D
 

bbarnhart

macrumors 6502a
Original poster
Jan 16, 2002
824
1
I tried it in Tiger, but it didn't work. Maybe I didn't do it right, but I'm kinda thinking that it needs to go through Apache. Maybe there's some kinda of developer plug in that I don't have.
 

benassis

macrumors newbie
Nov 13, 2007
2
0
Got SSL working; I was mostly able to just copy in the directives from my SSL <VirtualHost> that was in /etc/httpd/httpd.conf into /etc/apache2/extra/httpd-ssl.conf; I did have to uncomment one line in /etc/apache2/httpd.conf to include the above SSL configuration, and I had to edit the paths to my server certificates and copy them into /etc/apache2/ssl.key/.

I am getting this warning (IP elided), but it seems to be working, so...

Code:
sudo apachectl configtest
[Fri Oct 26 23:55:32 2007] [warn] NameVirtualHost xxx.yyy.zzz.qqq:443 has no VirtualHosts
Syntax OK
Hi UltraNurd,

I am also trying to install SSl on my machine since about a week without success.
I migrated from Tiger to Leopard (archive and install) on an Imac intel dual core. I succeeded installing php 5 and mysql, but SSL still resists.
Would you be so kind to post your httpd.conf file (containing your ssl config, as stated above) ? Of course, you should elide your personnal coordinates.
I could try to adapt it to my own configuration.
Thanks a lot
Regards
 

rezzz

macrumors newbie
Dec 3, 2007
2
0
I’ve done everything on here and more and I still have an issue. For some reason I have one VirtualHost that works just fine and the other I get 403 Forbidden. No matter what I do, it still is this way. Any ideas would be extremely helpful. Thanks in advance

rezzz
 

rezzz

macrumors newbie
Dec 3, 2007
2
0
multiple dots

Actually I just created a test virtual host and it works. The other VHs were existing sites that I moved into my vhosts directory.

The problem I'm thinking is that the one that's giving me issues is because there are PHP files with multiple dots in the name (i.e. - class.foo.php) -- I think that's what the issue is.

Anyone hear of this being an issue, and if so, is there a work around? I greatly appreciate the input, thanks.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.