I’ve placed code for a News Headline and a Weather Report several times now and the odds of it appearing in Preview is a crapshoot. What’s it take and are some codes friendlier than others?
If you preview something code-based, you might need to run it from a server, not a local file. When you preview locally, all you are doing is opening the file in a browser or in Freeway’s WebKit-based preview mode. Opening a file is not the same as running that file on a server, especially if that server is processing the file with PHP or another server-side language.
Do I need to invest in a dedicated server then? Will an extra CPU that I have laying around work? Dan
On Jun 21, 2010, at 11:09 AM, waltd wrote:
If you preview something code-based, you might need to run it from a server, not a local file. When you preview locally, all you are doing is opening the file in a browser or in Freeway’s WebKit-based preview mode. Opening a file is not the same as running that file on a server, especially if that server is processing the file with PHP or another server-side language.
If you have a web host you can post it there in a test directory. Or, you could use MAMP to run a local server. Doesn’t have to be a dedicated local Mac to run MAMP, but if you have a extra lying around it’s not a bad idea.
Mac OS X comes with the same industry-standard Web server (Apache 2) that any self-respecting hosting provider would charge you money to use. The only thing you’ll need to do is enable MySQL and PHP and you should be ready to go – no MAMP needed.
The PHP is simple – uncomment this line in the file /etc/apache2/httpd.conf:
(Uncomment here means you delete the # mark at the beginning of the line.)
Turn off Web Sharing in your System Preferencel, and turn it back on, and you will have a PHP5 Apache server. Put your files in /Library/WebServer/Documents/ or a subfolder beneath that level.
I can’t recall if MySQL is installed by default, I know it is on the Server version, but if it isn’t, it’s a free download of a normal Mac Installer package away. http://www.mysql.com/downloads/mysql/ Pick the one that most closely matches your hardware and OS version, in the DMG format.
If you can’t find one for your exact combo, there are instructions all over the net for compiling it yourself, which despite the geek warning plastered all over that simple phrase, is not all that hard to do. Copy and paste and wait while cryptic strings of text run through your Terminal will pretty much cover all that you need to do.