Installing PHP 5.3 with mysqlnd on Mac OS X with MacPorts
Historically, I’ve always preferred to use Apple’s built-in Apache 2.2 and PHP 5.x that comes with Leopard. However, after trying to compile PHP 5.3 from scratch and connect it with Apache, I decided to just use the MacPorts installer instead. That did mean giving up control of a finely-tuned Apache installation, but in the end, I think I’ve ended up with a better localhost system.
Prerequisites
- Install MacPorts
Also, make sure that your MacPorts install is completely up-to-date with:
sudo port -d selfupdate
Installation
Now, I’ve never used MacPorts to install PHP or Apache before, so I’m starting with a clean slate. If you’ve already installed PHP or Apache with MacPorts, your steps may be different. As always, your mileage may vary. For me, I develop several open-source projects, so I need things that others may not. Adjust these steps as necessary.
- Using “Web Sharing” in your Sharing Preferences should be turned off. Currently this points to the (old) Apple Apache installation, although we’ll change that later.
- From Terminal, install PHP 5.3 + Apache, and some other stuff. This will likely take quite a while. I’m installing SQLite, MySQL, and PostgreSQL because of my work on CacheCore, so you may or may not need those.
mysqlndis the new PHP Native Driver for MySQL and is supposed to be better, so we’ll use that. We also need to enable non-default settings for cURL.sudo port install curl +ssl+ipv6+ares+idn+gss+openldap+sftp_scp \ php5 +apache2+fastcgi+pear
You can see all available options by running
port variants php5 - The new Apache configuration file is stored at
/opt/local/apache2/conf/httpd.confwhile the old one was at/etc/apache2/conf/httpd.conf. Take a moment to copy over any settings you’ll want to maintain into the new Apache installation. - You’ll also want to include your extra settings. Toward the bottom of your
httpd.conffile, add the following line:# All settings Include conf/extra/*.conf
- If you don’t have an SSL certificate, rename your SSL configuration:
cd /opt/local/apache2; sudo mv conf/extra/httpd-ssl.conf conf/extra/httpd-ssl.conf-disabled
- You’ll also want to enable PHP in Apache:
sudo mv conf/extras-conf/mod_php.conf conf/extra/mod_php.conf
- The new PHP configuration file is stored at
/opt/local/etc/php5/php.iniwhile the old one was at/etc/php.ini. Take a moment to copy over any settings you’ll want to maintain into the new PHP installation. - Restart Apache. If you were using
apachectlbefore, it still points to the old Apache, so we’ll want to point specifically to the new one.sudo /opt/local/apache2/bin/apachectl restart
At this point, PHP 5.3 with Apache 2.2 and the new mysqlnd extension are all installed.
Extra stuff
- I generally prefer to have lots more stuff installed locally so that I can worry more about developing and less about installing. Because of this, I also install a few other things.
sudo port install memcached \ php5-apc \ php5-curl \ php5-http \ php5-iconv \ php5-imagick \ php5-mbstring \ php5-memcache \ php5-mysql \ php5-postgresql \ php5-sockets \ php5-sqlite \ php5-tidy \ php5-xdebug - Restart Apache with:
sudo /opt/local/apache2/bin/apachectl restart
Replacing older versions
Now, we want to continue using our command-line PHP scripts and the “Web Sharing” checkbox in the Sharing Preference Pane, so let’s make sure that those are all pointing to the new locations instead. We’ll be backing up and redirecting php, apachectl, and httpd.
- Open up your Sharing Preference Pane, and disable Web Sharing
- Run the following command on the Terminal:
sudo mv /usr/bin/php /usr/bin/php.bak && sudo ln -s /opt/local/bin/php /usr/bin/php; \ sudo mv /usr/sbin/apachectl /usr/sbin/apachectl.bak && sudo ln -s /opt/local/apache2/bin/apachectl /usr/sbin/apachectl; \ sudo mv /usr/sbin/httpd /usr/sbin/httpd.bak && sudo ln -s /opt/local/apache2/bin/httpd /usr/sbin/httpd; \
- Re-enable Web Sharing in the preference pane.
Shortcuts
Lastly, I like to set up some shortcuts so that I can access all of my important localhost stuff from one place. I’ll create a new directory called www-config and then I’ll place symlinks into it for quick access to Apache and PHP configuration files.
sudo mkdir /www-config && \ cd /www-config && \ sudo ln -s /opt/local/apache2/bin/apachectl /www-config/apachectl && \ sudo ln -s /opt/local/apache2/conf/ /www-config/httpd-conf && \ sudo ln -s /opt/local/var/db/php5/ /www-config/php-ini && \ sudo ln -s /opt/local/etc/php5/php.ini /www-config/php.ini
Run Internet Explorer 6 (or IE7, or IE8) images in VirtualBox on Mac OS X
Update: Microsoft’s images are broken, and don’t work on anything except VirtualPC now. Mac and Linux users are out of luck for the time being. More information on the subject can be found at http://blogs.msdn.com/petel/archive/2009/09/09/running-the-ie-vpc-s-on-other-vpc-hosts.aspx.
These days I’m looking to save money anywhere I can. How about you? Whereas VMWare Fusion (as awesome as it is) runs around $80 USD per copy, Sun’s VirtualBox is a free, open-source product for virtualization that runs on Mac OS X, Linux, and Windows.
If you’ve not yet read the related post, “Run Internet Explorer 6 (or IE7, or IE8) images in VMWare Fusion on Mac OS X,” you should. This is a follow up on how to take those virtual machines (which we’ve already done a lot of work on), and convert them for use VirtualBox.
Prerequisites
- You need to have access to a Mac OS X machine.
- A broadband connection would be quite helpful.
- A USB flash drive (or some other way to copy files to the VM before you have network access enabled).
VMWare Fusion uses the .vmdk disk format for its virtual drives. VirtualBox uses the .vdi format. Although VirtualBox can use the existing .vmdk images, you get better performance if you convert them to .vdi.
Downloading and Preparing stuff
- Download and install VirtualBox. It should live in the
/Applicationsdirectory. - Download and install Q (a Mac version of Qemu). It should live in the
/Applicationsdirectory. - Download and decompress an IE6, IE7, or IE8 VMWare Fusion image that I’ve posted previously. If you need ALL of them, you can save yourself the bandwidth by downloading the IE6 image, making a copy of the file, and upgrading that copy to IE7 or IE8.
Extracting the disk image
- When you decompress the VMWare Fusion image, you should end up with a folder containing 3 files: Two text files, and a
.vmwarefile. - Right-click (or command-click) the
.vmwarefile and choose “Show package contents.” This will open up a new window. - Find the
.vmdkfile and drag it some place that’s easy to find. In this tutorial, we’ll use the desktop.
Converting the VMWare image to a VirtualBox image (Optional)
This step is optional. VirtualBox can read the VMWare Fusion disk image format if you’re short on time. However, you get better performance if you convert to the native VirtualBox format.
- Fire up
Terminal.app. It lives inside your/Applications/Utilitiesdirectory. - Move to your desktop directory:
cd ~/Desktop
- We’ll convert the
.vmdkfile into a raw hard drive file, then convert that raw file into the native.vdiformat:/Applications/Q.app/Contents/MacOS/qemu-img convert -O raw IE6-XP.vmdk IE6-XP.raw && /Applications/VirtualBox.app/Contents/MacOS/VBoxManage convertdd IE6-XP.raw IE6-XP.vdi && rm IE6-XP.raw
- Wait. Depending on your computer, this will probably take 20-45 minutes.
- Once it’s done, you can delete the
IE6-XP.vmdkfile.
Configuring the VM
- Move the new
.vdifile to wherever you’ll want your virtual machines to live. - Launch VirtualBox. You’ll be presented with the “Welcome to VirtualBox” dialog.
- Click “New.” A “Create new virtual machine” dialog box will pop up. Click “Next.”
- Name your virtual machine. I named mine “IE6-XP.”
- Operating system is “Microsoft Windows.” Version is “Windows XP.” Click “Next.”
- Determine the amount of RAM you want to allow the virtual machine to use. I have 4 GB of RAM, so I allow 512 MB. Adjust as necessary, but I wouldn’t go below 192 MB. Click “Next.”
- Here, you select the disk image to use. Choose “Use existing hard disk.” There is a pull-down menu that says “<no media>”. Click the icon to the right of it.
- The “Virtual Media Manager” dialog should pop up. Click “Add.”
- Find where you saved the
.vdifile to, and select it. Once that’s done, click the “Select” button. This will close the Virtual Media Manager” dialog. - Back on the “Create new virtual machine” dialog, the pull-down menu that used to say “<no media>” should now say something along the lines of “IE6-XP.vdi (Normal, 16.00 GB).” Click “Next,” then “Finish.”
- From there, click “Settings” along the top of the application.
- Click the “Audio” tab, and deselect “Enable audio.” We don’t have the drivers for this, so we’ll save ourselves the nag-ware.
- Click the “Network” tab, and choose “Intel PRO/1000 MT Desktop” from the Adapter Type pull-down.
- Leave everything else as default, and click OK.
- Click “Start” along the top of the application to start the virtual machine.
Installing the drivers and Guest Additions
- When the virtual machine starts, the viewport will be very small. Windows also may be asking you to find drivers. Make it go away for now.
- In the “Devices” menu, choose “Install Guest Additions.” This will load a virtual CD-ROM.
- The setup should begin automatically. If it doesn’t, go to the Start Menu, choose “My Computer,” then double-click on “VirtualBox Guest Additions.”
- Go through the process and install the software, then restart your VM.
- While that restarts, switch back to Mac OS X and download the driver for the Intel PRO/1000 MT ethernet card. Download the version for Windows XP (32-bit). Copy it to your USB flash drive.
- When the virtual machine comes back up, you’ll need to connect your USB flash drive to your virtual machine. To do this, you’ll need to drag the flash drive icon to the trash from Mac OS X (but leave it physically connected). In VirtualBox, go to the menubar and choose
Devices > USB Devices > USB Flash Drive. - Navigate to the installer on your flash drive, and install the Intel drivers.
- Lastly, go to
Start Menu > Run, then in the dialog type the following so that you can keep the additional drivers on your VM:D:\VBoxWindowsAdditions-x86.exe /extract /D=C:\Drivers
Done!
You should be all set! If you want to get all super-hacky, you can check out “Create IE VBox” for geekier details.
Run Internet Explorer 6 (or IE7, or IE8) images in VMware Fusion on Mac OS X
Update: Microsoft’s images are broken, and don’t work on anything except VirtualPC now. Mac and Linux users are out of luck for the time being. More information on the subject can be found at http://blogs.msdn.com/petel/archive/2009/09/09/running-the-ie-vpc-s-on-other-vpc-hosts.aspx.
By now, most front-end web developers have heard of the Standalone Internet Explorers (Wikipedia article). Although these are incredibly useful, they’ve always been hacky at best.
Because of that, we need to go the long way. We’ll download the “officially sanctioned” VirtualPC images containing a time-limited version of Windows XP SP3 and Internet Explorer 6.0, and then we’ll convert these images to the kind that work with VMware Fusion (which works on Mac OS X). This should only need to be done every 3 or 4 months when the images expire.
These instructions are loosely based on the ones found at Running IE6, IE7 and IE8 on your Mac.
Prerequisites
- You need to have VMware Fusion installed on your Mac.
- You need to have access to a Windows XP machine, as this is where the converting will happen.
For those in a hurry
Update: Sorry, but I got killed on my Amazon S3 hosting bill this month. If you want to convert the images, you can do them yourselves.
Installing Qemu (FIRST-TIME ONLY)
- Download a small application to our Windows machine called Qemu. At the time of this writing, you want to download the regular version 0.9.1. Once it’s done, unzip it someplace that’s easy to get to via the command line (e.g.
c:\qemu). - Go into the Qemu folder, then into the
binfolder and copy all of the files in thebinfolder back to the original Qemu folder (you can simply copy-paste).
Downloading and Preparing stuff
- On Microsoft’s website, they have a page entitled Internet Explorer Application Compatibility VPC Image where you can download various time-limited images that allow you to test combinations of Windows XP SP3 or Vista, along with Internet Explorer 6.0, 7.0, and the 8.0 betas. In this example, we’re going to install the IE6/XP image but you can do whatever you need to do.
- We’ll need to unpack this download in Windows, so if you haven’t already, make sure you’re doing this part in Windows.
- Double-click it (in Windows) to begin unpacking it. It will warn you that it has an expiration date. On that date, we’ll have to download a fresh VPC image from Microsoft and do this all over again.
Converting the image
- You’ll want to copy the
XP SP3 with IE6.vhdfile into the Qemu folder. This will allow us to use simpler, more consistent commands to convert the image. - In your Windows VM go to
Start Menu > Run, type thecmdcommand, and click OK. - Using your deftly intimate knowledge of MS-DOS, use commands like
cdto navigate to where you unpacked Qemu. - If you don’t know MS-DOS commands from a hole in the wall, you can download Open Command Window Here from Microsoft, install it, find the Qemu folder in the normal Windows Explorer, right-click, and choose “Open Command Window Here”. One method is shorter and harder, while the other is easier and slower. Take your pick.
- Type the following command in your MS-DOS window:
qemu-img.exe convert -f vpc "XP SP3 with IE6.vhd" -O vmdk IE6-XP.vmdk
Note that “XP SP3 with IE6.vhd” is the path to the IE6 VPC file you downloaded, while “IE6-XP.vmdk” is the new file that VMWare Fusion will use.
- Wait. This will probably take 5-10 minutes.
Configuring the VM
- Move the new
.vmdkfile to your Mac. - Open VMWare Fusion (or shutdown the Windows VM you may already have running) and click
File > New. - Go through the wizard and when you get to the “Virtual Hard Disk” page, expand “Advanced disk options”, check “Use an existing virtual disk” and use the dropdown to find the new
.vmdkimage you just copied back to your Mac. - Finish the wizard and start it! If prompted to upgrade the virtual hard drive, click “Yes.”
Installing the drivers and VMWare Tools
- With VMWare Fusion running, download and decompress vmware_xpsp3_drivers.tar.gz. Copy all of the resulting files to
c:\windows\system32\drivers. Make sure you install these BEFORE the VMware tools! - Download vmware_mouse.reg and double-click it to load its settings into the Windows registry. VMware doesn’t correctly overwrite these setting upon install of the VMware tools, and the mouse can start doing wonky things. These registry settings fix it.
- In VMware, click
Virtual Machine > Install VMWare Tools. - Follow the instructions. If Windows asks for additional drivers, point it to
c:\windows\system32\drivers. - Make sure that you shutdown the VM and configure your memory (etc.) settings appropriately.
