Posted in How-Tos on August 29th, 2009 by andrew – Be the first to comment
I have been wanting to do a clean install on my laptop for the last couple of months and decided that I would just wait for 10.6 to avoid having too much downtime from work. I like to compile my dev stack from source, and as expected this turned out to be the only problematic area for my upgrade. As a whole the transition was very smooth - both MySQL and Apache compiled without a hitch. However, I had a couple of issues with PHP (5.2) that took a little more work (nothing some Google fu couldn’t solve).
Both of these problems are related to shared libraries that PHP relies on:
libresolv
Running make resulted in the following error:
Undefined symbols:
"_res_9_dn_expand", referenced from:
_zif_dns_get_mx in dns.o
"_res_9_search", referenced from:
_zif_dns_get_mx in dns.o
_zif_dns_check_record in dns.o
"_res_9_dn_skipname", referenced from:
_zif_dns_get_mx in dns.o
_zif_dns_get_mx in dns.o
ld: symbol(s) not found
collect2: ld returned 1 exit status
make: *** [libs/libphp5.bundle] Error 1
Thanks to a great StackOverflow thread I was able to get around this fairly easily by editing 2 lines in the Makefile after running the configure script:
EXTRA_LIBS = -lresolv [... all of the other flags that are already here]
EXTRA_LDFLAGS = -lresolv [... all of the other flags that are already here]
libiconv
An error was also thrown in reference to libiconv. Apparently there is something strange with Apple’s included libiconv libraries. I was pretty easily able to get around this by compiling a local copy of libiconv from the source at gnu.org:
# download source, extract, enter directory
./configure --prefix=/usr/local
make
sudo make install
Then, just add –with-iconv=/usr/local to your configure options so PHP will link to your copy instead of the Leopard one.
Final configure command:
./configure --prefix=/usr/local/php52 --with-apxs2=/usr/local/apache2/bin/apxs\
--enable-shared=all --with-zlib --with-curl --with-freetype-dir=/usr/local\
--with-jpeg-dir=/usr/local/lib --with-png-dir=/usr/local --with-gd\
--with-mcrypt --with-mysql=/usr/local/mysql\
--with-mysqli=/usr/local/mysql/bin/mysql_config\
--with-pdo-mysql=/usr/local/mysql/bin/mysql_config --with-iconv=/usr/local
Note: I did find that these issues have been resolved in the PHP 5.3.1 branch and will most likely be backported to 5.2 at some point, so make sure to check future versions before taking this route.
Hopefully this helps someone else out until these issues are resolved by either the PHP team or Apple. Do let me know if I have missed something stupid here or if there is an easier way to resolve these issues.
Posted in How-Tos on May 14th, 2009 by andrew – 1 Comment
Here is a cool little OS X tip that I stumbled upon a couple of weeks ago. I was writing documentation for the setup of one of our applications and I found myself copying the contents of configuration files into the wiki manually. If you have done this before, you know that it can be pretty annoying when you are working from the terminal and you end up cutting off the ends of lines because you don’t realize that they are chopped off in nano.
However, thanks to Stack Overflow, I was able to find a very elegant solution for this situation when you are working from a Mac client: pbcopy (and the yen to it’s yang, pbpaste). These 2 little programs allow you to pipe text to and from your clipboard into your terminal. For example, pretend I have a configuration file that I need to copy into a blog post or wiki:
$ cat localhost.conf | pbcopy
Now I can just use a standard paste command to insert the contents of the file into any input field. No need to open the file in an editor: easy. The inverse is also possible. Pretend you have copied a code snippet from an online tutorial to your clipboard and you need to create a file with the copied text as the content.
I am sure that there are some other cool uses for these commands, so put your ideas into the comments!
Posted in Blogging on May 7th, 2009 by andrew – 1 Comment
There are many reasons to have a personal blog. The most obvious (and frequent) reason is to have a place to keep your friends up-to-date with what you are doing. However, blogs are also a great tool for allowing potential employers or clients to know what you are passionate about and how you think. While I am not currently looking for a change in either of those areas, I decided that it is important to lay the groundwork now.
To begin with, I have finally moved this blog to a permanent home at andrewbredow.com instead of a subdomain to a site that I have no intention of developing any time soon. Any old links to site will be redirected here with 301 (permanent) redirect for the time being, and I will probably get rid of the subdomain altogether in a couple of months.
Additionally, I have made the switch over to Feedburner (which is now owned by Google) for my RSS feed. This will provide me with some better metrics and additional exposure and it also allows the possibility of switching out blogging software while keeping the same feed address. If you are subscribed to the old feed it will continue to work as long as the redirect is in place. However, it would be great if you re-subscribed using the Feedburner feed!
That’s all for now; there are more exciting things coming soon!
Posted in How-Tos on May 4th, 2009 by andrew – 3 Comments
The problem
When I first developing web applications I was only responsible for one site. My typical workflow was to have a checkout of the application in my document root and to just use http://localhost to debug it before I checked in my changes. As I started working on other projects, I would just go into my Apache configuration and change my document root to another directory. This got rather annoying after a while since I had to edit files and restart Apache every time I switched gears.
Then the light bulb clicked on: I knew how to configure virtual hosts to run multiple sites on web servers, why didn’t I just do the same thing on my local machine? Once this is accomplished, it becomes very painless to switch contexts between multiple applications. As an added bonus it also makes it very easy to install open source web applications on your local machine, do some hacking, and learn how they work. While this same thing is technically possible just by adding new folders to your document root, this can really confuse some web applications that are expecting to handle all of their URLs as directly relative to your base path.
Prerequisites
The only prerequisite to this tutorial is that you have a relatively clean install of Apache on your local machine. You can use the default OS X install, or also also a vanilla copy installed via the Windows Apache installer. I am going to give instructions for a *NIX OS, but this setup also works fine in Windows.
Set up
- First, you will want to locate your Apache configuration directory (containing http.conf). On OS X or most other flavors of UNIX it is /etc/apache2/, or Windows: C:/apache2/conf. Next, open your terminal and cd into the directory:
$ cd /usr/local/apache2/conf
- Add a “sites” subdirectory to your Apache configuration directory. This is the directory that will hold all of your virtual host configuration files.
- Locate your httpd.conf file, open it up for editing
- Now, we want to edit a couple of configuration settings. You may find variations of these already in the file that you can either delete or modify.
NameVirtualHost *:80
Include conf/sites
The first line tells Apache to use name-based virtual hosts. This means that it will match virtual hosts based on the domain name of the request. The second line causes all files in the sites directory to be included when Apache reads in it’s configuration files. Note that this folder location is relative to your ServerRoot location which you will find elsewhere in httpd.conf if you search for it.
- Next, you are going to go into your “sites” folder and create your first virtual host configuration file. It is helpful to name the files based on the domain that they reference (I am going to create http://local.andrew).
$ cd sites
$ nano local.andrew.conf
The basic file contents are
<VirtualHost *:80>
ServerName local.andrew
DocumentRoot /Users/andrew/Sites/somecoolsite
<Directory /Users/andrew/Sites/somecoolsite>
Options +FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
This is fairly self explanatory. In the first line you set the domain that you want to use with the ServerName directive. The document root of your files (they can be anywhere on your computer) goes after the DocumentRoot directive. Finally, the Directory block is where you can put any settings that are specific to this host (e.g. Rewrite rules).
- Next, you will need to create an entry in your host file to direct all traffic sent to your custom domain to your local machine. On any *NIX system the file is /etc/hosts, and on Windows it is C:\WINDOWS\system32\drivers\etc\hosts. The format is the same on all systems, just add a line like:
127.0.0.1 local.andrew
- You are all done setting up your first virtual host. Restart Apache (you will probably need to use a hard restart - apachectl restart - for your vhost settings to be applied), and direct your browser to whatever hostname you created. You should see your site right away!
Now that you have 1 host set up it is super easy to add more. Just copy your existing host file to a new name and edit the settings accordingly! This should greatly improve your workflow and help you be a more productive ninja developer.
Posted in Uncategorized on April 29th, 2009 by andrew – 2 Comments
Things have been a little crazy for the last couple of months. When I first started blogging in January, I had a big list of topics that I wanted to write about. However, in reality, I have been working on too many things to have time to develop and write any of these longer posts, so I think I am going to try to step back a bit and focus a little more on what I am working on and also try to bring a little more of a personal presence into this blog by sharing some of my musings and interests outside of technology.
My day job at Live Oak is has been great lately. I am continually reminded of how blessed I am to have a great job where I am surrounded by such smart people! On the project front, I have spent the last few months planning and beginning development on a large social networking application. I am not sure how much I can actually talk it about on here, but I hope to fill you all in as soon as possible. However, I will say that this is a unique project for me not only because it is technologically awesome and challenging, but also because I am excited about the impact that it will make when it launches. For me, this is the height of career satisfaction: being able to use my abilities and intellect for a cause that I believe in.
Outside of work, I am continuing to work on SailboatConnection.com, a project that has been in the works since last summer. While it got off to a bit of a slow start, the pace has really picked up over the last couple of months, and we are nearing the first milestone that will accessed by select public users. This project has been really fun mostly because it is the first project that I started using Zend Framework (including the MVC stack) from the beginning. I will share more details about this project as soon as it is available to the public.
On the personal front, things at home have been good. Carrie is nearing the end of her last semester with classes! I am really looking forward to spending more time with her this summer, even though she has to start work on her comps for her dissertation (boo). We don’t have tangible plans yet, but I am guessing that we will make it up to Michigan to see family and friends at some point, in addition to branching out and seeing more of Texas than just Austin and the hill country (please leave any suggestions on the comments!)