No TCPIP on mysql using Zend

Over the last few weeks I have been evaluating Zend Studio used in conjunction Zend Server CE on my Mac Book in order to improve debugging of my php / wordpress sites.

As I already had an installation of MySQL and used MySQL Workbench to administer it I was getting a little confused when using phpMyAdmin as provide by Zend Server CE and seeing a different set of databases.

I soon realised that I had 2 installations of MySQL, my original using TCPIP/3306 and a new Zend Version using Unix Sockets (tcpip disabled).  This was not really practical for me. So my solution was to remove my original installation and enable tcpip on my Zend version. THIS DESTROYED my original databases, which was not an issue for me as I had them backed up.

Once the original was uninstalled, I rebooted and verified the Zend version with phpMyAdmin and also from the command line with mysql.

Enabling TCPIP in MySQL Zend Edition

The configuration file for mySQL on my Mac was located at

/usr/local/zend/mysql/data/my.cnf

Unfortunately the data folder was locked as shown below

Robs-MacBook-Pro:mysql rob$ ls -l

total 0
drwxr-xr-x  49 root  wheel  1666 13 Dec 19:16 bin
drwxr-x—  13 zend  wheel   442 31 Dec 08:10 data
drwxr-x—   6 root  wheel   204  4 Sep 14:36 data.dist
drwxr-xr-x  23 root  wheel   782 13 Dec 19:16 lib
drwxr-xr-x   3 root  wheel   102 13 Dec 19:16 scripts
drwxr-xr-x  13 root  wheel   442 13 Dec 19:16 share
drwxr-xr-x   3 zend  wheel   102 31 Dec 08:10 tmp

So first I need to unlock the data folder using chmod

sudo chmod 777 data

Now I was able to enter the data folder and open my.cnf for editing. Personally I use textwrangler to edit as I like the ‘hidden’ option which allows my to navigate to folders usually hidden my MacOSx.

The only minor change here was to comment out the line below, thus enabling TCP/IP the same file already defined the default port of 3306, which was fine in my case.

#skip-networking

As a last step I switched the security back on for the data folder, as shown below then verified it with ls -l

sudo chmod 750 data

Again I restarted mySQL and now can happily connect to the MySQL databases using Workbench, phpMyAdmin and the command line.

Posted in Uncategorized | Tagged , | Leave a comment

MySQL not starting after Zend install

Whilst playing with Zend Server Community Edition trying to get mySQL to work I found myself at a point where mySQL would not start.

sudo zendctl.sh start-mysql
Starting MySQL
. ERROR! Manager of pid-file quit without updating file.

I had tried removing ZEND Server completely as documented on the Zend site. At best this is a bit vague.

  • Stop all Zend Server processes
  • Delete all Zend Server installed files
  • Remove the .app from /Applications
  • Remove Zend users

No matter what I did I always got the same error after re installing.  So after looking round the file structure I tried running a script called uninstall located in the Zend bin folder.  This asks a few questions but after completing the process and re installing, then all now seems to work :-)


Robs-MacBook-Pro:bin rob$ sudo /usr/local/zend/bin/uninstall.sh
Are you sure you wish to completely remove Zend Server? [yes|no]
yes
Stopping Zend Server 5.5.0 ..

httpd: Could not reliably determine the server's fully qualified domain name, using Robs-MacBook-Pro.local for ServerName
/usr/local/zend/bin/apachectl stop [OK]
Stopping Zend Server GUI [Lighttpd] [OK]
ERROR! MySQL manager or server PID file could not be found!
Stopping Java bridge [OK]

Zend Server stopped.
/usr/local/zend/apache2/htdocs and /usr/local/zend/mysql will be removed during this operation, if you wish to backup your PHP code and MySQL DBs,
please do so now and type "cont" to continue.
cont
Robs-MacBook-Pro:bin rob$

Posted in Uncategorized | Tagged , | Leave a comment

Zend Apache and Virtual Hosts

Over the last few months I have spent more time getting in to php development, this has been mainly for WordPress themes thou I also have written a few simple Web Services. Whilst the live versions of these are hosted externally I like to be able to develop on my laptop disconnected from the internet, eg whilst traveling on trains. This mean I have configured a number of sites using virtual hosts on my laptop.

