<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Andrew Hancox</title>
	<atom:link href="http://blog.andrewhancox.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.andrewhancox.com</link>
	<description>Just another WordPress site</description>
	<lastBuildDate>Thu, 17 May 2012 16:04:26 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Getting ready to develop on OSX + Macports (PHP, Tomcat, MySQL, Apache, PostgreSQL)</title>
		<link>http://blog.andrewhancox.com/getting-ready-to-develop-on-osx-macports-php-tomcat-mysql-apache-postgresql/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=getting-ready-to-develop-on-osx-macports-php-tomcat-mysql-apache-postgresql</link>
		<comments>http://blog.andrewhancox.com/getting-ready-to-develop-on-osx-macports-php-tomcat-mysql-apache-postgresql/#comments</comments>
		<pubDate>Mon, 23 Apr 2012 10:18:00 +0000</pubDate>
		<dc:creator>andrew.hancox</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.andrewhancox.com/?p=30</guid>
		<description><![CDATA[This is a quick and nasty post with the exact steps I went through to get my Macbook Air running Lion ready to develop PHP, Tomcat, MySQL, Apache and PostgreSQL. I know I need to tidy up the formatting. These &#8230; <a href="http://blog.andrewhancox.com/getting-ready-to-develop-on-osx-macports-php-tomcat-mysql-apache-postgresql/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is a quick and nasty post with the exact steps I went through to get my Macbook Air running Lion ready to develop PHP, Tomcat, MySQL, Apache and PostgreSQL. I know I need to tidy up the formatting.<br />
These instructions built on three sources:<br />
<a href="http://2tbsp.com/content/install_apache_2_and_php_5_macports">Chad Kieffer&#8217;s apache2 and php5 install guide</a><br />
<a href="http://2tbsp.com/content/install_and_configure_mysql_5_macports">Chad Kieffer&#8217;s MySQL5 install guide</a><br />
<a href="http://guide.macports.org/#installing">Macports install guide</a></p>
<h3>Set up macports</h3>
<p>Install XCode 4.3.2 from the app store.<br />
Install the XCode command line tools by launching XCode and going to Open XCode-&gt;Preferences-&gt;Downloads-&gt;Components-&gt;Install Command Line Tools</p>
<p>Run the following command to set up the XCode environment:<br />
sudo xcode-select -switch /Applications/Xcode.app</p>
<p>Dowload and install Java from the Apple web site &#8211; <a href="http://support.apple.com/kb/DL1515">here</a>.</p>
<p>Download macports and run the installer.</p>
<h3>Set up apache</h3>
<p>sudo port install apache2<br />
Edit /opt/local/apache2/conf/httpd.conf<br />
Uncomment the line &#8220;Include conf/extra/httpd-vhosts.conf&#8221;<br />
Change &#8220;User www&#8221; to &#8220;User _www&#8221; and &#8220;Group www&#8221; to &#8220;Group _www&#8221;</p>
<p>Make somewhere in your home directory for your projects to live and give apache access rights to it:<br />
cd ~<br />
mkdir Projects<br />
chgrp www Projects/</p>
<p>Add to /etc/hosts:<br />
127.0.0.1 projects.mba.local</p>
<p>Add to /opt/local/apache2/conf/extra/httpd-vhosts.conf</p>
<p>Options Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews<br />
AllowOverride All<br />
Order allow,deny<br />
Allow from all</p>
<p>ServerAdmin webmaster@dummy-host2.example.com<br />
DocumentRoot &#8220;/Users/<strong>USERNAME</strong>/Projects&#8221;<br />
ServerName projects.imac.local</p>
<h3>Set up PHP</h3>
<p>sudo port install php5 +apache2 +pear +mysql5 +postgresql</p>
<p>This tells you to compile the apache php extension as follows:<br />
cd /opt/local/apache2/conf/<br />
sudo /opt/local/apache2/bin/apxs -a -e -n &#8220;php5&#8243; libphp5.so</p>
<p>Now edit your apache config (/opt/local/apache2/conf/httpd.conf)<br />
Add the lines</p>
<p>AddType application/x-httpd-php .php</p>
<p>Change</p>
<p>DirectoryIndex index.html</p>
<p>To</p>
<p>DirectoryIndex index.html index.php</p>
<p>Choose a PHP.ini file to use:<br />
cd /opt/local/etc/php5/<br />
sudo mv php.ini-development php.ini</p>
<p>- You&#8217;ve now installed PHP5 but there&#8217;s loads of other packages you&#8217;ll want installed, the ones I require are:<br />
sudo port install php5-mysql +mysqlnd<br />
sudo port install php5-apc php5-curl php5-gd php5-iconv php5-imagick php5-imap php5-mbstring php5-mcrypt php5-openssl php5-xmlrpc php5-xdebug</p>
<p>- Finally you need to add the xdebug config file that gets loaded by php:<br />
sudo vim /opt/local/var/db/php5/xdebug.ini<br />
Add the following lines to the end of the file:<br />
xdebug.remote_enable=on<br />
xdebug.remote_log=&#8221;/var/log/xdebug.log&#8221;<br />
xdebug.remote_host=localhost<br />
xdebug.remote_handler=dbgp<br />
xdebug.remote_port=9000</p>
<h3>Set up MySQL</h3>
<p>I made things slightly harder for myself by installing MySQL 5.5 which is slightly more fiddly.<br />
sudo port install mysql55 +server<br />
sudo port install mysql55-server<br />
These install mysql but for all the tools to be available on the command line you want to:<br />
sudo port select mysql mysql55<br />
this creates symlinks into opt/local/bin for convenience</p>
<p>mysql55-server said to run sudo -u _mysql /opt/local/lib/mysql55/scripts/mysql_install_db5 &#8211; this command is wrong it should be:<br />
sudo -u _mysql /opt/local/lib/mysql55/scripts/mysql_install_db</p>
<p>Set the following properties in php.ini<br />
mysqli.default_socket = /opt/local/var/run/mysql55/mysqld.sock<br />
mysql.default_socket = /opt/local/var/run/mysql55/mysqld.sock<br />
pdo_mysql.default_socket=/opt/local/var/run/mysql55/mysqld.sock</p>
<p>Out the box mac ports doesn&#8217;t set the max allowed packet for mysql which means that some apps (Drupal) will fall over very quickly. It also sets no networking which prevents anything from connecting via tcp<br />
 To fix this we need to edit the my.cnf file:<br />
sudo vim /opt/local/etc/mysql55/my.cnf</p>
<p>Comment out (#) the line !include /opt/local/etc/mysql55/macports-default.cnf</p>
<p>And add the following lines:<br />
[mysqld]<br />
max_allowed_packet = 64M</p>
<h3>Tomcat</h3>
<p>TODO<br />
sudo port install tomcat6</p>
<h3>Aliases to start and stop</h3>
<p>Because I use my laptop for many things other than development I like to start and stop all these services manually, to do this I&#8217;ve edited my bash profile (~/.bash_profile) and added the following aliases:<br />
alias start_mysql=&#8217;sudo /opt/local/bin/mysqld_safe &amp;&#8217;<br />
alias stop_mysql=&#8217;sudo /opt/local/bin/mysqladmin shutdown&#8217;<br />
alias start_apache=&#8217;sudo /opt/local/apache2/bin/apachectl start&#8217;<br />
alias stop_apache=&#8217;sudo /opt/local/apache2/bin/apachectl stop&#8217;<br />
alias start_tomcat=&#8217;sudo tomcatctl start&#8217;<br />
alias stop_tomcat=&#8217;sudo tomcatctl stop&#8217;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhancox.com/getting-ready-to-develop-on-osx-macports-php-tomcat-mysql-apache-postgresql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing mod_sed on OSX/Macports</title>
		<link>http://blog.andrewhancox.com/installing-mod_sed-on-osxmacports/?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=installing-mod_sed-on-osxmacports</link>
		<comments>http://blog.andrewhancox.com/installing-mod_sed-on-osxmacports/#comments</comments>
		<pubDate>Wed, 18 Apr 2012 13:18:50 +0000</pubDate>
		<dc:creator>andrew.hancox</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.andrewhancox.com/?p=4</guid>
		<description><![CDATA[I had to use mod_sed for a project that required more exotic functionality than mod_substitute could deliver. The version of apache that includes mod_sed in core (2.4) is not available via macports, neither is a package containing this one module &#8230; <a href="http://blog.andrewhancox.com/installing-mod_sed-on-osxmacports/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I had to use <a href="http://httpd.apache.org/docs/2.4/mod/mod_sed.html">mod_sed</a> for a project that required more exotic functionality than <a href="http://httpd.apache.org/docs/2.2/mod/mod_substitute.html">mod_substitute</a> could deliver.<br />
The version of apache that includes mod_sed in core (2.4) is not available via macports, neither is a package containing this one module and I couldn&#8217;t find a binary to download so that left me having to compile it myself which wasn&#8217;t as scary as I thought it would be.</p>
<p>Go somewhere you can put the files while you work on them:<br />
cd ~/Documents</p>
<p>Download the tarball containing the code:<br />
wget wget http://src.opensolaris.org/source/raw/webstack/apache-modules/sed/mod_sed.tar.gz</p>
<p>Decompress and expand the archive:<br />
tar xzf mod_sed.tar.gz</p>
<p>Go into the folder containing the sourcecode:<br />
cd mod_sed</p>
<p>Now you&#8217;ve got the source files accessible we need to compile them. You do this using <a href="http://httpd.apache.org/docs/2.2/programs/apxs.html">apxs</a> which is a tool dedicated to compiling apache extensions &#8211; you need to make sure that you use the copy of this tool that sits in your macports installation, not the stock OSX version so prepend the path to your mac ports apache bin folder (probably /opt/local/apache2/bin) to the commands:<br />
/opt/local/apache2/bin/apxs -c mod_sed.c sed0.c sed1.c regexp.c<br />
/opt/local/apache2/bin/apxs -i -a mod_sed.la</p>
<p>Once this is done the module should be in the apache modules folder (/opt/local/apache2/modules/mod_sed.so) and enabled in httpd.conf (/opt/local/apache2/confhttpd.conf) by the line:<br />
LoadModule sed_module         modules/mod_sed.so</p>
<p>So restart your instance of apache and you can start using the module.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.andrewhancox.com/installing-mod_sed-on-osxmacports/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

