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 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 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 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197
|
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.3 $ -->
<sect1 xml:id="install.macosx.bundled" xmlns="http://docbook.org/ns/docbook">
<title>Using the bundled PHP</title>
<simpara>
PHP has come standard with Macs since OS X version 10.0.0. Enabling PHP
with the default web server requires uncommenting a few lines in the
Apache configuration file <filename>httpd.conf</filename> whereas the
<acronym>CGI</acronym> and/or <acronym>CLI</acronym> are enabled by
default (easily accessible via the Terminal program).
</simpara>
<simpara>
Enabling PHP using the instructions below is meant for quickly setting up
a local development environment. It's <emphasis>highly recommended</emphasis>
to always upgrade PHP to the newest version. Like most live software,
newer versions are created to fix bugs and add features and PHP being is
no different. See the appropriate MAC OS X installation documentation for
further details. The following instructions are geared towards a beginner
with details provided for getting a default setup to work. All users are
encouraged to compile, or install a new packaged version.
</simpara>
<simpara>
The standard installation type is using mod_php, and enabling the bundled
mod_php on Mac OS X for the Apache web server (the default web server,
that is accessible via System Preferences) involves the following steps:
</simpara>
<para>
<orderedlist>
<listitem>
<simpara>
Locate and open the Apache configuration file. By default, the location
is as follows: <filename>/etc/httpd/httpd.conf</filename>
</simpara>
<simpara>
Using <literal>Finder</literal> or <literal>Spotlight</literal> to find
this file may prove difficult as by default it's private and owned by
the <literal>root</literal> user.
</simpara>
<note>
<simpara>
One way to open this is by using a Unix based text editor in the
Terminal, for example <literal>nano</literal>, and because the
file is owned by root we'll use the <literal>sudo</literal> command
to open it (as root) so for example type the following into the
<literal>Terminal</literal> Application (after, it will prompt for
a password):
<literal>sudo nano /etc/httpd/httpd.conf</literal>
</simpara>
<simpara>
Noteworthy nano commands: <literal>^w</literal> (search),
<literal>^o</literal> (save), and <literal>^x</literal> (exit) where
<literal>^</literal> represents the Ctrl key.
</simpara>
</note>
</listitem>
<listitem>
<para>
With a text editor, uncomment the lines (by removing the #) that look
similar to the following (these two lines are often not together,
locate them both in the file):
<screen>
<![CDATA[
# LoadModule php4_module libexec/httpd/libphp4.so
# AddModule mod_php4.c
]]>
</screen>
Notice the location/path. When building PHP in the future, the above
files should be replaced or commented out.
</para>
</listitem>
<listitem>
<para>
Be sure the desired extensions will parse as PHP (examples: .php .html
and .inc)
</para>
<para>
Due to the following statement already existing in
<filename>httpd.conf</filename> (as of Mac Panther), once PHP is
enabled the <filename>.php</filename> files will automatically
parse as PHP.
<screen>
<![CDATA[
<IfModule mod_php4.c>
# If php is turned on, we respect .php and .phps files.
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
# Since most users will want index.php to work we
# also automatically enable index.php
<IfModule mod_dir.c>
DirectoryIndex index.html index.php
</IfModule>
</IfModule>
]]>
</screen>
</para>
</listitem>
<listitem>
<simpara>
Be sure the DirectoryIndex loads the desired default index file
</simpara>
<simpara>
This is also set in <filename>httpd.conf</filename>. Typically
<filename>index.php</filename> and <filename>index.html</filename> are
used. By default <filename>index.php</filename> is enabled because
it's also in the PHP check shown above. Adjust accordingly.
</simpara>
</listitem>
<listitem>
<simpara>
Set the &php.ini; location or use the default
</simpara>
<simpara>
A typical default location on Mac OS X is
<filename>/usr/local/php/php.ini</filename> and a call to
<function>phpinfo</function> will reveal this information.
If a &php.ini; is not used, PHP will use all default values.
See also the related FAQ on
<link linkend="faq.installation.phpini">finding php.ini</link>.
</simpara>
</listitem>
<listitem>
<simpara>
Locate or set the <literal>DocumentRoot</literal>
</simpara>
<simpara>
This is the root directory for all the web files. Files in this directory
are served from the web server so the PHP files will parse as PHP before
outputting them to the browser. A typical default path is
<filename>/Library/WebServer/Documents</filename> but this can be set to
anything in <filename>httpd.conf</filename>. Alternatively, the default
DocumentRoot for individual users is
<filename>/Users/yourusername/Sites</filename>
</simpara>
</listitem>
<listitem>
<simpara>
Create a <function>phpinfo</function> file
</simpara>
<para>
The <function>phpinfo</function> function will display information about PHP.
Consider creating a file in the DocumentRoot with the following PHP code:
<programlisting role="php">
<![CDATA[
<?php phpinfo(); ?>
]]>
</programlisting>
</para>
</listitem>
<listitem>
<simpara>
Restart Apache, and load the PHP file created above
</simpara>
<simpara>
To restart, either execute <literal>sudo apachectl graceful</literal> in
the shell or stop/start the "Personal Web Server" option in the
OS X System Preferences. By default, loading local files in the browser
will have an <acronym>URL</acronym> like so:
<filename>http://localhost/info.php</filename> Or using the DocumentRoot
in the user directory is another option and would end up looking like:
<filename>http://localhost/~yourusername/info.php</filename>
</simpara>
</listitem>
</orderedlist>
</para>
<simpara>
The <acronym>CLI</acronym> (or <acronym>CGI</acronym> in older versions) is
appropriately named <filename>php</filename> and likely exists as
<filename>/usr/bin/php</filename>. Open up the terminal, read the
<link linkend="features.commandline">command line section</link> of the PHP
manual, and execute <literal>php -v</literal> to check the PHP version of
this PHP binary. A call to <function>phpinfo</function> will also reveal
this information.
</simpara>
</sect1>
<!-- Keep this comment at the end of the file
Local variables:
mode: sgml
sgml-omittag:t
sgml-shorttag:t
sgml-minimize-attributes:nil
sgml-always-quote-attributes:t
sgml-indent-step:1
sgml-indent-data:t
indent-tabs-mode:nil
sgml-parent-document:nil
sgml-default-dtd-file:"../../manual.ced"
sgml-exposed-tags:nil
sgml-local-catalogs:nil
sgml-local-ecat-files:nil
End:
vim600: syn=xml fen fdm=syntax fdl=2 si
vim: et tw=78 syn=sgml
vi: ts=1 sw=1
-->
|