Working with .Net developers who use Visual Studio my biggest frustration is issues I have is the pain in debugging PHP code, having to put excessieve manual code and logging which can be time consuming.  Thou I do include logging for general fault finding.  What I was missing was the ability to step through code in a similar fashion to Visual Studio.  After some research I discovered that Zend Server CE (free) in conjunction with Zend Studio (€299) appears to do this.

So with a 30 day trial of Zend Studio installed I decided to set up an environment on my laptop with the hope it would deliver, and I would then justify the €299 spend against the time I will save.

So this article discusses how I configured Apache under Zend to use the default port of 80 with host headers on my MacBook Pro running MacOSx 10.7 (Lion). The first thing to be aware of is that the Zend Server CE install, installs its own version of Apache under /usr/local/zend/apache2 so it is highly likely that you already have a default version under /private/etc/apache2.  In addition it installs its own light wieght web server for the administrive web site, so you can access the config via a browser even with Apache stopped.

Adding Zend to the Path

To make things easier and allow your system to find the Zend executables and scripts add the Zend Bin folder to the Path.

The Path file is located at /private/etc/paths

Now add the line /usr/local/zend/bin

Apache httpd.conf changes

Set the port number

The Apache config file httpd.conf for the Zend installation is installed at /usr/local/zend/apache2/conf/httpd.conf. I recommend you first make a back of this either from the command line using

sudo cp httpd.conf http.conf.org

or just using ‘Save As’ with a Gui based tool such as Textwrangler.

At around line 40, comment our the original line enabling port 10088 and add a line for port 80 as shown below

40
41
#Listen 10088
Listen 80

Change the Documents Folder

In this example my Sites folder is under my user name of rob. This should be changed to your username in the examples below.

105
106
#DocumentRoot "/usr/local/zend/apache2/htdocs"
DocumentRoot "/Users/rob/Sites"

Also change the documents folder as shown below, again I just comment out the original line at 134, the rest of the listing is just shown for completeness.

132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#
# This should be changed to whatever you set DocumentRoot to.
#
#<Directory "/usr/local/zend/apache2/htdocs">
<Directory "/Users/rob/Sites">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks
 
    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride All
 
    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all
 
</Directory>

Enabling the Virtual Host file

Finally uncomment the include statement for the virtual host file.

391
392
# Virtual hosts
Include conf/extra/httpd-vhosts.conf

Now exit and save the httpd.conf file

Adding Virtual Host Entries

Next we need to edit the file enabled in the previous section, backup then open the file /usr/local/zend/apache2/conf/extra/httpd-vhosts.conf

Set the port number

First change the port number that Apache will use in the virtual host file from 10088 to 80

391
392
#NameVirtualHost *:10088
NameVirtualHost *:80

Add your site entries

Now we need to disable or delete the 2 default site entries provided by Zend and add our own entries. The example below shows the original entries just commented out and my 3 new sites added to the end

28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#<VirtualHost *:10088>
#    ServerAdmin webmaster@dummy-host.example.com
#    DocumentRoot "/usr/local/zend/apache2/docs/dummy-host.example.com"
#    ServerName dummy-host.example.com
#    ServerAlias www.dummy-host.example.com
#    ErrorLog "logs/dummy-host.example.com-error_log"
#    CustomLog "logs/dummy-host.example.com-access_log" common
#</VirtualHost>
 
#<VirtualHost *:10088>
#    ServerAdmin webmaster@dummy-host2.example.com
#    DocumentRoot "/usr/local/zend/apache2/docs/dummy-host2.example.com"
#    ServerName dummy-host2.example.com
#    ErrorLog "logs/dummy-host2.example.com-error_log"
#    CustomLog "logs/dummy-host2.example.com-access_log" common
#</VirtualHost>
 
<VirtualHost *:80>
    ServerAdmin rob.langley@me.com
    DocumentRoot "/Users/rob/Sites/intranet"
    ServerName localhost
    ServerAlias intranet
    ErrorLog "/Users/rob/Sites/logs/intranet_error_log"
    CustomLog "/Users/rob/Sites/logs/intranet-access_log" commonvhost
