{"id":41,"date":"2009-05-19T15:17:43","date_gmt":"2009-05-19T20:17:43","guid":{"rendered":"http:\/\/24.183.55.167:8101\/wordpress\/?p=41"},"modified":"2012-08-14T20:56:02","modified_gmt":"2012-08-15T01:56:02","slug":"installing-apache-php-mysql-and-memcached-on-os-x","status":"publish","type":"post","link":"https:\/\/icesquare.com\/wordpress\/installing-apache-php-mysql-and-memcached-on-os-x\/","title":{"rendered":"Installing Apache, PHP, MySQL and MemCached on OS X"},"content":{"rendered":"<p>This is my note on how to to install Apache, PHP and MySQL on a an OS X box. Although some of these applications are come with the operating systems, it is always good to know how to upgrade them to the latest version.<\/p>\n<h3>1. Apple Developer Tools and Mac Port<\/h3>\n<p>Before installing Mac Port, you will need the Apple Developer Tools. You can download it from the Apple Developer&#8217;s Network.<\/p>\n<p>After installing Apple Developer&#8217;s Tools, you can install Mac Port. You can get it from the <a href=\"http:\/\/www.macports.org\/install.php\">here<\/a>.<\/p>\n<p>Update Mac Port<\/p>\n<pre>sudo port selfupdate<\/pre>\n<p>Add the Mac Port path in the profile: &#8221;&#8217;~\/.bash_profile&#8221;&#8217;:<\/p>\n<pre>export PATH=\/opt\/local\/bin:$PATH<\/pre>\n<p>MySQL:Mac Port<br \/>\nInstall MySQL from Mac Port:<\/p>\n<pre>sudo port install mysql5<\/pre>\n<p>MySQL:Package<br \/>\nGo to the [http:\/\/dev.mysql.com\/downloads\/mysql\/5.0.html#macosx-dmg MySQL&#8217;s website] to download the package.<\/p>\n<p>Setup the a master password for root user:<\/p>\n<pre>\/usr\/local\/mysql\/bin\/mysqladmin -u root password 'new-password'<\/pre>\n<p>Add the MySQL path in the profile: &#8221;&#8217;~\/.bash_profile&#8221;&#8217;:<\/p>\n<pre>export PATH=\/usr\/local\/mysql\/bin:$PATH<\/pre>\n<h3>Apache:Mac Port<\/h3>\n<p>Install Apache from Mac Port:<\/p>\n<pre>sudo port install apache2<\/pre>\n<p>Open the configuration file: &#8221;&#8217;\/opt\/local\/etc\/rc.conf&#8221;&#8217; and add the following at the end of the file:<\/p>\n<pre>APACHE2=-YES-<\/pre>\n<h3>PHP:Mac Port<\/h3>\n<p>Install PHP from Mac Port:<\/p>\n<pre>sudo port install php5 +apache2 +mysql5 +pear <\/pre>\n<p>When that is done, register PHP 5 with Apache 2:<\/p>\n<pre>cd \/opt\/local\/apache2\/modules<\/pre>\n<pre>sudo \/opt\/local\/apache2\/bin\/apxs -a -e -n \"php5\" libphp5.so<\/pre>\n<p>And create a php.ini file (which you can edit to configure PHP 5):<\/p>\n<pre>sudo cp \/opt\/local\/etc\/php.ini-dist \/opt\/local\/etc\/php.ini<\/pre>\n<h4>httpd.conf<\/h4>\n<p>Edit the Apache configuration file &#8221;&#8217;\/opt\/local\/apache2\/conf\/httpd.conf&#8221;&#8217; and add the following lines to the end of the file:<\/p>\n<pre>AddType application\/x-httpd-php .php\r\nAddType application\/x-httpd-php-source .phps<\/pre>\n<p>Replace this line:<\/p>\n<pre>DirectoryIndex index.html<\/pre>\n<p>by the following:<\/p>\n<pre>DirectoryIndex index.php index.html<\/pre>\n<h4>php.ini<\/h4>\n<p>If the MySQL is installed from package rather than from Mac Port, we need to modify the mysql.default_socket value.<\/p>\n<p>Open &#8221;&#8217;\/opt\/local\/etc\/php.ini&#8221;&#8217;:<\/p>\n<pre>mysql.default_socket = \/tmp\/mysql.sock<\/pre>\n<h3>MemCached<\/h3>\n<p>Install MemCached from Mac Port:<\/p>\n<pre> sudo port install memcached<\/pre>\n<pre> sudo port install php5-memcache<\/pre>\n<p>We need to enable MemCached in PHP5. <\/p>\n<p>First, we need to add the following in &#8221;&#8217;\/opt\/local\/etc\/php.ini:&#8221;&#8217;:<\/p>\n<pre>\r\nextension_dir=\/opt\/local\/lib\/php\/extensions\/no-debug-non-zts-20060613\r\nextension = memcache.so\r\n<\/pre>\n<p>Run the following command to start MemCached:<\/p>\n<pre>sudo \/opt\/local\/bin\/memcached -d -u nobody<\/pre>\n<p><\/p>\n","protected":false},"excerpt":{"rendered":"<p>This is my note on how to to install Apache, PHP and MySQL on a an OS X box. Although some of these applications are come with the operating systems, <a class=\"more-link\" href=\"https:\/\/icesquare.com\/wordpress\/installing-apache-php-mysql-and-memcached-on-os-x\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_hide_featured_image":false,"_jetpack_featured_image_duplicate_dismissed":0,"_jetpack_feature_clip_id":0,"_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},"jetpack_post_was_ever_published":false},"categories":[144,6],"tags":[8,13,11,9,12,172],"class_list":["post-41","post","type-post","status-publish","format-standard","hentry","category-sever-problem","category-technology","tag-apache","tag-install","tag-memcached","tag-mysql","tag-os-x","tag-php"],"jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p1sqzr-F","jetpack_sharing_enabled":true,"jetpack-related-posts":[{"id":31,"url":"https:\/\/icesquare.com\/wordpress\/installing-apache-php-mysql-and-memcached-on-freebsd\/","url_meta":{"origin":41,"position":0},"title":"Installing Apache, PHP, MySQL and MemCached on FreeBSD","author":"Derrick","date":"May 19, 2009","format":false,"excerpt":"This is my note on how to to install Apache, PHP, MySQL and MemCached on a FreeBSD 7 Box. 1. MySQL Go to the mysql52-server port directory by typing the command: cd \/usr\/ports\/databases\/mysql51-server Build the port by typing: make BUILD_OPTIMIZED=yes BUILD_STATIC=yes Using these two options will speed up the execution\u2026","rel":"","context":"In &quot;FreeBSD&quot;","block_context":{"text":"FreeBSD","link":"https:\/\/icesquare.com\/wordpress\/category\/sever-problem\/freebsd\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":603,"url":"https:\/\/icesquare.com\/wordpress\/weird-php-error-after-freebsd-port-upgrade\/","url_meta":{"origin":41,"position":1},"title":"Weird PHP Error after FreeBSD port upgrade (PHP Warning:  PHP Startup: Unable to load dynamic library)","author":"Derrick","date":"April 6, 2010","format":false,"excerpt":"Today I upgraded the port on my FreeBSD box using portmaster tools: portmaster -Dai After that, I found that the PHP gave the following weird error: php -v PHP Warning: PHP Startup: Unable to load dynamic library '\/usr\/local\/lib\/php\/20060613\/memcached.so' - \/usr\/local\/lib\/php\/20060613\/memcached.so: Undefined symbol \" php_session_create_id\" in Unknown on line 0 PHP\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3514,"url":"https:\/\/icesquare.com\/wordpress\/freebsdphp-does-not-work-after-upgrading-apache-to-2-2-27\/","url_meta":{"origin":41,"position":2},"title":"[FreeBSD]PHP does not work after upgrading Apache to 2.2.27","author":"Derrick","date":"April 11, 2014","format":false,"excerpt":"I upgraded the Apache to 2.2.27 on my FreeBSD box via portmaster. The upgrade went very smooth. After the upgrade, I found that Apache no longer rendered the PHP page correctly. In the other words, it displayed the source code of the PHP files instead of executing the code. Before\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":351,"url":"https:\/\/icesquare.com\/wordpress\/installing-apache-on-snow-leopard-os-x-10-6\/","url_meta":{"origin":41,"position":3},"title":"Installing Apache on Snow Leopard (OS X 10.6)","author":"Derrick","date":"October 30, 2009","format":false,"excerpt":"The Apache web server comes with the OS X is a bit out dated. So I decided to install a new one. After I tried installing it using mac port, it kept giving error. Finally, I built the Apache from source, and it worked! Grep Apache from here. Download the\u2026","rel":"","context":"In &quot;Server Problems&quot;","block_context":{"text":"Server Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/sever-problem\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]},{"id":3474,"url":"https:\/\/icesquare.com\/wordpress\/the-easiest-way-to-improve-the-performance-of-mysql-server-on-freebsd\/","url_meta":{"origin":41,"position":4},"title":"The easiest way to improve the performance of MySQL server on FreeBSD","author":"Derrick","date":"February 2, 2014","format":false,"excerpt":"There are many different ways to improve the MySQL performance. In general, it breaks down into two different categories: Server side and client side. On the server side, we can optimize the database and table structure, such as indexing the columns etc. On the client side, we can optimize the\u2026","rel":"","context":"In &quot;Computer Problems&quot;","block_context":{"text":"Computer Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/technology\/computer-problems-computer-help-pc-support\/"},"img":{"alt_text":"","src":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1","width":350,"height":200,"srcset":"https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=350%2C200&ssl=1 1x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=525%2C300&ssl=1 1.5x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=700%2C400&ssl=1 2x, https:\/\/i0.wp.com\/icesquare.com\/wordpress\/wp-content\/uploads\/2014\/02\/speedometer.jpg?resize=1050%2C600&ssl=1 3x"},"classes":[]},{"id":110,"url":"https:\/\/icesquare.com\/wordpress\/tokyo-cabinet-is-31-times-faster-than-mysql\/","url_meta":{"origin":41,"position":5},"title":"Tokyo Cabinet is 31 times faster than MySQL!!!","author":"Derrick","date":"May 23, 2009","format":false,"excerpt":"Today I was comparing the performance of Tokyo Cabinet, MySQL and Memcached using PHP. The result of Tokyo Cabinet is really impressive! (Note that these results are generated from my computer. If you perform your own benchmarks, then you might find different results due to different system configurations. In fact,\u2026","rel":"","context":"In &quot;Programming Problems&quot;","block_context":{"text":"Programming Problems","link":"https:\/\/icesquare.com\/wordpress\/category\/programming-problems\/"},"img":{"alt_text":"","src":"","width":0,"height":0},"classes":[]}],"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/41","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/comments?post=41"}],"version-history":[{"count":10,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/41\/revisions"}],"predecessor-version":[{"id":2950,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/posts\/41\/revisions\/2950"}],"wp:attachment":[{"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/media?parent=41"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/categories?post=41"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/icesquare.com\/wordpress\/wp-json\/wp\/v2\/tags?post=41"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}