php-src/INSTALL

423 lines
15 KiB
Plaintext
Raw Normal View History

2003-07-03 12:14:42 +08:00
Installation Instructions for PHP 5
2002-05-15 18:20:02 +08:00
-----------------------------------
1999-04-08 05:05:13 +08:00
STOP!
Before going any further, please remember you are going to find more
up to date instructions in the online manual, located here:
http://www.php.net/manual/en/install.apache.php
For Apache 2, instructions and up-to-date information regarding it's
support status, is available here:
http://www.php.net/manual/en/install.apache2.php
It is strongly recommended that you read the manual page before going
further. However, for the impatient, here is a quick set of steps that
will build PHP as (first) a dynamic Apache module (DSO) for Apache 1.3.x
with MySQL support and then a static module. A more verbose explanation follows.
1999-04-08 05:05:13 +08:00
For installing PHP on other web servers, refer to one of the following
files:
sapi/aolserver/README
sapi/pi3web/README
sapi/servlet/README
sapi/thttpd/README
README.Zeus
Some notes:
1: Only install either the static module or the dynamic one. Do not
install both.
1999-04-08 05:05:13 +08:00
2: If you are recompiling PHP to add new extensions or upgrading
something like GD, remove the config.cache file before you re-run
configure.
3: If you are on Linux and have installed shared libraries, make
sure the location of these shared libraries are listed in your
/etc/ld.so.conf file. For example, if you have:
/usr/local/lib/mysql/libmysqlclient.so
Make sure /etc/ld.so.conf contains:
/usr/local/lib/mysql
Then run ldconfig.
2000-03-27 08:33:47 +08:00
If you want both PHP 3 and 4 modules in the same Apache server, check the
bottom of this file for instructions.
INSTALLATION WITH THE ZEUS WEB SERVER:
--Please see the 'README.Zeus' file included in this distribution
2000-03-27 08:33:47 +08:00
2000-03-27 08:33:47 +08:00
QUICK INSTALL (DSO)
For this to work your Apache httpd must have mod_so enabled.
Check using httpd -l. You should see something like:
Compiled-in modules:
http_core.c
mod_so.c
Chances are you will see a lot more modules than these two. That's ok,
as long as mod_so.c shows up you can proceed with the following steps:
2002-05-15 18:23:42 +08:00
$ gunzip -c php-4.x.y.tar.gz | tar xf -
$ cd php-4.x.y
2000-03-27 08:33:47 +08:00
$ ./configure --with-mysql --with-apxs
$ make
$ make install
If you get an error telling you that the apxs script could not be found,
look for it on your system and if you find it, provide the full path to it
as: --with-apxs=/path/to/apxs
2002-07-08 00:44:23 +08:00
Make sure you specify the version of apxs that is actually installed on
your system and NOT the one that is in the apache source tarball.
Next you must copy php.ini-dist to the appropriate place (normally
/usr/local/lib/php.ini) and edit it as necessary to set PHP options.
2000-03-27 08:33:47 +08:00
The only thing left to do is to edit your httpd.conf file and make sure the
PHP 4 mime type is there and uncommented. You need a line that looks like
this:
AddType application/x-httpd-php .php
Then restart your server (apachectl restart) and you should be able to
serve up PHP files now. Make a test file called test.php and put some
PHP tags in it. Like <?phpinfo()?>, for example.
QUICK INSTALL (Static)
1999-04-08 05:05:13 +08:00
$ gunzip -c apache_1.3.x.tar.gz | tar xf -
$ cd apache_1.3.x
$ ./configure
$ cd ..
2002-05-15 18:23:42 +08:00
$ gunzip -c php-4.x.y.tar.gz | tar xf -
$ cd php-4.x.y
$ ./configure --with-mysql --with-apache=../apache_1.3.x
$ make
$ make install
$ cd ../apache_1.3.x
2003-07-03 12:14:42 +08:00
$ ./configure --prefix=/www --activate-module=src/modules/php5/libphp5.a
(The above line is correct! Yes, we know libphp5.a does not exist at this
1999-04-08 05:05:13 +08:00
stage. It isn't supposed to. It will be created.)
$ make
(you should now have an httpd binary which you can copy to your Apache bin dir if
is is your first install then you need to "make install" as well)
2002-05-15 18:23:42 +08:00
$ cd ../php-4.x.y
$ cp php.ini-dist /usr/local/lib/php.ini
You can edit /usr/local/lib/php.ini file to set PHP options.
1999-04-08 05:05:13 +08:00
Edit your httpd.conf or srm.conf file and add:
AddType application/x-httpd-php .php
1999-04-08 05:05:13 +08:00
VERBOSE INSTALL
2000-03-27 08:33:47 +08:00
Chances are you are reading this because the quick install steps above
did not work for you. If this is the case, congratulations, you are
among the elite few that actually reads documentation. It really is
not a difficult install and once you have done it once you will fly
through it.
Installing PHP can be done in four simple steps:
1999-04-08 05:05:13 +08:00
1. Unpack your distribution file.
2002-05-15 18:23:42 +08:00
You will have downloaded a file named something like php-4.x.y.tar.gz.
Unzip this file with a command like: gunzip php-4.x.y.tar.gz
1999-04-08 05:05:13 +08:00
2002-05-15 18:23:42 +08:00
Next you have to untar it with: tar -xvf php-4.x.y.tar
1999-04-08 05:05:13 +08:00
2002-05-15 18:23:42 +08:00
This will create a php-4.x.y directory. cd into this new directory.
1999-04-08 05:05:13 +08:00
2000-03-27 08:33:47 +08:00
2a. Configure PHP (Dynamic Module) - Skip to 2b if you wish to build
a static module
You now have to choose the options you would like. There are quite
a few of them. To see a list, type: ./configure --help
The only options that you are likely to want to use are the ones in
the last section entitled, "--enable and --with options recognized:"
A popular choice is to build the Apache module version. In order to
build PHP as a dynamic module for Apache-1.3.x you have to first have
Apache installed. Assuming Apache is already installed, make sure
the shared object module is enabled. To check this, type: httpd -l
You should see something like:
Compiled-in modules:
http_core.c
mod_so.c
You will most likely have a lot more modules than what is shown here.
As long as mod_so.c shows up in the list, PHP should be happy.
Now, type: ./configure --with-mysql --with-apxs
If you get an error telling you that the apxs script could not be found,
look for it on your system and if you find it, provide the full path to it
as: --with-apxs=/path/to/apxs
2002-07-08 00:44:23 +08:00
Make sure you specify the version of apxs that is actually installed on
your system and NOT the one that is in the apache source tarball.
2000-03-27 08:33:47 +08:00
You might also want other flags on this configure line. --with-mysql
is just an example.
There are a few things that can go wrong during this configure step.
The most common is that you have asked for an option and that the
configure script can not find the files required to enable this
option in PHP. Chances are you can provide the full path to the
base directory under which the related files were installed. For
example, if you have installed the GD library in /opt/gd which means
that /opt/gd/include has your GD header files and /opt/gd/lib contains
your GD library files, you would use --with-gd=/opt/gd
Skip to step 3 for compilation and installation instructions.
2b. Configure PHP (Static Module) - Skip if you performed 2a
1999-04-08 05:05:13 +08:00
You now have to choose the options you would like. There are quite
a few of them. To see a list, type: ./configure --help
The only options that you are likely to want to use are the ones in
the last section entitled, "--enable and --with options recognized:"
A popular choice is to build the Apache module version. You need
to know where the source code directory for your Apache server is
located. Then use an option like: --with-apache=/usr/local/src/apache
if that is your Apache source code directory. If you only specify
--with-apache, then it will default to look for your Apache source
in /usr/local/etc/httpd.
NOTE: The directory you specify should be the top-level of the
unpacked Apache (or Stronghold) distribution. The configure program
will automatically look for httpd.h in different directories under that
location depending on which version of Apache, including Stronghold,
you are running.
For MySQL support, since newer versions of MySQL installs its various
components under /usr/local, this is the default. If you have
changed the location you can specify it with: --with-mysql=/opt/local
for example. Otherwise just use: --with-mysql
*NOTE* If you are using Apache 1.3b6 or later, you should run the
Apache Configure script at least once before compiling PHP. It
doesn't matter how you have Apache configured at this point.
2000-03-27 08:33:47 +08:00
Skip to step 3b at this point.
1999-04-08 05:05:13 +08:00
3. Compile and install the files. Simply type: make install
2000-03-27 08:33:47 +08:00
3a. Dynamic Module Installation
Nothing else is needed here. Proceed to step 4a.
3b. Static Module Installation
1999-04-08 05:05:13 +08:00
For the Apache module version this will copy the appropriate files
2003-07-03 12:14:42 +08:00
to the src/modules/php5 directory in your Apache distribution if
1999-04-08 05:05:13 +08:00
you are using Apache 1.3.x. If you are still running Apache 1.2.x
these files will be copied directly to the main src directory.
For Apache 1.3b6 and later, you can use the new APACI configuration
mechanism. To automatically build Apache with PHP support, use:
cd apache_1.3.x
./configure --prefix=/<path>/apache \
2003-07-03 12:14:42 +08:00
--activate-module=src/modules/php5/libphp5.a
1999-04-08 05:05:13 +08:00
make
make install
If you do not wish to use this new configuration tool, the old
install procedure (src/Configure) will work fine.
If you are using the old Apache ./Configure script, you will have to
edit the Apache src/Configuration file manually. If you do not have
this file, copy Configuration.tmpl to Configuration.
For Apache 1.3.x add:
2003-07-03 12:14:42 +08:00
AddModule modules/php5/libphp5.a
1999-04-08 05:05:13 +08:00
For Apache 1.3.x don't do anything else. Just add this line and then
run "./Configure" followed by "make".
For Apache 1.2.x add:
2003-07-03 12:14:42 +08:00
Module php5_module mod_php5.o
1999-04-08 05:05:13 +08:00
2003-07-03 12:14:42 +08:00
For Apache 1.2.x you will also have to look in the libphp5.module file,
1999-04-08 05:05:13 +08:00
which was copied to the src directory. The EXTRA_LIBS line in the Apache
Configuration file needs to be set to use the same libs as specified on
2003-07-03 12:14:42 +08:00
the LIBS line in libphp5.module. You also need to make sure to add
1999-04-08 05:05:13 +08:00
"-L." to the beginning of the EXTRA_LIBS line.
So, as an example, your EXTRA_LIBS line might look like:
2003-07-03 12:14:42 +08:00
EXTRA_LIBS=-L. -lphp5 -lgdbm -ldb -L/usr/local/mysql/lib -lmysqlclient
1999-04-08 05:05:13 +08:00
NOTE: You should not enclose the EXTRA_LIBS line in double-quotes, as it
2003-07-03 12:14:42 +08:00
is in the libphp5.module file.
1999-04-08 05:05:13 +08:00
2003-07-03 12:14:42 +08:00
Also, look at the RULE_WANTHSREGEX setting in the libphp5.module file
1999-04-08 05:05:13 +08:00
and set the WANTHSREGEX directive accordingly in your Configuration file.
This last step applies to versions of Apache prior to 1.3b3.
This is a bit of a hassle, but should serve as incentive to move to
Apache 1.3.x where this step has been eliminated.
Once you are satisfied with your Configuration settings, type: ./Configure
If you get errors, chances are that you forgot a library or made a typo
somewhere. Re-edit Configuration and try again. If it goes well,
type: make
2000-03-27 08:33:47 +08:00
Assuming it compiles without errors, proceed to step 4b.
4a. Setting up the server. (Dynamic Module)
The make install command in step 3 should have done most of your
work for you. It actually edits your httpd.conf file and tries to
enable the dynamic PHP module. To verify this, look for a line that
looks like this:
2003-07-03 12:14:42 +08:00
LoadModule php5_module libexec/libphp5.so
2000-03-27 08:33:47 +08:00
2003-07-03 12:14:42 +08:00
The actual path before the libphp5.so part might differ slightly. This
2000-03-27 08:33:47 +08:00
is likely fine. If you are paranoid you can examine the output from the
2003-07-03 12:14:42 +08:00
make install step to see where the libphp5.so file was actually put and
2000-03-27 08:33:47 +08:00
place the full path to this file on this LoadModule line.
If somewhere in your httpd.conf file you have a ClearModuleList line
then you also need this line:
2003-07-03 12:14:42 +08:00
AddModule mod_php5.c
2000-03-27 08:33:47 +08:00
And finally you need to tell Apache which file extension should trigger
PHP. You do this by creating a special mime type and associating it
with an extension. We suggest using:
AddType application/x-httpd-php .php
You are however free to use any extension you wish, including .html.
Note! If a line has a # at the beginning, then it is commented out
and you need to remove the # for that line to take effect.
Finally you need to copy php.ini-dist to the appropriate place
(normally /usr/local/lib/php.ini) and edit if necessary.
2000-03-27 08:33:47 +08:00
Once you have made these changes you should be ready to restart your
server and try it out. Type: apachectl restart
4b. Setting up the server. (Static Module)
1999-04-08 05:05:13 +08:00
You should now have a new httpd binary. Shut down your existing server,
if you have one, and copy this new binary overtop of it. Perhaps make
2000-03-27 08:33:47 +08:00
a backup of your previous one first. Then edit your conf/httpd.conf file
1999-04-08 05:05:13 +08:00
and add the line:
AddType application/x-httpd-php .php
1999-04-08 05:05:13 +08:00
There is also an interesting feature which can be quite instructive and
helpful while debugging. That is the option of having colour syntax
highlighting. To enable this, add the following line:
AddType application/x-httpd-php-source .phps
1999-04-08 05:05:13 +08:00
Any file ending in .phps will now be displayed with full colour syntax
highlighting instead of being executed.
Note that on some older server setups, the AddType lines are in the
conf/srm.conf file instead of conf/httpd.conf.
2000-03-27 08:33:47 +08:00
Note! If a line has a # at the beginning, then it is commented out
and you need to remove the # for that line to take effect.
When you are finished making changes to your httpd.conf file, you need
to copy php.ini-dist to the appropriate place (normally
/usr/local/lib/php.ini) and edit if necessary. You can then
start up your server.
5. Testing it all worked
Create a test file named test.php in your web tree somewhere and
put some test PHP tags in it. <?phpinfo()?> is a good first test.
This tag tells PHP to do a braindump and tells you all sorts of things
about itself.
WHY DISABLING -fPIC WORKS ON LINUX
From: Martin v. Loewis <martin@loewis.home.cs.tu-berlin.de>
To: glibc-linux@ricardo.ecn.wfu.edu
Subject: Re: Shared library -shared vs. -fpic
[In reply to Kaz Kylheku <kaz@ashi.footprints.net>]
> PIC stands for Position-Independent Code.
Correct.
> Code isn't position-independent (or ``relocatable'') cannot be
> loaded at an arbitrary address;
Wrong.
> it requires some references to be patched at load time.
Correct.
> Shared libraries need to be relocatable because it's not known
> beforehand what address they will be loaded at
Correct, depending on the meaning of "relocatable". PIC code typically
does not contain relocations; that's why its position-independent.
> Just because you don't specify -fPIC doesn't mean that the compiler
> won't emit position-independent code; the option prevents it from
> emitting position-dependent code in situations where it otherwise
> would.
Correct. However, a non-trivial shared library typically won't be
position-independent unless explicitly compiled with
-fPIC. Linux/glibc indeed does not require a shared library to be
position-independent; instead, it will perform the relocations in the
binary, even if they refer to code pages. As a result, those relocated
pages won't be shared across processes, anymore.
Regards,
Martin
2000-05-15 22:40:20 +08:00
USING PHP 3 AND PHP 4 AS CONCURRENT APACHE MODULES
With some (newer) installations of Apache, it's possible to compile both
PHP 3 and PHP 4, and run them concurrently.
Note, it's only really wise to do this if you need to use the PHP 3 engine
to maintain backwards compatibility.
2000-05-15 22:40:20 +08:00
To enable it, configure PHP 3 and PHP 4 to use APXS (--with-apxs) and the
necessary link extensions (--enable-versioning). Otherwise, all standard
installations instructions apply. For example:
$ ./configure \
--with-apxs=/apache/bin/apxs \
--enable-versioning \
--with-mysql \