</VirtualHost>
 
 
<VirtualHost *:80>
    ServerAdmin rob.langley@me.com
    DocumentRoot "/Users/rob/Sites/helloWorld"
    ServerName localhost
    ServerAlias hello
    ErrorLog "/Users/rob/Sites/logs/hello_error_log"
    CustomLog "/Users/rob/Sites/logs/hello-access_log" commonvhost
</VirtualHost>
 
 
 <VirtualHost *:80>
    ServerAdmin rob.langley@me.com
    DocumentRoot "/Users/rob/Sites/florida-paradise-villas (Wordpress)"
    ServerName localhost
    ServerAlias fpv
    ErrorLog "/Users/rob/Sites/logs/fpv_error_log"
    CustomLog "/Users/rob/Sites/logs/fpv-access_log" common
</VirtualHost>

You will see in my config above I use server aliases such as fpv and hello so I can access my local sites with http://fpv and http://hello. In order for these addresses to resolve to localhost you need to add them to your host file located at /private/etc/hosts

12
13
14
15
16
#Custom Settings - R Langley
# web sites
127.0.0.1	intranet
127.0.0.1	fpv
127.0.0.1	hello

Auto Starting Zend Apache

The final step is ensure the Zend Version of Apache starts as opposed to the default Mac version. This is to prevent confusion and also a conflict as they are now both configured to use port 80.

I achieved this by effectively repointing the default apachectl to the Zend version of Apache so when the system start Apache it starts Zend version as opposed to the default.

First stop the current version of apache if its still running

apachectl stop

Next you need to move the current version to a safe place in case you need it in the future. The file is located at /usr/sbin/apachectl and can be moved with

sudo mv /usr/sbin/apachectl /Users/rob/SafePlace

Where ‘rob’ above is my personal user folder and should be changed to yours or an alternate location.

Now with the original version of the file removed we can create a link too Zend

cd /usr/sbin
sudo ln -s /usr/local/zend/apache2/bin/apachectl ./

Now you should be able to start the new version of Apache with

apachectl start
Posted in Uncategorized | Tagged , , | Leave a comment

Windows 7 not seeing allocated diskspace

I have a virtualised version of Windows 7 Ultimate running on my Macbook Pro under VMware Fusion 4. The C drive having 50Gb was becoming quite full so I shut down the VM and allocated an additional 20Gb. After restarting I went in to disk manager and disk tools and saw the new partition was now 70Gb and fully extended, however if I right clicked the actual C drive it reported only 50Gb. Looking in the actual VM package from my Mac I could see the appropriate number of 2Gb vmdk files totalling 70Gb. This seemed very strange so I tried updating vmware tools, running chkdsk, rebooting all without success. In the meantime I allocated another 15Gb but still the actual C drive reported 50Gb in explorer but now disk manager report 85Gb.

I discovered that the ‘extend filesystem’ command in diskpart fixes this.


>diskpart

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 85 GB 0 B

DISKPART> select disk 1

The disk you specified is not valid.

There is no disk selected.

DISKPART> list disk

Disk ### Status Size Free Dyn Gpt
-------- ------------- ------- ------- --- ---
Disk 0 Online 85 GB 0 B

DISKPART> select disk 0

Disk 0 is now the selected disk.

DISKPART> list partition

Partition ### Type Size Offset
------------- ---------------- ------- -------
Partition 1 Primary 84 GB 1024 KB

DISKPART> select partition 1

Partition 1 is now the selected partition.

DISKPART> list volume

Volume ### Ltr Label Fs Type Size Status Info
---------- --- ----------- ----- ---------- ------- --------- --------
Volume 0 D DVD-ROM 0 B No Media
* Volume 1 C NTFS Partition 84 GB Healthy System

DISKPART> select volume 1

Volume 1 is the selected volume.

DISKPART> extend filesystem
DiskPart successfully extended the file system on the volume.

DISKPART>

Posted in Uncategorized | Tagged , | Leave a comment

Setting up Apache after Lion 10.7 Install

I have just bought a new 256Gb SSD for my Mac Book Pro to upgrade my 128Gb SSD which I installed some months ago to have a test of SSD and performance (its awesome). I took this opportunity to perform a CLEAN install of OSx Lion 10.7 leaving my original SSD in a USB caddie with 10.6 (Snow Leopard).

