summaryrefslogtreecommitdiff
path: root/INSTALL
blob: 2d1f8eb68af9fbf9862cc67b9e4c94b360ccdb03 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
Installation Instructions for PHP 4.1
-------------------------------------

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

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.  

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.  

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.

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


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:

$ gunzip -c php-4.1.x.tar.gz | tar xf -
$ cd php-4.1.x
$ ./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

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.

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)

$ gunzip -c apache_1.3.x.tar.gz | tar xf -
$ cd apache_1.3.x
$ ./configure
$ cd ..

$ gunzip -c php-4.1.x.tar.gz | tar xf -
$ cd php-4.1.x
$ ./configure --with-mysql --with-apache=../apache_1.3.x
$ make
$ make install

$ cd ../apache_1.3.x
$ ./configure --prefix=/www --activate-module=src/modules/php4/libphp4.a
 (The above line is correct!  Yes, we know libphp4.a does not exist at this
  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)
$ cd ../php-4.1.x
$ cp php.ini-dist /usr/local/lib/php.ini
You can edit /usr/local/lib/php.ini file to set PHP options.
Edit your httpd.conf or srm.conf file and add:
  AddType application/x-httpd-php .php


VERBOSE INSTALL

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:

1. Unpack your distribution file.  

   You will have downloaded a file named something like php-4.1.x.tar.gz.
   Unzip this file with a command like: gunzip php-4.1.x.tar.gz

   Next you have to untar it with: tar -xvf php-4.1.x.tar

   This will create a php-4.1.x directory.  cd into this new directory.

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

   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

   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.

   Skip to step 3b at this point.

3. Compile and install the files.  Simply type: make install

3a.   Dynamic Module Installation

   Nothing else is needed here.  Proceed to step 4a.

3b.   Static Module Installation

   For the Apache module version this will copy the appropriate files
   to the src/modules/php4 directory in your Apache distribution if
   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 \
                   --activate-module=src/modules/php4/libphp4.a
       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:

      AddModule modules/php4/libphp4.a

   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:

      Module php4_module mod_php4.o

   For Apache 1.2.x you will also have to look in the libphp4.module file,
   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
   the LIBS line in libphp4.module. You also need to make sure to add
   "-L." to the beginning of the EXTRA_LIBS line.

   So, as an example, your EXTRA_LIBS line might look like:

	EXTRA_LIBS=-L. -lphp4 -lgdbm -ldb -L/usr/local/mysql/lib -lmysqlclient

   NOTE: You should not enclose the EXTRA_LIBS line in double-quotes, as it
   is in the libphp4.module file.

   Also, look at the RULE_WANTHSREGEX setting in the libphp4.module file 
   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

   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:

      LoadModule php4_module libexec/libphp4.so

   The actual path before the libphp4.so part might differ slightly.  This
   is likely fine.  If you are paranoid you can examine the output from the
   make install step to see where the libphp4.so file was actually put and
   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:

      AddModule mod_php4.c

   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.

   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)
   
   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
   a backup of your previous one first.  Then edit your conf/httpd.conf file
   and add the line:

      AddType application/x-httpd-php .php

   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

   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.

   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

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. 
   
   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 \