PECL UUID extension on Mac OSX
Today I needed to set up the PECL UUID PHP module on my Mac OSX 10.7 Lion development machine, I needed it for a project that I'm working on.
My first reaction was to fire up terminal and run sudo pecl install uuid. It all looked good for a moment but then came to a grinding halt when 'make' failed.
Here is the error for reference (and for those searching snippets of it):
|
1 2 3 4 5 6 7 8 9 10 11 12 |
cc -I. -I/private/tmp/pear/temp/uuid -DPHP_ATOM_INC -I/private/tmp/pear/temp/pear-build-rootEEpqkn/uuid-1.0.2/include -I/private/tmp/pear/temp/pear-build-rootEEpqkn/uuid-1.0.2/main -I/private/tmp/pear/temp/uuid -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -I/include -DHAVE_CONFIG_H -g -O2 -c /private/tmp/pear/temp/uuid/uuid.c -fno-common -DPIC -o .libs/uuid.o /private/tmp/pear/temp/uuid/uuid.c: In function ‘zm_startup_uuid’: /private/tmp/pear/temp/uuid/uuid.c:89: error: ‘UUID_TYPE_DCE_TIME’ undeclared (first use in this function) /private/tmp/pear/temp/uuid/uuid.c:89: error: (Each undeclared identifier is reported only once /private/tmp/pear/temp/uuid/uuid.c:89: error: for each function it appears in.) /private/tmp/pear/temp/uuid/uuid.c:90: error: ‘UUID_TYPE_DCE_RANDOM’ undeclared (first use in this function) /private/tmp/pear/temp/uuid/uuid.c: In function ‘zif_uuid_create’: /private/tmp/pear/temp/uuid/uuid.c:168: error: ‘UUID_TYPE_DCE_TIME’ undeclared (first use in this function) /private/tmp/pear/temp/uuid/uuid.c:171: error: ‘UUID_TYPE_DCE_RANDOM’ undeclared (first use in this function) /private/tmp/pear/temp/uuid/uuid.c:181: warning: format ‘%d’ expects type ‘int’, but argument 4 has type ‘long int’ make: *** [uuid.lo] Error 1 ERROR: `make' failed |
After a bit of googling I found out what the problem was and a solution to it. The full explanation and solution can be found here:
http://unrealexpectations.com/blog/2010/04/mamp-pecluuid-module-working-on-snow-leopard/
I can confirm that the patch and build worked on my set up (OSX 10.7 Loin) and I hope by spreading the word it some more people out.
Installing and setting up PEAR
This post will help you get PEAR installed and up and running on your machine, there are two options to below, one describes an OXS Lion specific setup and the other is more generic.
Installing on OSX 10.7 Lion
OSX Lion already has the PEAR install bundle so there is no need to download it, open up a terminal window and enter the following commands:
|
1 2 |
cd /usr/lib/php sudo php install-pear-nozlib.phar |
Downloading and installing
Do not follow this part if you have just done the above steps. Otherwise enter the below into a terminal window:
|
1 2 |
curl http://pear.php.net/go-pear.phar > go-pear.php sudo php -q go-pear.php |
It will ask you to enter a new installation base ($prefix). I recommend you use /usr/local
Configuring PHP include path
Edit /etc/php.ini and find the line: ;include_path = ".:/php/includes". Uncomment it (remove the ; at the beginning) and add the PEAR path to it. It should end up looking similar to the below:
|
1 |
include_path = ".:/usr/lib/php/pear" |
Update PEAR
Now to update the install enter the 3 commands below into the terminal window:
|
1 2 3 |
sudo pear channel-update pear.php.net sudo pecl channel-update pecl.php.net sudo pear upgrade-all |
Install PHPUnit
Just for good measure you will probably also want to install PHPUnit, if you do then execute the below command and your ready to go.
|
1 2 3 4 |
sudo pear channel-discover pear.phpunit.de sudo pear channel-discover pear.symfony-project.com sudo pear install pear.phpunit.de/PHPUnit sudo pear install phpunit/DbUnit --alldeps |
Install MySQL 5.1 Server on OSX Lion
So I had to get MySQL set up on my OSX Lion MacBook Pro after the recent format and upgrade to Lion. It was easier than i expected but I thought that it was still worth a post anyway.
First off, head over to the MySQL site and download the Mac pre-compiles binary of MySQL Community Server 5.1.x (the latest download says it's for OSX 10.6 Snow Leopard but it works fine with 10.7 Lion). Download the latest DMG available, this can be found here http://dev.mysql.com/downloads/mysql/5.1.html.
When the download finishes, open the disk image and install the main package file (mysql-5.1.xx-osx10.6-x86_64.pkg), when that finishes double-click on the preferences pane (MYSQL.prefpane file) file to install that into the System Preferences menu. If you would like the database server to start on boot then you also need to install the MySQLStartupItem.pkg file.
Once this is done you can then open System Preferences and under the "Other" heading you will find your new MySQL preferences, from here you can start and stop the server and also enable/disable startup option.
Now if you are going to us mysql from terminal then you will want to add the mysql binaries path to your $PATH shell variable. To do this edit your .bash_profile file and add /usr/local/mysql/bin to the PATH variable. Your file might look like this:
|
1 |
export PATH=~/bin:/usr/local/bin:/usr/local/mysql/bin:$PATH |
When all the above is done you can start setting up the server. We now need to secure the server by setting some defaults and removing some test stuff, to do this open a terminal and run:
|
1 |
sudo /usr/local/mysql/bin/mysql_secure_installation |
It will ask for your password (because of sudo) and then will ask you some questions about changes it wishes to make. Enter a password for root and then you can accept the defaults for the rest of the questions if you are unsure.
One last thing, if you intend to use MySQL with PHP then you will need to update your php.ini file to change the location that is set for the mysql.sock file. Open php.ini and find and replace /var/mysql/mysql.sock with /tmp/mysql.sock. This is because the MySQL default location for the mysql.sock file is in /tmp
Hope it helps
Apache SSL on Mac OSX Lion 10.7
I have recently upgraded to OSX Lion from Snow Leopard, whilst setting up my development environment I needed to configure the built in Apache server to support SSL. Below are instructions on what needed to be done. Please note that the below is based on a clean install of OSX 10.7.2 and if you did an upgrade or are running a different version of Lion then the instructions below may need to be tweaked to suit your setup.
Generate a host key
First off we'll make a home for the new SSL files. I used /private/etc/apache2/ssl. We need to change to the new directory and then run a ssh-keygen command to create the server key file. Open up a terminal window and enter the commands below.
|
1 2 3 |
mkdir /private/etc/apache2/ssl cd /private/etc/apache2/ssl sudo ssh-keygen -f server.key |
Generate a certificate request file
This command creates a certificate request file. A certificate request file contains information about your organisation that will be used in the SSL certificate. You will be asked various questions, fill these in as appropriate or leave blank. Please note that you shouldn't set a pass phrase on the certificate, just leave this blank when it asks for a pass phrase.
|
1 |
sudo openssl req -new -key server.key -out request.csr |
Create the SSL certificate
Create a self signed SSL certificate using the request file.
|
1 |
sudo openssl x509 -req -days 365 -in request.csr -signkey server.key -out server.crt |
Configure Apache
Create a backup of /private/etc/apache2/httpd.conf.
In /private/etc/apache2/httpd.conf, make sure the SSL module is enabled (remove the # from the start of the line)
|
1 |
LoadModule ssl_module libexec/apache2/mod_ssl.so |
In the same file search for the below line and uncomment it (remove the #)
|
1 |
Include /private/etc/apache2/extra/httpd-ssl.conf |
Edit /private/etc/apache2/extra/httpd-ssl.conf, search for the lines that start with SSLCertificateFile, SSLCertificateKeyFile and update them to match the below:
|
1 2 |
SSLCertificateFile "/private/etc/apache2/ssl/server.crt" SSLCertificateKeyFile "/private/etc/apache2/ssl/server.key" |
In the same file comment out (add a # to the beginning of the line) the lines that start with SSLCACertificatePath and SSLCARevocationPath
Configure the vhosts
In /private/etc/apache2/httpd.conf, search for the below line and uncomment it (remove the #)
|
1 |
Include /private/etc/apache2/extra/httpd-vhosts.conf |
Now open /private/etc/apache2/extra/httpd-vhosts.conf and add the line below under the port 80 NameVirtualHost directive
|
1 |
NameVirtualHost *:443 |
Now you can configure a basic SSL vhost by adding the code below to the end of the file. Please note that for the DocumentRoot you should replace it with a real path.
|
1 2 3 4 5 6 7 8 |
<VirtualHost *:443> SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile /private/etc/apache2/ssl/server.crt SSLCertificateKeyFile /private/etc/apache2/ssl/server.key ServerName localhost DocumentRoot "/some/website/directory/" </VirtualHost> |
Check the config and restart Apache
|
1 2 |
sudo apachectl configtest sudo apachectl restart |
Now you can open your browser and try out your new HTTPS site
