📄 faq.installation.html
字号:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html> <head> <title>Installation</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="faq.databases.html">Database issues</a></div> <div class="next" style="text-align: right; float: right;"><a href="faq.build.html">Build Problems</a></div> <div class="up"><a href="faq.html">FAQ</a></div> <div class="home"><a href="index.html">PHP Manual</a></div></div><hr /><div> <h1>Installation</h1> <p class="para"> This section holds common questions about the way to install PHP. PHP is available for almost any OS (except maybe for MacOS before OSX), and almost any web server. </p> <p class="para"> To install PHP, follow the instructions in <a href="install.html" class="xref">Installation and Configuration</a>. </p> <div class="qandaset"><ol class="qandaset_questions"><li><a href="#faq.installation.apache2"> Why shouldn't I use Apache2 with a threaded MPM in a production environment? </a></li><li><a href="#faq.installation.phpini"> Unix/Windows: Where should my php.ini file be located? </a></li><li><a href="#faq.installation.nodata"> Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here? </a></li><li><a href="#faq.installation.processing"> Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here? </a></li><li><a href="#faq.installation.frontpage"> Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions? </a></li><li><a href="#faq.installation.blankscreen"> Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen. </a></li><li><a href="#faq.installation.500error"> Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error. </a></li><li><a href="#faq.installation.undefinedsyms"> Some operating systems: I have installed PHP without errors, but when I try to start apache I get undefined symbol errors: [mybox:user /src/php4] root# apachectl configtest apachectl: /usr/local/apache/bin/httpd Undefined symbols: _compress _uncompress </a></li><li><a href="#faq.installation.cgierror"> Windows: I have installed PHP, but when I to access a PHP script file via my browser, I get the error: cgi error: The specified CGI application misbehaved by not returning a complete set of HTTP headers. The headers it did return are: </a></li><li><a href="#faq.installation.phpandiis"> Windows: I've followed all the instructions, but still can't get PHP and IIS to work together! </a></li><li><a href="#faq.installation.forceredirect"> When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami, I get the following error: Security Alert! PHP CGI cannot be accessed directly.. </a></li><li><a href="#faq.installation.findphpini"> How do I know if my php.ini is being found and read? It seems like it isn't as my changes aren't being implemented. </a></li><li><a href="#faq.installation.addtopath"> How do I add my PHP directory to the PATH on Windows? </a></li><li><a href="#faq.installation.phprc"> How do I make the php.ini file available to PHP on windows? </a></li><li><a href="#faq.installation.apache.multiviews"> Is it possible to use Apache content negotiation (MultiViews option) with PHP? </a></li><li><a href="#faq.installation.requestmethods"> Is PHP limited to process GET and POST request methods only? </a></li></ol> <dl> <dt><strong> <p class="para"> Why shouldn't I use Apache2 with a threaded MPM in a production environment? </p> </strong></dt> <dd><a name="faq.installation.apache2"></a> <p class="para"> PHP is glue. It is the glue used to build cool web applications by sticking dozens of 3rd-party libraries together and making it all appear as one coherent entity through an intuitive and easy to learn language interface. The flexibility and power of PHP relies on the stability and robustness of the underlying platform. It needs a working OS, a working web server and working 3rd-party libraries to glue together. When any of these stop working PHP needs ways to identify the problems and fix them quickly. When you make the underlying framework more complex by not having completely separate execution threads, completely separate memory segments and a strong sandbox for each request to play in, feet of clay are introduced into PHP's system. </p> <p class="para"> If you feel you have to use a threaded MPM, look at a FastCGI configuration where PHP is running in its own memory space. </p> <p class="para"> And finally, this warning against using a threaded MPM is not as strong for Windows systems because most libraries on that platform tend to be threadsafe. </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix/Windows: Where should my <var class="filename">php.ini</var> file be located? </p> </strong></dt> <dd><a name="faq.installation.phpini"></a> <p class="para"> By default on Unix it should be in <var class="filename">/usr/local/lib</var> which is <var class="filename"><install-path>/lib</var>. Most people will want to change this at compile-time with the <a href="configure.html#configure.with-config-file-path" class="link">--with-config-file-path</a> flag. You would, for example, set it with something like: <div class="example-contents"><div class="cdata"><pre>--with-config-file-path=/etc </pre></div></div> And then you would copy <var class="filename">php.ini-dist</var> from the distribution to <var class="filename">/etc/php.ini</var> and edit it to make any local changes you want. </p> <div class="example-contents"><div class="cdata"><pre>--with-config-file-scan-dir=PATH </pre></div></div> <p class="para"> On Windows the default path for the <var class="filename">php.ini</var> file is the Windows directory. If you're using the Apache webserver, <var class="filename">php.ini</var> is first searched in the Apaches install directory, e.g. <var class="filename">c:\program files\apache group\apache</var>. This way you can have different <var class="filename">php.ini</var> files for different versions of Apache on the same machine. </p> <p class="para"> See also the chapter about the <a href="configuration.html#configuration.file" class="link">configuration file</a>. </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix: I installed PHP, but every time I load a document, I get the message 'Document Contains No Data'! What's going on here? </p> </strong></dt> <dd><a name="faq.installation.nodata"></a> <p class="para"> This probably means that PHP is having some sort of problem and is core-dumping. Look in your server error log to see if this is the case, and then try to reproduce the problem with a small test case. If you know how to use 'gdb', it is very helpful when you can provide a backtrace with your bug report to help the developers pinpoint the problem. If you are using PHP as an Apache module try something like: <ul class="itemizedlist"> <li class="listitem"> <p class="para"> Stop your httpd processes </p> </li> <li class="listitem"> <p class="para"> gdb httpd </p> </li> <li class="listitem"> <p class="para"> Stop your httpd processes </p> </li> <li class="listitem"> <p class="para"> > run -X -f /path/to/httpd.conf </p> </li> <li class="listitem"> <p class="para"> Then fetch the URL causing the problem with your browser </p> </li> <li class="listitem"> <p class="para"> > run -X -f /path/to/httpd.conf </p> </li> <li class="listitem"> <p class="para"> If you are getting a core dump, gdb should inform you of this now </p> </li> <li class="listitem"> <p class="para"> type: bt </p> </li> <li class="listitem"> <p class="para"> You should include your backtrace in your bug report. This should be submitted to <a href="http://bugs.php.net/" class="link external">» http://bugs.php.net/</a> </p> </li> </ul> </p> <p class="para"> If your script uses the regular expression functions (<a href="function.ereg.html" class="function">ereg()</a> and friends), you should make sure that you compiled PHP and Apache with the same regular expression package. This should happen automatically with PHP and Apache 1.3.x </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix: I installed PHP using RPMS, but Apache isn't processing the PHP pages! What's going on here? </p> </strong></dt> <dd><a name="faq.installation.processing"></a> <p class="para"> Assuming you installed both Apache and PHP from RPM packages, you need to uncomment or add some or all of the following lines in your <var class="filename">httpd.conf</var> file: <div class="example-contents"><div class="cdata"><pre># Extra ModulesAddModule mod_php.cAddModule mod_php.cAddModule mod_perl.c# Extra ModulesLoadModule php_module modules/mod_php.soLoadModule php5_module modules/libphp5.so # for PHP 5LoadModule perl_module modules/libperl.so</pre></div> </div> And add: <div class="example-contents"><div class="cdata"><pre>AddType application/x-httpd-php .php</pre></div> </div> ... to the global properties, or to the properties of the VirtualDomain you want to have PHP support added to. </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix: I patched Apache with the FrontPage extensions patch, and suddenly PHP stopped working. Is PHP incompatible with the Apache FrontPage extensions? </p> </strong></dt> <dd><a name="faq.installation.frontpage"></a> <p class="para"> No, PHP works fine with the FrontPage extensions. The problem is that the FrontPage patch modifies several Apache structures, that PHP relies on. Recompiling PHP (using 'make clean ; make') after the FP patch is applied would solve the problem. </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix/Windows: I have installed PHP, but when I try to access a PHP script file via my browser, I get a blank screen. </p> </strong></dt> <dd><a name="faq.installation.blankscreen"></a> <p class="para"> Do a 'view source' in the web browser and you will probably find that you can see the source code of your PHP script. This means that the web server did not send the script to PHP for interpretation. Something is wrong with the server configuration - double check the server configuration against the PHP installation instructions. </p> </dd> </dl> <dl> <dt><strong> <p class="para"> Unix/Windows: I have installed PHP, but when try to access a PHP script file via my browser, I get a server 500 error. </p> </strong></dt> <dd><a name="faq.installation.500error"></a> <p class="para"> Something went wrong when the server tried to run PHP. To get to see a sensible error message, from the command line, change to the directory containing the PHP executable (<var class="filename">php.exe</var> on Windows) and run <strong class="command">php -i</strong>. If PHP has any problems running, then a suitable error message will be displayed which will give you a clue as to what needs to be done next. If you get a screen full of HTML codes (the output of the <a href="function.phpinfo.html" class="function">phpinfo()</a> function) then PHP is working, and your problem may be related to your server configuration which you should double check. </p> </dd>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -