PHP & MySQL supposed to be pre-installed with Snow Leopard
It's been five years since I've grappled with this, and was looking forward to having PHP 5.x and MySQL 5.1 on my new iMac w/Snow... but not so much.
I'd *really* like not to have to dL new versions... but start with what's here (and get back to work! on projects).
Apache is started (via "web sharing").
Followed online instructions for uncommenting
"LoadModule php5_module libexec/apache2/libphp5.so"
SAVED (with admin pw) [ double-checked: it took ]
copied "php.ini.default" to php.ini [ I see it readily in private/etc (since I've used TinkerTools to show hidden files ]
[ rebooted ]
HOWEVER: PHP is *still* not processing my localhost files [ Safari just *shows* the code rather than processing it. ]
On to MySQL:
All my google searches talk about how to deal with *new* DLs of MySQL. What about just *activating* what's already installed?
BUT: I notice that all the online discussions talk about installing MySQL in:
"usr/local" i.e., there should be a file "usr/local/mysql" after installation.
BUT: I don't even have a directory "local" within "usr" - just the usual suspects ( bin, lib, libexec, etc.)
[ though my previous system (Tiger) which *was running PHP/MySQL just fine had a *php5* directory inside a "local" directory within "usr" ]
Can anybody help me unleash what's supposed to be *already* installed?
I'm not much of a Terminal user, but I can navigate around within it.
Not sure about the php, but for Mysql i seem to recall I needed to install a pref pane for MySQL Server Status. Have you tried that?
Yes, I forgot to say, I did download from MySQL that "MySQL Server Status" preference pane.
After installation, I did check "Automatically start MySQL Server on Startup" in the pane, but (after restart) the pref pane came back with:
>>MySQL Server Status
>>The MySQL Database Server installation was not found.
>>Please make sure the /usr/local/mysql/bin/mysqladmin file is present.
>>The MySWL Server Instance is NOT RUNNING
[ Then there is a button "Start MySQL" -- but it is grayed out ]
Which reminds me... somebody with a little bit of Terminal experience:
Is there a way to do a *search* from with Terminal for *mysql* as an app?
Are you sure they are supposed to be pre-installed in SN ?
I know they are listed in the tech specs for SERVER snow leopard... but I see no mention of them in details of software that comes with the basis Snow Leopard.
MySQL is installed on Server, not regular OS X. PHP is installed. You also need a line in your httpd.conf as follows:
AddType application/x-httpd-php .php
That tells Apache to parse PHP files.
Then restart Apache (Web sharing -> Stop, Start).
-- You may already have a conf file /etc/apache2/other/php5.conf with that line in it. If so, make sure you have a line in the main httpd.conf:
That will include any other conf files into the main one. It's just sometimes easier to keep all the directives organized if you have several specialized files.
You may need more config changes but we don't know what you've already got there.
You can ls /usr/local/mysql/bin to see whether mysqladmin is there.
Why not build MySQL and PHP via Macports? This way you'll have a version in a predictable path that you can upgrade as needed.
Muchos thanks for tip, besson. Result from terminal:
ls: /usr/local/mysql/bin: No such file or directory
I may just need to do the build as you suggest. Working at installation level has always given me experience of, "nothing is as simple as it seems (or should be)" - so if the blessed stuff is already there, I'd rather not risk munging it all up.
@fizzy: Thanks. I'll try the *other* config files, something I'd not seen mentioned in web articles.
imac:~ RP$ ls /usr/
X11 bin libexec share
X11R6 lib sbin standalone
so there is *no* "local" inside /usr/ ... is that weird? or indicative that none of the likes of php/mysql was (pre)installed
[Whereas way back at 10.2 the system came with it installed.]
It's going to pretty pretty much impossible for us to figure out what you have installed where. I would go for a clean break with Macports. All Macports installed software is installed into a sandbox in /opt/local, so you'll know exactly where to find this software, and you'll be able to update it as you please. You'll also get the advantage of knowing that you have a secure version custom built for your CPU.
You'll have to live without the little pref pane, but last I checked Macports will install a launchd item for you for MySQL. You'll also have to give up on trying to get the Macports bits to interact with the Apple bits (e.g. turning on/off Apache via the Sharing pane). Apple's bits are usually quite old anyway, and may or may not have the PHP extensions and Apache modules you wish to use.
I appreciate the encouragement, besson.
It's feels like launching into a whole other frontier...
But from poking around a bit it sounds like the Macports has a strong community (even with Apple support) and should be worth the overhead of whatever learning curve there may be (e.g., life beyond the Sharing Pane).
:: slow yogic breathing ::
Well, I'm trying to keep breathing, however...
I have DLd latest Apple Dev Tools (700MB + ) and DL'd MacPorts 1.8.1 & installed.
I even successfully did "sudo port" in Terminal and entered interactive mode for MacPorts.
But, man! - does no one have step-by-step instructions?
My little brain finds the guide.macports.org filled with overwhelming, archane discussion.
So I'm in MacPorts in terminal.
I'd like to get a port of PHP 5.1 ; I *do* find it listed at:
The MacPorts Project -- Available Ports
but I've no clue whether something *here* is supposed to help me *find* and DL latest PHP 5.x? or whether I'm supposed to DL from php.net ?
...and when I click on the hotlink for php5, I am taken to:
/trunk/dports/lang/php5/Portfile – MacPorts
But that is the 300+ lines of a portfile.
What do I do with that? Something *before* DLing php5 from somewhere?
[Sorry: this is obviously *not* designed for a pathetic GUI-raised slob]
I hate to ask here for guide through steps... but... (is there somewhere just step-by-step for something as common as PHP? and then what about guide to how to add configurations that might not be in the php config described in the portfile (like mysqlite or graphics libs)?
A little guidance would be *so* sweet.
What I do is I skip the Apache and PHP that ships with the system, and get MAMP:
MAMP: Mac, Apache, MySQL, PHP
I then reconfigured the MAMP's Apache to listen on port 80 rather than the default 8080, and it all works perfectly without fussing around with ports or terminal.
Well, after the install, I just gutted it up and *guessed* (based on help from: Install Apache 2 and PHP 5 with MacPorts | 2 tablespoons ) to try in terminal:
sudo port install php5
...worked like a charm, installing apache2 *and* php5
[and used "sudo port install mysql5 to DL & build MySQL too ]
Also very helpful was to DL the GUI to MacPorts: Porticus.org - which confirms that Apache, PHP5, MySQL5 are all installed and activated.
They don't actually *function* yet, but... hey, it's time to stop for breakfast!
There *is* a learning curve, though the 2tbsp.com guide helped a bunch. If as besson suggests the MacPorts even makes it possible to keep this system UP-TO-DATE, it'll have been worth the learning curve.
sudo port selfupdate (updates Macports and its awareness of newer versions of ports that might be available)
sudo port install php5
sudo port upgrade php5
port installed (lists ports installed w. Macports)
some ports have install options called variants. TO list variants for a port:
port variants php5
the pluses indicate defaults (in this case apache2 is a default) to install php5 with the suhosin patch (which is a good idea):
sudo port install php5 +suhosin
You'll need the php5-mysql port which installs the MySQL PHP extension:
port search php5-mysql
see if this port is already installed:
port installed php5-mysql
if it isn't:
sudo port install php5-mysql
This is great if all you want is a just-add-water solution, and this source will keep their installer up-to-date, you are confident that it isn't compromised, and you are happy with their decisions on what pieces/configure options to install. What happens if they don't include the suhosin patch and you want that?
Hardened-PHP Project - PHP Security - Feature List
This will, for instance, allow you to prevent creating your infinite loops in your programs that kill the server.
It gave me PHP 5.3.1, with (according to phpinfo() ) MySQL 5.0.5
But I'm having trouble getting MySQL started, with PHPMyAdmin saying,
"#2002 - The server is not responding (or the local MySQL server's socket is not correctly configured) "
I've correct the socket address in php.ini ... to no avail, after a restart.
What would be *most* cool would be if I had a Terminal command to determine where is MySQL (and is it running). The MySQL 5.0.5 *must* be in there, right?
Got any suggestions?
PS: I don't know what that thing's worth, but the MySQL Server Status Pref Pane still says, "The MySQL Server Instance is NOT RUNNING." (their emphasis).
Unless the MySQL Server Pref pane was installed by Macports, it is worthless. Basically every process keeps a PID (process ID) file so that start and stop scripts can determine whether or not the process is running. The whole Macports (and Fink) design is based on giving you a completely isolated sandbox of all of your Unix tools that are separate from Apple's. This way, you don't have to worry about Apple's upgrades clobbering the Macports software, for instance. The PID installed by Macports is in its own path, and therefore other pref panes will not know where to find the Macports PID unless you create a symbolic link to it.
*Everything* installed by Macports is installed into /opt/local. You can always look for stuff in Unix with the following command:
find /search/path -iname "whatever"
where /search/path is the directory you want to search in, and iname means "named" and the optional "i" is for "case insensitive" (-name works too). You can add stars to indicate wildcards, so:
sudo find /opt/local -iname "*mysql*"
means search for files in /opt/local containing "mysql" in their name, and I don't care about case sensitivity. You can add:
to indicate "only show me files, not directories", or:
to only show directories. In Unix directories actually are files, but we generally don't call directories files.
I'm pretty sure the path to MySQL in Macports is /opt/local/bin/mysql5 or something like that. However, to start/stop MySQL you would need to invoke its start/stop script, which should have been installed as a launchd item (launchd is the OS X service for stopping and starting services - Apple's own and others). If you do a:
you'll get a list of all of the services with launchd start/stop scripts. If you don't see this, you probably installed the MySQL client and not the server (you can verify this with port installed mysql5-server). This is fine, just install the server:
sudo port install mysql5-server
Once you see your launchd item, you can set it to run and startup at boot by doing a:
sudo launchctl load -w ~/Library/LaunchAgents/<the mysql5 launchd file>
I'm not terribly familiar with launchd, so if this doesn't work let us know and I'm sure somebody will help. You can verify that it is running by doing a:
ps aux | grep mysql
ps = process list, the aux sets some display options, and the | grep mysql means filter this list only showing lines containing the words "mysql".
All of this being said, the reason why I don't bother running PHP/MySQL on my workstation is because shuttling data to and from the server can be a PITA, as is ensuring that the PHP extensions and environment matches your server close enough to be thought of as a functional mirror. This is definitely possible, but you might find it better in the long run to just create a VM of the same OS you run on your server and try to match this environment. If you don't have your own server, try to match the PHP configuration options and MySQL version running on your host. You don't have to nail this down to point updates, but you should familiarize yourself with some of the differences between PHP 4 and 5 and MySQL 4 and 5 so that you know how to make your code portable, as well as what sorts of PHP coding techniques require various php.ini configuration options. For example, if you get blank pages on your server running the same code on your client, the PHP memory allocation might need adjusting in your php.ini.
I generally think it's good for all web developers running apps on a Unix server to have at least a basic understanding of Unix. The host does matter, especially when it comes to stuff such as performance optimizing.
Also, if you do decide to shuttle data between machines, use mysqldump with the --default-character-set option and not just phpMyAdmin.
The default character set in MySQL is still latin, but a lot of web apps are starting to store data in utf8 now, particularly ones with foreign language support. If you try to important latin data with foreign language characters or other special ASCII characters including smart quotes to UTF8 and the character sets/collations don't match, you'll get funny characters appearing. So, it is good to make sure the collations match and that you specify your character set via this CLI option.
A great tutorial, Besson !
I discovered that I did need to port mysql5-server. ...though things haven't changed.
I did take the file location for launchctl that 2tbsp.com suggested for boot-starting of apache, since I noticed they had plist is parallel places
[ local/etc/LaunchDaemons/org.macports.mysql5/org.macports.mysql5.plist ]
And I certainly agree that some Unix fundamentals would be very handy for me... though I'm not sure they would help me understand how php5 is managing to get auto-started but not MySQL5-server.
PERHAPS?: the httpd.conf now has UNcommented "LoadModule php5__module libexec/apache2/libphp5.so
SO?: maybe there should be a similar LoadModule for mysql (if only I knew its proper name/location... perhaps "libexec/mysqld" ?)
Well, maybe I shouldn't have much faith in the value of what's in private/etc/apache2/httpd.conf ...
If I comment out the "LoadModule php5_module..." - then restart Apache... php still starts up without any instruction.
Am I at least getting it right that what starts-at-boot PHP, Apache, and MySQL must be different processes?
It certainly seems to me strange that there are LaunchDaemons for "apache2" and "mysql5" but not for PHP (and that it's apache2 and PHP5 that *are* starting up at boot).
[and of course, I'm not getting the distinction between Mysql and mysql-server (since the folders created with /etc/ are for php5 and just mysql5) ]
PS: BTW, most of the reason I'm trying to get set up with PHP/MySQL on development machine is that I'm often off-line or on a crippled internet connection in a rural area.
Apache and MySQL are different processes, but PHP isn't. PHP is an extension to Apache. IOW, there is no PHP startup script.
You don't want to edit anything in /private/etc or /etc, these are the Apple paths (and possibly the paths used by the other installers you used in the past). The Macports path is /opt/local/etc/. With exception to the launchd script, *nothing* should be outside of /opt/local. There was even some dispute among the Macports developers whether or not breaking from this with the launchd scripts was fair game.
That being said, I haven't used Macports to install Apache/MySQL/PHP in a long time. AFAIK, the convention of everything sandboxed into /opt/local with very few exceptions is still true though.
|All times are GMT -4. The time now is 08:02 AM.||
Copyright © 2005-2007 MacNN. All rights reserved.
Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2016, vBulletin Solutions, Inc.