On my old disk I ran several development sites using Apache / PHP / MySQL using a combination of the hosts file and virtual hosts in Apache.

This blog documents the process I went through in migrating my sites from a Snow Leopard (10.6) to a new clean installation of Lion (10.7).

Tasks on Lion 10.7 Installation

First I enabled ‘Web Sharing’ under system preferences, and tested I could access http://localhost from a browser.

Next I copied my original files under /volumes/ssd/users/rob/sites to the new disk at /volumes/ssd240/users/rob/sites where rob is my user folder.

Then I backed up the default host file located in /private/etc/ and added my own aliases such as those shown below.

127.0.0.1 bizziebee
127.0.0.1 intranet

Lion seems to have a higher level of file security on file system so I had to change this on a few of my files in order to be able to modify the key configuration files in apache.  So using terminal I modified the following.


cd /private/etc/apache2
sudo chmod u+w httpd.conf

cd /private/etc/apache2/extra
chmod u+w httpd-vhosts.conf

Using textwrangler which allows you to view hidden files, I opened my original httpd-vhosts.conf file and merged it into the new version. Note as my new disk had a new Volume label I had to rename these from SSD to SSD240


<VirtualHost *:80>
ServerAdmin rob.langley@me.com
DocumentRoot "/Volumes/SSD240/Users/Rob/Sites/intranet"
ServerName localhost
ServerAlias intranet
ErrorLog "/Volumes/SSD240/Users/Rob/Sites/logs/intranet_error_log"
CustomLog "/Volumes/SSD240/Users/Rob/Sites/logs/intranet-access_log" common
</VirtualHost>

Next we need to modify the default httpd.conf file.

  1. Enable PHP support by deleting the leading # around line 111
  2. LoadModule php5_module libexec/apache2/libphp5.so

  3. Enable Virtual hosts by deleting the leading # around line 626
  4. Include /private/etc/apache2/extra/httpd-vhosts.conf

Now lets restart apache and test our settings so far. From terminal type.
sudo httpd -k restart

MySQL Migration

First I installed a new copy of MySQL Community followed by MySQL Workbench to administrate it.  Both these installations were simple and straight forward but my machine did require a reboot in order to start mysql.

Copying Configuration from MySQL workbench

Obviously my new installation of MySQL workbench did not have any of the original connections or server instances.  So rather than have to remember them all I copied two xml files from my orignal disk.  The xml files were located as follows.

/Volumes/SSD/Users/Rob/Library/Application Support/MySQL/Workbench/connections.xml
/Volumes/SSD/Users/Rob/Library/Application Support/MySQL/Workbench/server_instances.xml

Copying MySQL xml filesNow start MySQL workbench to find all your saved connections :-)

Your local databases can now be exported from your original installation by booting into your original disk and creating and export (dump) and saving the file in a common location.  I actually created one dump for all my schemas and this seemed to work.  Then start you new OS (Lion) and import these files  in to your new MySQL installation.

MySQL Sockets

It appears that the location of mysql.sock has moved in Lion from var/mysql/mysql.sock to tmp/mysql.sock  This is defined in /private/etc/php.ini.  Unfortunately this file also appear to have been renamed to php.ini.default.  So….

  • Stop the web server ‘sudo apachectl stop’
  • copy php.ini.default to php.ini
  • Edit php.ini and Search and Replace ‘var/mysql/mysql.sock’ to ‘tmp/mysql.sock’
  • Restart the web server ’sudo apachectl start’

Thanks to Brian Chans blog for the info on mysql.sock

Thats it, I now have my sites running under Lion.  I hope this may be of some help to some people.

Posted in Uncategorized | Tagged , , , | Leave a comment

PHP Webservice and MySQL

In this post I will document some recent research I did in writing a basic PHP SOAP Web Service to return a set of data from a MySQL database.  Having recently purchased an iPad I wanted to write an application for personal use which will query an existing MySQL database.  Therefore I researched and developed this code standlone on my Mac Book Pro running the default install of Apache and a download of MySQL.

The first thing I did is wrote a basic Stored Routine using MySQL Workbench to return a set of data.

