⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 install.macosx.bundled.html

📁 php的帮助文档,涉及到PHP的案例和基本语法,以及实际应用内容
💻 HTML
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head>  <title>Using the bundled PHP</title>  <meta http-equiv="content-type" content="text/html; charset=UTF-8"> </head> <body><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.macosx.html">Installation on Mac OS X</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.macosx.server.html">Compiling for OS X Server</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 class="orderedlist">   <li class="listitem">    <span class="simpara">     Locate and open the Apache configuration file. By default, the location      is as follows: <var class="filename">/etc/httpd/httpd.conf</var>    </span>    <span class="simpara">     Using <i>Finder</i> or <i>Spotlight</i> to find     this file may prove difficult as by default it&#039;s private and owned by     the <i>root</i> user.    </span>    <blockquote><p><b class="note">Note</b>:      <span class="simpara">      One way to open this is by using a Unix based text editor in the      Terminal, for example <i>nano</i>, and because the       file is owned by root we&#039;ll use the <i>sudo</i> command      to open it (as root) so for example type the following into the       <i>Terminal</i> Application (after, it will prompt for      a password):      <i>sudo nano /etc/httpd/httpd.conf</i>     </span>     <span class="simpara">      Noteworthy nano commands: <i>^w</i> (search),       <i>^o</i> (save), and <i>^x</i> (exit) where       <i>^</i> represents the Ctrl key.     </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"><pre><div class="cdata"><pre># LoadModule php4_module libexec/httpd/libphp4.so# AddModule mod_php4.c</pre></div>     </pre></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"><pre><div class="cdata"><pre>&lt;IfModule mod_php4.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>     </pre></div>    </p>   </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     <a href="function.phpinfo.html" class="function">phpinfo()</a> 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 <i>DocumentRoot</i>    </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      DocumentRoot for individual users is      <var class="filename">/Users/yourusername/Sites</var>    </span>   </li>   <li class="listitem">    <span class="simpara">     Create a <a href="function.phpinfo.html" class="function">phpinfo()</a> file    </span>    <p class="para">     The <a href="function.phpinfo.html" class="function">phpinfo()</a> 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>    <span class="simpara">     To restart, either execute <i>sudo apachectl graceful</i> 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>    </span>   </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 <i>php -v</i> to check the PHP version of   this PHP binary. A call to <a href="function.phpinfo.html" class="function">phpinfo()</a> will also reveal  this information. </p></div><hr /><div style="text-align: center;"> <div class="prev" style="text-align: left; float: left;"><a href="install.macosx.html">Installation on Mac OS X</a></div> <div class="next" style="text-align: right; float: right;"><a href="install.macosx.server.html">Compiling for OS X Server</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>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -