{"id":207,"date":"2007-09-17T18:53:32","date_gmt":"2007-09-18T02:53:32","guid":{"rendered":"http:\/\/www.evardsson.com\/blog\/2007\/09\/17\/apache-226-php-524-and-mysql-5045-on-os-x\/"},"modified":"2007-10-22T08:11:09","modified_gmt":"2007-10-22T16:11:09","slug":"apache-226-php-524-and-mysql-5045-on-os-x","status":"publish","type":"post","link":"https:\/\/www.evardsson.com\/blog\/2007\/09\/17\/apache-226-php-524-and-mysql-5045-on-os-x\/","title":{"rendered":"Apache 2.2.6, PHP 5.2.4 and MySQL 5.0.45 on OS X"},"content":{"rendered":"<p>I got tired of looking for a way to replace the Apache\/PHP that Apple packages with OS X (without breaking anything else in the process) so I decided to install Apache 2.2 and PHP5 in their own location to avoid stepping on the Apple package toes.<\/p>\n<p>Since I do a great deal of development again MySQL I needed to install that as well, and figured that I would probably need the GD functionality as well so I grabbed libjpeg and libpng to make those work as well. This is the step-by-step.<\/p>\n<p>(Props to James Pelow and his <a href=\"http:\/\/www.phpmac.com\/articles.php?view=252\">article from last year<\/a>, from which I borrowed the configure command lines and configuration modifications, as well as the idea of installing the whole mess in \/apache2.)<\/p>\n<p>Download the latest MySQL (I used the package version) from <a href=\"http:\/\/dev.mysql.com\/downloads\/\">MySQL<\/a>.<\/p>\n<p>Installation is straightforward following the same methods as any other Mac installer.<\/p>\n<p>Download and install libjpeg and libpng &#8211; from <a href=\"http:\/\/ethan.tira-thompson.com\/Mac%20OS%20X%20Ports.html\">Ethan Tira-Thompson<\/a> (this is also in a Mac installer which contains both libraries in one installer).<\/p>\n<p>Download the latest Apache httpd server (Unix source) from <a href=\"http:\/\/httpd.apache.org\/download.cgi\">Apache<\/a><\/p>\n<p>in the terminal:<\/p>\n<pre>\r\ntar -xzvf httpd-2.2.6.tar.gz &amp;&amp; cd httpd-2.2.6\r\n\r\n.\/configure\r\n\r\n--prefix=\/apache2\r\n\r\n--enable-module=most\r\n\r\n--enable-shared=max\r\n\r\nmake\r\n\r\nsudo make install\r\n\r\nsudo mkdir \/apache2\/php<\/pre>\n<p>Download the latest PHP from <a href=\"http:\/\/www.php.net\/downloads.php\">PHP<\/a><\/p>\n<pre>\r\ntar -xzvf php-5.2.4.tar.gz &amp;&amp; cd php-5.2.4\r\n\r\n.\/configure\r\n\r\n--prefix=\/apache2\/php\r\n\r\n--with-zlib\r\n\r\n--with-xml\r\n\r\n--with-ldap=\/usr\r\n\r\n--enable-cli\r\n\r\n--with-zlib-dir=\/usr\r\n\r\n--enable-exif\r\n\r\n--enable-ftp\r\n\r\n--enable-mbstring\r\n\r\n--enable-mbregex\r\n\r\n--enable-dbx\r\n\r\n--enable-sockets\r\n\r\n--with-iodbc=\/usr\r\n\r\n--with-curl=\/usr\r\n\r\n--with-mysql=\/usr\/local\/mysql\r\n\r\n--with-gd\r\n\r\n--with-jpeg-dir=\/usr\/local\r\n\r\n--with-png-dir=\/usr\/local<\/pre>\n<pre>--with-apxs2=\/apache2\/bin\/apxsmake\r\n\r\nsudo make install\r\n\r\nsudo cp php.ini-dist \/apache2\/php\/lib\/php.ini<\/pre>\n<p>Now to make your Apache2.2 a little more &#8216;Mac&#8217; &#8211; you can point it at the Mac web shared files folder, change the user and group and change the location for user files to match the Mac folder system.<\/p>\n<p>Edit httpd.conf (I use nano, you can use any flat text editor like nano, pico, vi, emacs or even BBedit)<\/p>\n<pre>sudo nano -w \/apache2\/conf\/httpd.conf<\/pre>\n<p>The changes to httpd.conf I made:<br \/>\nI changed<\/p>\n<pre>User daemon<\/pre>\n<pre>Group daemon<\/pre>\n<p>to<\/p>\n<pre>User www<\/pre>\n<pre>Group www<\/pre>\n<p>and<\/p>\n<pre>DocumentRoot \"\/apache2\/htdocs\"<\/pre>\n<p>to<\/p>\n<pre>DocumentRoot \"\/Library\/WebServer\/Documents\"<\/pre>\n<p>and<\/p>\n<pre>&lt;Directory \"\/apache2\/htdocs\"&gt;<\/pre>\n<p>to<\/p>\n<pre>&lt;Directory \"\/Library\/WebServer\/Documents\"&gt;<\/pre>\n<p>and added<\/p>\n<pre>AddType application\/x-httpd-php .php<\/pre>\n<pre>AddType application\/x-httpd-php-source .phps\r\n\r\nDirectoryIndex index.html index.php<\/pre>\n<p>Edit httpd-userdir.conf<\/p>\n<pre>sudo nano -w \/apache2\/conf\/extra\/httpd-userdir.conf<\/pre>\n<p>The changes to httpd-userdir.conf I made:<br \/>\nI changed<\/p>\n<pre>UserDir public_html<\/pre>\n<p>to<\/p>\n<pre>UserDir Sites<\/pre>\n<p>To start and stop the server:<br \/>\nMySQL comes with a Preference Pane that allows you to start and stop it there. To start and stop Apache you need to first make sure that the default Apache shipped with OS X is stopped.<\/p>\n<pre>sudo \/apache2\/bin\/apachectl start<\/pre>\n<pre>sudo \/apache2\/bin\/apachectl stop<\/pre>\n<p>I only ran into one issue, when trying to start the server I ran against the following error message (and no running server, of course):<\/p>\n<pre>httpd: Syntax error on line 53 of \/apache2\/conf\/httpd.conf:<\/pre>\n<pre>Cannot load \/apache2\/modules\/libphp5.so into server:<\/pre>\n<pre>Library not loaded: \/usr\/local\/mysql\/lib\/mysql\/libmysqlclient.15.dylib<\/pre>\n<pre>Referenced from: \/apache2\/modules\/libphp5.son  Reason: image not found<\/pre>\n<p>To fix this I did the following:<\/p>\n<pre>cd \/usr\/local\/mysql\/lib<\/pre>\n<pre>sudo mkdir \/usr\/local\/mysql\/lib\/mysql\r\n\r\nfor i in `ls .\/l*`; do sudo ln -sf \/usr\/local\/mysql\/lib\/$i \/usr\/local\/mysql\/lib\/mysql\/$i; done<\/pre>\n<p>This creates soft links in the directory that libphp5.so is looking for the MySQL libraries.<\/p>\n<p>Then it started right up! Wheee! (I did a quick test by dropping PhpMyAdmin into the \/Library\/WebServer\/Documents folder and browsed to it &#8211; the whole Apache\/PHP\/MySQL is working correctly)<\/p>\n<p>Technorati Tags: <a href=\"http:\/\/technorati.com\/tag\/Apache%202.2\" class=\"performancingtags\" rel=\"tag\">Apache 2.2<\/a>, <a href=\"http:\/\/technorati.com\/tag\/PHP5\" class=\"performancingtags\" rel=\"tag\">PHP5<\/a>, <a href=\"http:\/\/technorati.com\/tag\/MySQL%205\" class=\"performancingtags\" rel=\"tag\">MySQL 5<\/a>, <a href=\"http:\/\/technorati.com\/tag\/OS%20X\" class=\"performancingtags\" rel=\"tag\">OS X<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I got tired of looking for a way to replace the Apache\/PHP that Apple packages with OS X (without breaking anything else in the process) so I decided to install Apache 2.2 and PHP5 in &hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":false,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2}},"categories":[25,13,21,33],"tags":[162,150,158,170],"class_list":["post-207","post","type-post","status-publish","format-standard","hentry","category-apache","category-mysql","category-os-x","category-php","tag-apache","tag-mysql","tag-os-x","tag-php"],"jetpack_publicize_connections":[],"jetpack_featured_media_url":"","jetpack_shortlink":"https:\/\/wp.me\/pxT7i-3l","jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/posts\/207","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/comments?post=207"}],"version-history":[{"count":0,"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/posts\/207\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/media?parent=207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/categories?post=207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.evardsson.com\/blog\/wp-json\/wp\/v2\/tags?post=207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}