Sophie

Sophie

distrib > Mageia > 4 > x86_64 > by-pkgid > f800694edefe91adea2624f711a41a2d > files > 8203

php-manual-en-5.5.7-1.mga4.noarch.rpm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Using the bundled PHP</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="install.macosx.packages.html">Using Packages</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="install.macosx.compile.html">Compiling PHP on Mac OS X</a></div>
 <div class="up"><a href="install.macosx.html">Installation on Mac OS X</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="install.macosx.bundled" class="sect1">
 <h2 class="title">Using the bundled PHP</h2>
 <p class="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 <var class="filename">httpd.conf</var> whereas the 
  <acronym title="Common Gateway Interface">CGI</acronym> and/or <acronym title="Command Line Interpreter/Interface">CLI</acronym> are enabled by  
  default (easily accessible via the Terminal program).
 </p>
 <p class="simpara">
  Enabling PHP using the instructions below is meant for quickly setting up
  a local development environment.  It&#039;s <em class="emphasis">highly recommended</em> 
  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.  
 </p>
 <p class="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:
 </p>
 <p class="para">
  <ol type="1">
   <li class="listitem">
    <span class="simpara">
     Locate and open the Apache configuration file. By default, the location 
     is as follows: <var class="filename">/private/etc/apache2/httpd.conf</var>
    </span>
    <span class="simpara">
     Using <em>Finder</em> or <em>Spotlight</em> to find
     this file may prove difficult as by default it&#039;s private and owned by
     the <em>root</em> user.
    </span>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <span class="simpara">
      One way to open this is by using a Unix based text editor in the
      Terminal, for example <em>nano</em>, and because the 
      file is owned by <em>root</em> we&#039;ll use the <em>sudo</em> command
      to open it (as <em>root</em>) so for example type the following into the 
      <em>Terminal</em> Application (after, it will prompt for
      a password):
      <em>sudo nano /private/etc/apache2/httpd.conf</em>
     </span>
     <span class="simpara">
      Noteworthy nano commands: <em>^w</em> (search), 
      <em>^o</em> (save), and <em>^x</em> (exit) where 
      <em>^</em> represents the Ctrl key.
     </span>
    </p></blockquote> 
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <span class="simpara">
      Versions of Mac OS X prior to 10.5 were bundled with older versions of
      PHP and Apache.  As such, the Apache configuration file on legacy
      machines may be <var class="filename">/etc/httpd/httpd.conf</var>.
     </span>
    </p></blockquote>
   </li>
   <li class="listitem">
    <p class="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):
     <div class="example-contents screen">
<div class="cdata"><pre>
# LoadModule php5_module libexec/httpd/libphp5.so

# AddModule mod_php5.c
</pre></div>
     </div>
      Notice the location/path. When building PHP in the future, the above
      files should be replaced or commented out.
    </p>
   </li>
   <li class="listitem">
    <p class="para">
     Be sure the desired extensions will parse as PHP (examples: .php .html 
     and .inc)
    </p>
    <p class="para">
     Due to the following statement already existing in
     <var class="filename">httpd.conf</var> (as of Mac Panther), once PHP is 
     enabled the <var class="filename">.php</var> files will automatically 
     parse as PHP.
     <div class="example-contents screen">
<div class="cdata"><pre>
&lt;IfModule mod_php5.c&gt;
    # 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
    &lt;IfModule mod_dir.c&gt;
        DirectoryIndex index.html index.php
    &lt;/IfModule&gt;
&lt;/IfModule&gt;
</pre></div>
     </div>
    </p>
    <blockquote class="note"><p><strong class="note">Note</strong>: 
     <p class="para">
      Before OS X 10.5 (Leopard), PHP 4 was bundled instead of PHP 5 in
      which case the above instructions will differ slightly by changing
      5&#039;s to 4&#039;s.
     </p>
    </p></blockquote>
   </li>
   <li class="listitem">
    <span class="simpara">
     Be sure the DirectoryIndex loads the desired default index file
    </span>
    <span class="simpara">
     This is also set in <var class="filename">httpd.conf</var>. Typically 
     <var class="filename">index.php</var> and <var class="filename">index.html</var> are 
     used. By default <var class="filename">index.php</var> is enabled because 
     it&#039;s also in the PHP check shown above. Adjust accordingly.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     Set the <var class="filename">php.ini</var> location or use the default
    </span>
    <span class="simpara">
     A typical default location on Mac OS X is 
     <var class="filename">/usr/local/php/php.ini</var> and a call to
      <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> will reveal this information. 
     If a <var class="filename">php.ini</var> is not used, PHP will use all default values.
     See also the related FAQ on 
     <a href="faq.installation.html#faq.installation.phpini" class="link">finding php.ini</a>.
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     Locate or set the <em>DocumentRoot</em>
    </span>
    <span class="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 
     <var class="filename">/Library/WebServer/Documents</var> but this can be set to
     anything in <var class="filename">httpd.conf</var>.  Alternatively, the default 
     <var class="filename">DocumentRoot</var> for individual users is 
     <var class="filename">/Users/yourusername/Sites</var>
    </span>
   </li>
   <li class="listitem">
    <span class="simpara">
     Create a  <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> file
    </span>
    <p class="para">
     The  <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> function will display information about PHP. 
     Consider creating a file in the DocumentRoot with the following PHP code:
     <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php&nbsp;phpinfo</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
     </div>

    </p> 
   </li>
   <li class="listitem">
    <span class="simpara">
     Restart Apache, and load the PHP file created above
    </span>
    <p class="para">
     To restart, either execute <em>sudo apachectl graceful</em> in 
     the shell or stop/start the &quot;Personal Web Server&quot; option in the
     OS X System Preferences. By default, loading local files in the browser 
     will have an <acronym title="Uniform Resource Locator">URL</acronym> like so: 
     <var class="filename">http://localhost/info.php</var> Or using the DocumentRoot 
     in the user directory is another option and would end up looking like: 
     <var class="filename">http://localhost/~yourusername/info.php</var>
    </p>
   </li>
  </ol>
 </p>
 <p class="simpara">
  The <acronym title="Command Line Interpreter/Interface">CLI</acronym> (or <acronym title="Common Gateway Interface">CGI</acronym> in older versions) is 
  appropriately named <var class="filename">php</var> and likely exists as  
  <var class="filename">/usr/bin/php</var>. Open up the terminal, read the
  <a href="features.commandline.html" class="link">command line section</a> of the PHP 
  manual, and execute <em>php -v</em> to check the PHP version of 
  this PHP binary. A call to  <span class="function"><a href="function.phpinfo.html" class="function">phpinfo()</a></span> will also reveal
  this information.
 </p>
</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="install.macosx.packages.html">Using Packages</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="install.macosx.compile.html">Compiling PHP on Mac OS X</a></div>
 <div class="up"><a href="install.macosx.html">Installation on Mac OS X</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>