Setup a PHP.net mirror on OSX
Many of us PHP developers use php.net often. The mirrors available are pretty good, but what if you don’t have a net connection. Ah, OSX already has Apache and PHP installed. This combined with the handy way php.net allows anyone to have a mirror can save your life.
- We need to get a copy of the website. Run this to synchronize you computer with the current site.
rsync -avzC --timeout=600 --delete --delete-after \ --include='manual/en/' --include='manual/en/**' \ --exclude='manual/**' --exclude='distributions/manual/**' \ --exclude='distributions/**' --exclude='extra/**' \ rsync.php.net::phpweb /Library/WebServer/Documents/php
- Add SQLite support if necessary.
pear install SQLite - Setup the Apache VirtualHost:
Save this in a file called /etc/httpd/users/php.confNameVirtualHost *:80 <VirtualHost *:80> </VirtualHost> <VirtualHost *:80> ServerName php ServerAdmin webmaster@domainname.com # Webroot of PHP mirror site DocumentRoot /Library/WebServer/Documents/php # These PHP settings are necessary to run a mirror php_value include_path .:/Library/WebServer/Documents/php/include php_flag register_globals on # Log server activity ErrorLog /var/log/httpd/php-error_log TransferLog /var/log/httpd/php-access_log # Set directory index DirectoryIndex index.php index.html # Do not display directory listings if index is not present, # and do not try to match filenames if extension is omitted Options -Indexes -MultiViews # Handle errors with local error handler script ErrorDocument 401 /error.php ErrorDocument 403 /error.php ErrorDocument 404 /error.php # Add types not specified by Apache by default AddType application/octet-stream .chm .bz2 .tgz AddType application/x-pilot .prc .pdb # Set mirror's preferred language here SetEnv MIRROR_LANGUAGE "en" # Turn spelling support off (which would break URL shortcuts) <IfModule mod_speling.c> CheckSpelling Off </IfModule> </VirtualHost> - run
sudo apachectl graceful - Add a php alias to you hosts file. Edit /etc/hosts. Add “php” to the end of the line that starts with “127.0.0.1″
- In order to get updates you can run the first command any time you want, or if you are running Tiger you can copy this file into ~/Library/LaunchAgents/net.php.mirror.plist. This will cause it to be updated daily.
Posted: June 17th, 2005.
Tags: Mac, Web