Local Hosting in Mac OS X 10.4 Tiger
The first thing I needed to do, after seamlessly porting all my files and applications from an iBook running Panther to a MacG5 running Tiger, was to install the applications that would complete my local hosting environment using the pre-installed Apache webserver. Noticably missing were the MySQL databases stored at /usr/local/mysql/data. In fact, the /usr/local directory did not exist. One very important item, if you are thinking of updating your OS from Panther to Tiger, backup your data or it will all be gone when the OS X upgrade is completed.
MySQL
According to most of the reports I found, an installation of MySQL 4.1.12 from the available Mac OS X v10.3 installer package at dev.mysql.com would work in Tiger with no problem. I ignored the warnings about the 4.0 and 4.1 password encryption problems as I am trying to duplicate the same hosting environment as my webhost, Textdrive, and I have already overcome that hurdle.
I enabled the root user by going to Applications > Utilities > NetInfoManager and selecting “Authenticate” from the “Security” menu. Once authenticated, select “Enable Root User” and enter a password for the root user.
I downloaded the MySQL 4.1.12 Installer Package for Mac OS X v10.3. Following the instructions at Marc Liyange’s site enabled me to quickly get the MySQL server up and running.
PHP
By default, the PHP module is not enabled. To enable the PHP module, I could have followed the instructions at taoofmac.com. However, I realized that, contrary to what I read at one site, Tiger does not include PHP 5, but PHP Version 4.3.10. For an installer package of PHP 5, I would need to visit Marc Liyanage’s site, yet again. So I downloaded the PHP 5.0.4 for Apache 1.3 on Mac OS X 10.3 from Marc’s site.
MySQL Admin Tools
phpMyAdmin
I downloaded phpMyAdmin 2.6.2-pl1 and copied the contents to /Library/WebServer/Documents/phpMyAdmin. I set the configuration settings in the phpMyAdmin/config.inc.php file. Then I was able to navigate to http://localhost/phpMyAdmin/ to check whether I was able to connect to the MySQL databases.
MySQL Administrator
Interestingly, MySQL Administrator for Mac OS X is no longer available from mysql.com, leading me to believe that the link may have been removed because of possible concerns over installation in Tiger, but that is just a guess. All I really know is that many sites link to a download page for Administrator for Mac where no such download link exists.
CocoaMySQL
One nice application for managing MySQL databases is CocoaMySQL. But, apparently, the application has a problem with version 4.1 passwords. A fix was posted on macosxhints.com with a link to a modified version of CocoaMySQL. I can attest that it does work with MySQL 4.1.
Connecting to the local server is quite simple, but connecting to a remote host requires a means of opening a secure tunnel to the host server. On the TextDrive forum, a discussion about remote connections through CocoaMySQL provided interesting information about another application that may come in handy: SSH Tunnel Manager. The connection settings can be modified from those shown in the screenshot at this post on the TextDrive forum.
Subversion
To download the latest revision from the Textpattern subversion repository, I would need Subversion installed on my server as well. Instructions for using Subversion to checkout the code are in Dean Allen’s post on the release of Txp 1.0 RC3. For a Mac OS X Package of Subversion, go to the Mac OS X downloads page on the Metissian site.
Backing Up the Databases
Next, I needed to transfer the databases from the iBook to the MacG5. One option would be to dump the databases to an SQL query file and import them through a MySQL admin tool. Another option would be to save the databases as a tar) archive and dearchive them into the appropriate directory. By modifying Marc Liyanage’s instructions for updating a MySQL installation, I can do just that.
1. Type the following into a terminal window on the iBook to save the old data
cd /usr/local/mysql sudo tar -cvf /Users/user-account-name/Desktop/mysql-data.tar data
2. Copy the file to the root directory of the MacG5 hard drive.
3. Unpack the files into the MySQL data directory on the MacG5
cd /usr/local/mysql sudo tar -xf mysql-data.tar sudo chown -R mysql /usr/local/mysql/data/*
Re-establishing the Virtual Hosts
The last step would be to copy the Apache configuration file and the hosts file to re-establish the virtual hosts so I can be working on websites locally as if the sites were live, but they only exist on my local machine.
Local Hosting on Mac OS X
When I start to develop a site, I change the Apache WebServer configuration files /etc/hosts and the /etc/httpd/httpd.conf to add a fake URL to my local hosting environment, so I can do all my testing on my local server using URLs relative to the root directory of the site. Then, when I upload the files to the hosting server, it’s just a matter of changing the config.php file settings and the “Site URL”, “Temp folder” path “File Upload Path” in the Textpattern > admin > preferences section. If, for instance, you wanted to create a directory in /Library/WebServer/Documents/mattmikulla_dev and be able to access it in your browser as http://dev.mattmikulla.site/ you could change your server config settings (this assumes you have PHP and MySQL installed on your Mac):
Modify the “hosts” file
In Terminal type to change directory to ”/etc”:
cd /etc
Authenticate to launch the PICO text editor (or NANO in Tiger)
sudo pico
To read file in PICO:
^R
Insert file from home directory:
hosts
Insert your fake domain name so that the file looks something like this:
127.0.0.1 localhost 127.0.0.1 dev.domain-name.site 255.255.255.255 broadcasthost ::1 localhost
Close PICO
^X
Modify the “httpd.conf” file
Go to ”/etc/httpd”
cd /etc/httpd
Save file as another name as backup
sudo cp httpd.conf httpd.conf.050528
Launch PICO again
sudo pico
Read file
^R
File name to read
httpd.conf
Go to the end of the file and type the following:
NameVirtualHost 127.0.0.1<VirtualHost 127.0.0.1>
ServerName localhost DocumentRoot /Library/WebServer/Documents </VirtualHost><VirtualHost 127.0.0.1>
ServerName dev.domain-name.site DocumentRoot /Library/WebServer/Documents/domain-name </VirtualHost>
Look (whereis) for the settings to ensure read access to the subdirectories via .htaccess
^W
Look for:
options the .htaccess
Modify “AllowOverride None” to allow .htaccess to control
directory access options AllowOverride All
Save file to overwrite existing
^O
File name and confirm overwrite
httpd.conf
Exit PICO
^X
Now you can go to System Preferences > Sharing and stop and start Personal Web Sharing to reset the WebServer to the new configuration settings. Or issue the following command in Terminal to gracefully restart Apache:
sudo apachectl graceful
So that’s what I do, and it’s working pretty well, thank you very much.
|
posted Thursday July 7, 2005