The PHP sample depends on some specific settings, which can be changed in the php.ini file. This table gives an overview:
Setting | Value | Remarks |
---|---|---|
allow_call_time_pass_reference | Off | |
always_populate_raw_post_data | Off | |
arg_separator.input | & | |
arg_separator.output | & | |
asp_tags | Off | |
file_uploads | On | |
upload_max_filesize | 2M | Change this if you need to upload bigger files |
post_max_size | 8M | Change this if you need to upload bigger files |
memory_limit | 128M | |
log_errors | On | |
magic_quotes_gpc | Off | |
magic_quotes_runtime | Off | |
magic_quotes_sybase | Off | |
max_file_uploads | 20 | |
max_input_nesting_level | 64 | |
max_input_time | 60 | |
register_argc_argv | Off | |
register_globals | Off | |
register_long_arrays | Off | |
request_order | GP | |
variables_order | GPCS | |
safe_mode | Off | |
short_open_tag | Off |
Example: running the PHP sample on Mac OS X
Mac OS X 10.6 (Snowleopard) comes with a built-in web server with PHP. However, PHP is by default not enabled.
To enable it, open the file /etc/apache2/httpd.conf. Locate the line,
#LoadModule php5_module libexec/apache2/libphp5.so
Remove the leading hash (#), and save the file. A default php.ini file which matches our needs is already available, but it is disabled. To enable it, rename or copy the file /etc/php.ini.default to /etc/php.ini.
Now PHP is enabled, and we just need to copy the sample to the web server: copy the contents of the Samples/PHP subfolder of the SDK to /Library/WebServer/Documents.
As a final step, we need to enable the web server. In the Mac OS X System Preferences, go to Sharing, and enable the Web Sharing checkbox. Open a web browser, and go to http://localhost/index.php.