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_
To install PHP, follow the instructions in the
INSTALL
file located in the distribution_ Windows users should also read the
install_txt
file_ There are also some helpful hints for Windows users
here_
1_
Unix/Windows: Where should my php_ini file be
located?
By default on UNIX it should be in /usr/local/lib
which is <install_path>/lib_
Most people will want to change this at compile_time with the
__with_config_file_path
flag_ You would, for example, set it with something like:
__with_config_file_path=/etc
And then you would copy php_ini_dist from
the distribution to /etc/php_ini and
edit it to make any local changes you want_
__with_config_file_scan_dir=PATH
On Windows the default path for the php_ini file is the Windows
directory_ If you're using the Apache webserver, php_ini is first
searched in the Apaches install directory, e_g_ c:\program
files\apache group\apache_ This way you can have
different php_ini files for different versions of Apache on the same
machine_
2_
Unix: I installed PHP, but every time I load a document, I get the
message 'Document Contains No Data'! What's going on here?
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:
Stop your httpd processes
gdb httpd
Stop your httpd processes
> run _X _f /path/to/httpd_conf
Then fetch the URL causing the problem with your browser
> run _X _f /path/to/httpd_conf
If you are getting a core dump, gdb should inform you of this now
type: bt
You should include your backtrace in your bug report_ This should be submitted to
http://bugs_php_net/
If your script uses the regular expression functions
(ereg() 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
3_
Unix: I installed PHP using RPMS, but Apache isn't processing the
PHP pages! What's going on here?
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 httpd_conf file:
# Extra Modules
AddModule mod_php_c
AddModule mod_php3_c
AddModule mod_perl_c
# Extra Modules
LoadModule php_module modules/mod_php_so
LoadModule php3_module modules/libphp3_so /* for PHP 3 */
LoadModule php4_module modules/libphp4_so /* for PHP 4 */
LoadModule perl_module modules/libperl_so
And add:
AddType application/x_httpd_php3 _php3 /* for PHP 3 */
AddType application/x_httpd_php _php /* for PHP 4 */
___ to the global properties, or to the properties of the
VirtualDomain you want to have PHP support added to_
4_
Unix: I installed PHP 3 using RPMS, but it doesn't compile with
the database support I need! What's going on here?
Due to the way PHP 3 built, it is not easy to build a
complete flexible PHP RPM_ This issue is addressed in PHP 4_
For PHP 3, we currently suggest you use the mechanism described in the
INSTALL_REDHAT file in the PHP distribution_ If you insist on using
an RPM version of PHP 3, read on___
The RPM packagers are setting up the RPMS to install
without database support to simplify installations and
because RPMS use /usr/ instead of the standard /usr/local/ directory for
files_ You need to tell the RPM spec file which databases to support
and the location of the top_level of your database server_
This example will explain the process of adding support for the
popular MySQL database server, using the mod installation for Apache_
Of course all of this information can be adjusted for any database
server that PHP supports_ We will assume you installed MySQL and Apache
completely with RPMS for this example as well_
First remove mod_php3 :
rpm _e mod_php3
Then get the source rpm and INSTALL it, NOT __rebuild
rpm _Uvh mod_php3_3_0_5_2_src_rpm
Then edit the /usr/src/redhat/SPECS/mod_php3_spec file
In the %build section add the database support you want, and the path_
Make sure you restart Apache, and you now have PHP 3 with MySQL support
using RPM's_ Note that it is probably much easier to just build
from the distribution tarball of PHP 3 and follow the instructions in
INSTALL_REDHAT found in that distribution_
5_
Unix: I patched Apache with the FrontPage extensions patch, and
suddenly PHP stopped working_ Is PHP incompatible with the
Apache FrontPage extensions?
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_
6_
Unix/Windows: I have installed PHP, but when I try to
access a PHP script file via my browser, I get a blank screen_
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_
7_
Unix/Windows: I have installed PHP, but when try to
access a PHP script file via my browser, I get a
server 500 error_
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
(php_exe on Windows) and run
php _i_ 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
phpinfo() function) then PHP is working,
and your problem may be related to your server configuration
which you should double check_
8_
Some operating systems: I have installed PHP without errors,
but when I try to start apache I get undefined symbol errors:
This has actually nothing to do with PHP, but with the MySQL
client libraries_ Some need __with_zlib, others do not_ This
is also covered in the MySQL FAQ_
9_
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:
This error message means that PHP failed to output anything
at all_ To get to see a sensible error message, from the
command line, change to the directory containing the PHP
executable (php_exe on Windows) and run
php _i_ 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
phpinfo() function) then PHP is working_
Once PHP is working at the command line, try accessing the
script via the browser again_ If it still fails then it
could be one of the following:
File permissions on your PHP script,
php_exe, php4ts_dll,
php_ini or any PHP extensions you are trying to load are such
that the anonymous internet user
ISUR_<machinename> cannot access them_
The script file does not exist (or possibly isn't where you
think it is relative to your web root directory)_ Note that
for IIS you can trap this error by ticking the 'check file
exists' box when setting up the script mappings in the
Internet Services Manager_ If a script file does not exist
then the server will return a 404 error instead_ There is
also the additional benefit that IIS will do any
authentication required for you based on the NTLanMan
permissions on your script file_
10_
Windows: I've followed all the instructions, but still can't
get PHP and IIS to work together!
Make sure any user who needs to run a PHP script has the rights
to run php_exe! IIS uses an anonymous user
which is added at the time IIS is installed_ This user needs
rights to php_exe_ Also, any authenticated
user will also need rights to execute php_exe_
And for IIS4 you need to tell it that PHP is a script engine_
Also, you will want to read
this faq_
11_
When running PHP as CGI with IIS, PWS, OmniHTTPD or Xitami,
I get the following error: Security Alert! PHP CGI
cannot be accessed directly__
You must set the
cgi_force_redirect directive to 0_
It defaults to 1 so be sure the directive
isn't commented out (with a ;)_ Like
all directives, this is set in php_ini
Because the default is 1, it's critical
that you're 100% sure that the correct php_ini file is being
read_ Read this faq
for details_
12_
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_
To be sure your php_ini is being read by PHP, make a call to
phpinfo() and near the top will be a
listing called Configuration File (php_ini)_
This will tell you where PHP is looking for php_ini and
whether or not it's being read_ If just a directory PATH exists
than it's not being read and you should put your php_ini
in that directory_ If php_ini is included within the PATH than
it is being read_
If php_ini is being read and you're running PHP as a module
then be sure to restart PHP after making changes to php_ini