CREATE DEFINER=`root`@`localhost` PROCEDURE `sr_RetrieveBasicBookingDetailsList`(IN days int)
BEGIN
SELECT b.bookingRef, b.customerId, CONCAT_WS(' ',c.lastname, c.firstname) as customerFullName, b.state, b.startDate, b.endDate, b.bookingDate, b.totalCost, 0 as Owing
FROM bookings as b
INNER JOIN client c on b.customerId = c.customerId
WHERE startDate &gt; DATE_SUB(now(), INTERVAL days DAY)
ORDER BY startDate ASC;
END

The inner workings of the above stored routine does not really matter except to say that you can pass it a single integer value which represents the number of days.  The Stored Routine then returns a set of data based on this value.  With the Stored Routine written and tested it was time to move on to writing my the PHP Web Service.  In order to simplify development I chose to use the library nusoap which is available at SorceForge

Line 1 – 3: Define library location for NUSoap and also config location for global variable such as Database credentials.

Line 4 -9: Create SOAP object and define namespace.

Line 10-30: Create an complex dataType called bookingBasicDetail to each booking record returned from the database

Line 33-45: Create an array to be returned by the web service, is an array of bookingBasicDetails so will contain the complete dataset returned fromt the database.

Line 48-58: Now define the actual web service.

Line 59: Define function to be called by webservice

Line 60-67: Open a database connection and return a soap fault if there is an error such as bad password or database not found.

Line 69-73: Call Stored Routine passing in the single integer value ‘days’. Return a Soap Fault if anything errors.

Line 78-96: Iterate through each rowset returned by stored routine, mapping the columns (fields) to variables within the array. For example startDate is the 5th field in the rowset returned.

Line 98-101: Close database and return results from function to web service.

Line 104 – 105: Set up HTTP for web service

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
<?php
	require_once('../config.php');
    require_once('../lib/nusoap.php');
    // Create the server instance
    $server = new soap_server();
 
    // Initialize WSDL support
    $server->configureWSDL('villaQuoter.bookings', 'urn:villaQuoter.bookings');
 
 
	//Define a STRUCT for 'simple quote details' conatins a minimum set of fields including:
	//	state, bookingRef, customerId, startDate, endDate, bookingDate, Customer Full Name, Total Cost, Amount Owing    	
    $server->wsdl->addComplexType(
    	'basicBookingDetails',		//Name of Type
    	'complexType',				//Type Class (Complex)
    	'struct',					//php Type (Struct)
    	'all',						//Compisitor??
    	'',							//Restriction Base
    	array(
			'state' => array('name' => 'state', 'type' => 'xsd:int'),
    		'bookingRef' => array('name' => 'bookingRef', 'type' => 'xsd:string'),
    		'customerId' => array('name' => 'customerId', 'type' => 'xsd:string'),
    		'customerFullName' => array('name' => 'customerFullName', 'type' => 'xsd:string'),
    		'startDate' => array('name' => 'startDate', 'type' => 'xsd:string'),
    		'endDate' => array('name' => 'endDate', 'type' => 'xsd:string'),
    		'bookingDate' => array('name' => 'bookingDate', 'type' => 'xsd:string'),
    		'totalCost' => array('name' => 'totalCost', 'type' => 'xsd:string'),
    		'amountOwing' => array('name' => 'amountOwing', 'type' => 'xsd:string')
    	)		
    );
 
 
	//Create an ARRAY of data type BasicBookingDetails (this will be returned by the Web Service)
    $server->wsdl->addComplexType(
    	'arrBasicBookingDetails',		//Name of Array
    	'complexType',					//Type Class (Complex)
    	'array',						//Php Type (Array)
    	'',								//Compistor??
    	'SOAP-ENC:Array',				//Restriction Base
    	array(),
    	array(
    		array('ref' => 'SOAP-ENC:arrayType', 'wsdl:arrayType' => 'tns:basicBookingDetails[]') //link back to complexType via namespace
    		),
    	'tns:basicBookingDetails'
    );
 
 
    //Define Web Service
    $server->register('ws_retrieveBasicBookingDetailsList',
    	array('history' => 'xsd:int'),											//Input Parameters (Integer: Days)
    	array('return' => 'tns:arrBasicBookingDetails'),						//Output Paraemters, an Array of BasicBookingDetails
    		'urn:villaQuoter.bookings',											//Namespace
	        'urn:villaQuoter.bookings#ws_retrieveBasicBookingDetailsList',   	//soapaction
    		'document',																//style  rpc or document
    		'literal',															//use encoded or literal
    		'This method returns basic details for bookings / quotes, define number of days of history to return. 0 = future only.'	//documentation	
    	);
 
	function ws_retrieveBasicBookingDetailsList($days)
	{// Called by Web Service of Same Name.
    	$link=mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME);
    	if(mysqli_connect_errno())
    	{	
    		//Raise SOAP Fault if Database Connection fails
			return new soap_fault('SQL-ERROR: '.mysqli_connect_error());
    	}
 
 
		$result = $link->query("call sr_RetrieveBasicBookingDetailsList(".$days.")");
		if(mysqli_errno($link))
		{	
    		//Raise SOAP Fault if Stored Routine Call Fails
			return new soap_fault('SQL-ERROR: '.mysqli_error($link));
    	}
 
 
 
		//Create bookings array (holds multiple bookings of STRUCT Type basicBookingDetails	
		$bookings = array();
 
 
		while($row = mysqli_fetch_row($result))
		{// Loop throu each booking and Load into 'bookings' array
			$booking = array(
	 			bookingRef => $row[0],
	 			customerId => $row[1],
	 			customerFullName => $row[2],
	 			state => $row[3],
	 			startDate => $row[4],
	 			endDate => $row[5],
	 			bookingDate => $row[6],
	 			totalCost => $row[7],		
	 			amountOwing => $row[8]
			);
	  		$bookings[] = $booking;
		}
		//Close Database Connection (results now in $bookings array)
		mysqli_close($link);
 
	return $bookings;
	}
 
 
    $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : '';
    $server->service($HTTP_RAW_POST_DATA);
?>

Posted in Uncategorized | Tagged , , , , , | Leave a comment

Useful commands on a MAC

Below are a few commands I need to use on an adhoc basis, they are blogged here mainly for my own personal reference, but my help others

To restart apache from the command line type

sudo httpd -restart

To view network settings including IP address, MAC address, DNS etc from the command line (terminal) type

ifconfig

Changing MAC Address

Occasionally I have the need to temporally change my MAC address.  The following command achieves this.  However in order for this to be successful the order of events are important.  The steps assume you are using WiFi as opposed to a cabled ethernet, thou I suspect the process is very similar.

  • Turn you WiFi off
  • Disable ‘Auto Join’
  • Re-enable WiFi.
  • Once the appropriate WiFi connection is detected type the following before before joining the network. (choose the required mac address)

sudo ifconfig en1 ether 1a:12:61:ff:aa:91

  • Type the following to verify the new MAC address.

ifconfig

  • Join the appropriate Network

Re-index Spotlight

On occasion my spotlight index appear to have become corrupted and results are no longer returned.

Turn indexing on, on the root folder.

sudo mdutil -i on /

Rebuild index

sudo mdutil -E /

Showing Hidden Files in Finder

On occasion you need to view hidden files, I recently needed this when search for filezilla.xml in order to copy my config between machines.

To view hidden files

defaults write com.apple.Finder AppleShowAllFiles TRUE

killall Finder

To re-hide hidden files

defaults write com.apple.Finder AppleShowAllFiles FALSE

killall Finder

 

Posted in Uncategorized | Tagged , | Leave a comment

HTC Wildfire, Android and Address Book Syncing

A few days a go my parents decided to ditch their 20th century phones and took a trip to a high street phone shop to purchase a new ‘smart’ phone.  After visiting them last night I discovered they thought it was far from smart.  With various issues they have so far spent 2 hours in the shop, 2 hours on telephone support fortunately this was to a freephone number.

Address Book Issues

Using Yahoo Mail on HTC Wildfire with Android
So last night I was tasked with sorting their address book.  On the phone they appeared to have many contacts duplicated, they accepted this as some had come from the original phone sim and some from there Yahoo email address book.  But they were getting increasingly frustrated as they just could not seem to reliably delete and merge them.  They would delete a contact and a short while later it would be back again.  Then other contacts would appear in the ‘HTC People’ list but on clicking Menu and Delete they were not listed and so could not be deleted.   Being an iPhone user and not familiar with Android I spent a further 2 frustrating hours trying to resolve this  before finally getting to the bottom of this.

I discovered a few things.

  1. The shop assistant had copied there SIM contact to the HTC Wildfire phone
  2. The shop assistant also installed and setup Yahoo mail on from the Android store.
  3. The telephone support people had set up HTC Sync and sync these phone contacts to Windows Contacts.
  4. All contacts are shown in HTC People, but it does not seem obvious where they came from eg SIM, Windows Contacts or Yahoo.
  5. When you try and delete a contact on the phone that originated from Yahoo contacts, these are not displayed, this can be frustrating when you can’t work out why you can not delete certain contacts.
  6. If you delete a phone contact that is also in Windows Contacts it is not deleted from Windows Contacts and can in some cases syncs back to the phone.  arghhhh.

So after working out how it all seemed to work, we decided we only need one master list and all contacts should be maintained from this list.  This could either be Windows Contacts or Yahoo Mail as they already used Yahoo mail it made sense to use this as the master for their HTC Wildfire phone.  So we did the following.

  1. Ensured any contacts that were on the phone / in windows contacts where also in Yahoo Mail or were not needed.
  2. Deleted all contacts from Windows Contacts on the PC, Sync’ed the changes with HTC Sync and observed that these individual contacts were removed from HTC People.
  3. Connect USB cable but select ‘Charge Only’ on HTC screen NOT HTC Sync
  4. Disabled ‘Contact Sync’ing’ in Yahoo Mail / Menu / Options / [email account].  Acknowledge the warning about the contacts will be deleted from phone.  At this point there were now only a hand full of default contacts and groups on the phone.
  5. Re-enabled Yahoo Mail ‘Contact Sync’ and observed that the contacts appeared in the HTC People list after about 1 hour.

With Yahoo Mail now as thier master address book they find it much simpler editing the address lists in an environment they are familiar with and the contacts ‘magically’ appear on the phone.  It is important to realise the Sync is done over the wire and not OTA (over the air).

Posted in Uncategorized | Tagged | Leave a comment

Scripting the addition of a new DNS Server entry

I’m currently migrating a number of Virtual Machines between hosts and also to a new Active Directory domain.  For various reasons the DNS entries are manually configured as opposed to using DHCP.  One thing I found myself doing was manually adding the new DNS entries so the machines could resolve names in an alternate domain that has no trusts at a AD level.  I had already written a simple script to copy on some basic command line utilities such as grep and awk as well add various groups to the Remote Desktop Group.  However I found myself manually adding the new DNS server to the IP settings.

However after a quick Google I found the following useful command ‘netsh’ where 10.1.1.26 is the IP address of the server you want to add.

netsh interface ip add dns “Local Area Network” 10.1.1.26

By default it adds this server to the end of the DNS server list so you not need to worry about over writing other entries. However you can specify the position by adding index=x where x is the position.

Posted in Uncategorized | Tagged | Leave a comment

WordPress needs to access your webserver

The error you may get when trying to install a WordPress plugin running natively on Mac OSxI have been working with WordPress for a few months now, and have been developing my sites on my MacBook Pro whilst traveling to work on the train.

I have apache running and using a combination of host file entries and apaches virtual hosts file I can have a number of sites running from my laptop for development purposes.  My main issue has been installing plugins and upgrading wordpress, when ever I tried to do this I found I got prompted for FTP details.  I was never quite sure why it need my ftp details as I was sure my live installations have no record of the actual ftp security credentials, yet they work fine.  So after several sessions on Google I found the excellent article by Chris Abernethy explaining why wordpress needs this.  It turns out the fileowner of the WordPress website files need to be the same as the account that apache is running under.  In the case of Mac OSx 10.6.7 this user is _www

So by opening a terminal window and navigating to my ‘Sites’ folder I could set the owner for the specific website concerned.

sudo chown -R _www websiteFolder

Now my plugin’s install via the GUI in the same way they do on my live production servers.

Posted in Uncategorized | Tagged , , | Leave a comment