php-src / INSTALL

   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
 412
 413
 414
 415
 416
 417
 418
 419
 420
 421
 422
 423
 424
 425
 426
 427
 428
 429
 430
 431
 432
 433
 434
 435
 436
 437
 438
 439
 440
 441
 442
 443
 444
 445
 446
 447
 448
 449
 450
 451
 452
 453
 454
 455
 456
 457
 458
 459
 460
 461
 462
 463
 464
 465
 466
 467
 468
 469
 470
 471
 472
 473
 474
 475
 476
 477
 478
 479
 480
 481
 482
 483
 484
 485
 486
 487
 488
 489
 490
 491
 492
 493
 494
 495
 496
 497
 498
 499
 500
 501
 502
 503
 504
 505
 506
 507
 508
 509
 510
 511
 512
 513
 514
 515
 516
 517
 518
 519
 520
 521
 522
 523
 524
 525
 526
 527
 528
 529
 530
 531
 532
 533
 534
 535
 536
 537
 538
 539
 540
 541
 542
 543
 544
 545
 546
 547
 548
 549
 550
 551
 552
 553
 554
 555
 556
 557
 558
 559
 560
 561
 562
 563
 564
 565
 566
 567
 568
 569
 570
 571
 572
 573
 574
 575
 576
 577
 578
 579
 580
 581
 582
 583
 584
 585
 586
 587
 588
 589
 590
 591
 592
 593
 594
 595
 596
 597
 598
 599
 600
 601
 602
 603
 604
 605
 606
 607
 608
 609
 610
 611
 612
 613
 614
 615
 616
 617
 618
 619
 620
 621
 622
 623
 624
 625
 626
 627
 628
 629
 630
 631
 632
 633
 634
 635
 636
 637
 638
 639
 640
 641
 642
 643
 644
 645
 646
 647
 648
 649
 650
 651
 652
 653
 654
 655
 656
 657
 658
 659
 660
 661
 662
 663
 664
 665
 666
 667
 668
 669
 670
 671
 672
 673
 674
 675
 676
 677
 678
 679
 680
 681
 682
 683
 684
 685
 686
 687
 688
 689
 690
 691
 692
 693
 694
 695
 696
 697
 698
 699
 700
 701
 702
 703
 704
 705
 706
 707
 708
 709
 710
 711
 712
 713
 714
 715
 716
 717
 718
 719
 720
 721
 722
 723
 724
 725
 726
 727
 728
 729
 730
 731
 732
 733
 734
 735
 736
 737
 738
 739
 740
 741
 742
 743
 744
 745
 746
 747
 748
 749
 750
 751
 752
 753
 754
 755
 756
 757
 758
 759
 760
 761
 762
 763
 764
 765
 766
 767
 768
 769
 770
 771
 772
 773
 774
 775
 776
 777
 778
 779
 780
 781
 782
 783
 784
 785
 786
 787
 788
 789
 790
 791
 792
 793
 794
 795
 796
 797
 798
 799
 800
 801
 802
 803
 804
 805
 806
 807
 808
 809
 810
 811
 812
 813
 814
 815
 816
 817
 818
 819
 820
 821
 822
 823
 824
 825
 826
 827
 828
 829
 830
 831
 832
 833
 834
 835
 836
 837
 838
 839
 840
 841
 842
 843
 844
 845
 846
 847
 848
 849
 850
 851
 852
 853
 854
 855
 856
 857
 858
 859
 860
 861
 862
 863
 864
 865
 866
 867
 868
 869
 870
 871
 872
 873
 874
 875
 876
 877
 878
 879
 880
 881
 882
 883
 884
 885
 886
 887
 888
 889
 890
 891
 892
 893
 894
 895
 896
 897
 898
 899
 900
 901
 902
 903
 904
 905
 906
 907
 908
 909
 910
 911
 912
 913
 914
 915
 916
 917
 918
 919
 920
 921
 922
 923
 924
 925
 926
 927
 928
 929
 930
 931
 932
 933
 934
 935
 936
 937
 938
 939
 940
 941
 942
 943
 944
 945
 946
 947
 948
 949
 950
 951
 952
 953
 954
 955
 956
 957
 958
 959
 960
 961
 962
 963
 964
 965
 966
 967
 968
 969
 970
 971
 972
 973
 974
 975
 976
 977
 978
 979
 980
 981
 982
 983
 984
 985
 986
 987
 988
 989
 990
 991
 992
 993
 994
 995
 996
 997
 998
 999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
Installing PHP
     _________________________________________________________________

   Table of Contents
   Preface
   1. General Installation Considerations
   2. Installation on Unix systems

        Apache 1.3.x on Unix systems
        Apache 2.0 on Unix systems
        Caudium
        fhttpd related notes
        Sun, iPlanet and Netscape servers on Sun Solaris
        CGI and commandline setups
        HP-UX specific installation notes
        OpenBSD installation notes
        Solaris specific installation tips
        Gentoo installation notes

   3. Installation on Mac OS X

        Using Packages
        Compiling for OS X Server
        Compiling for MacOS X Client

   4. Installation of PECL extensions

        Introduction to PECL Installations
        Downloading PECL extensions
        PECL for Windows users
        Compiling shared PECL extensions with PEAR
        Compiling shared PECL extensions with phpize
        Compiling PECL extensions statically into PHP

   5. Problems?

        Read the FAQ
        Other problems
        Bug reports

   6. Runtime Configuration

        The configuration file
        How to change configuration settings
     _________________________________________________________________

Preface

   These installation instructions were generated from the HTML version
   of the PHP Manual so formatting and linking have been altered. See the
   online and updated version at: http://php.net/install.unix
     _________________________________________________________________

Chapter 1. General Installation Considerations

   Before starting the installation, first you need to know what do you
   want to use PHP for. There are three main fields you can use PHP, as
   described in the What can PHP do? section:

     * Server-side scripting
     * Command line scripting
     * Client-side GUI applications

   For the first and most common form, you need three things: PHP itself,
   a web server and a web browser. You probably already have a web
   browser, and depending on your operating system setup, you may also
   have a web server (e.g. Apache on Linux and MacOS X; IIS on Windows).
   You may also rent webspace at a company. This way, you don't need to
   set up anything on your own, only write your PHP scripts, upload it to
   the server you rent, and see the results in your browser.

   While setting up the server and PHP on your own, you have two choices
   for the method of connecting PHP to the server. For many servers PHP
   has a direct module interface (also called SAPI). These servers
   include Apache, Microsoft Internet Information Server, Netscape and
   iPlanet servers. Many other servers have support for ISAPI, the
   Microsoft module interface (OmniHTTPd for example). If PHP has no
   module support for your web server, you can always use it as a CGI or
   FastCGI processor. This means you set up your server to use the CGI
   executable of PHP to process all PHP file requests on the server.

   If you are also interested to use PHP for command line scripting (e.g.
   write scripts autogenerating some images for you offline, or
   processing text files depending on some arguments you pass to them),
   you always need the command line executable. For more information,
   read the section about writing command line PHP applications. In this
   case, you need no server and no browser.

   With PHP you can also write desktop GUI applications using the PHP-GTK
   extension. This is a completely different approach than writing web
   pages, as you do not output any HTML, but manage windows and objects
   within them. For more information about PHP-GTK, please visit the site
   dedicated to this extension. PHP-GTK is not included in the official
   PHP distribution.

   From now on, this section deals with setting up PHP for web servers on
   Unix and Windows with server module interfaces and CGI executables.
   You will also find information on the command line executable in the
   following sections.

   PHP source code and binary distributions for Windows can be found at
   http://www.php.net/downloads.php. We recommend you to choose a mirror
   nearest to you for downloading the distributions.
     _________________________________________________________________

Chapter 2. Installation on Unix systems

   This section will guide you through the general configuration and
   installation of PHP on Unix systems. Be sure to investigate any
   sections specific to your platform or web server before you begin the
   process.

   As our manual outlines in the General Installation Considerations
   section, we are mainly dealing with web centric setups of PHP in this
   section, although we will cover setting up PHP for command line usage
   as well.

   There are several ways to install PHP for the Unix platform, either
   with a compile and configure process, or through various pre-packaged
   methods. This documentation is mainly focused around the process of
   compiling and configuring PHP. Many Unix like systems have some sort
   of package installation system. This can assist in setting up a
   standard configuration, but if you need to have a different set of
   features (such as a secure server, or a different database driver),
   you may need to build PHP and/or your webserver. If you are unfamiliar
   with building and compiling your own software, it is worth checking to
   see whether somebody has already built a packaged version of PHP with
   the features you need.

   Prerequisite knowledge and software for compiling:

     * Basic Unix skills (being able to operate "make" and a C compiler)
     * An ANSI C compiler
     * flex: Version 2.5.4
     * bison: Version 1.28 (preferred), 1.35, or 1.75
     * A web server
     * Any module specific components (such as gd, pdf libs, etc.)

   The initial PHP setup and configuration process is controlled by the
   use of the commandline options of the configure script. You could get
   a list of all available options along with short explanations running
   ./configure --help. Our manual documents the different options
   separately. You will find the core options in the appendix, while the
   different extension specific options are descibed on the reference
   pages.

   When PHP is configured, you are ready to build the module and/or
   executables. The command make should take care of this. If it fails
   and you can't figure out why, see the Problems section.
     _________________________________________________________________

Apache 1.3.x on Unix systems

   This section contains notes and hints specific to Apache installs of
   PHP on Unix platforms. We also have instructions and notes for Apache
   2 on a separate page.

   You can select arguments to add to the configure on line 10 below from
   the list of core configure options and from extension specific options
   described at the respective places in the manual. The version numbers
   have been omitted here, to ensure the instructions are not incorrect.
   You will need to replace the 'xxx' here with the correct values from
   your files.

   Example 2-1. Installation Instructions (Apache Shared Module Version)
   for PHP 
1.  gunzip apache_xxx.tar.gz
2.  tar -xvf apache_xxx.tar
3.  gunzip php-xxx.tar.gz
4.  tar -xvf php-xxx.tar
5.  cd apache_xxx
6.  ./configure --prefix=/www --enable-module=so
7.  make
8.  make install
9.  cd ../php-xxx

10. Now, configure your PHP.  This is where you customize your PHP
    with various options, like which extensions will be enabled.  Do a
    ./configure --help for a list of available options.  In our example
    we'll do a simple configure with Apache 1 and MySQL support.  Your
    path to apxs may differ from our example.

      ./configure --with-mysql --with-apxs=/www/bin/apxs

11. make
12. make install

    If you decide to change your configure options after installation,
    you only need to repeat the last three steps. You only need to
    restart apache for the new module to take effect. A recompile of
    Apache is not needed.

    Note that unless told otherwise, 'make install' will also install PEAR,
    various PHP tools such as phpize, install the PHP CLI, and more.

13. Setup your php.ini file:

      cp php.ini-dist /usr/local/lib/php.ini

    You may edit your .ini file to set PHP options.  If you prefer your
    php.ini in another location, use --with-config-file-path=/some/path in
    step 10.

    If you instead choose php.ini-recommended, be certain to read the list
    of changes within, as they affect how PHP behaves.

14. Edit your httpd.conf to load the PHP module.  The path on the right hand
    side of the LoadModule statement must point to the path of the PHP
    module on your system.  The make install from above may have already
    added this for you, but be sure to check.

    For PHP 4:

      LoadModule php4_module libexec/libphp4.so

    For PHP 5:

      LoadModule php5_module libexec/libphp5.so

15. And in the AddModule section of httpd.conf, somewhere under the
    ClearModuleList, add this:

    For PHP 4:

      AddModule mod_php4.c

    For PHP 5:

      AddModule mod_php5.c

16. Tell Apache to parse certain extensions as PHP.  For example,
    let's have Apache parse the .php extension as PHP.  You could
    have any extension(s) parse as PHP by simply adding more, with
    each separated by a space.  We'll add .phtml to demonstrate.

      AddType application/x-httpd-php .php .phtml

    It's also common to setup the .phps extension to show highlighted PHP
    source, this can be done with:

      AddType application/x-httpd-php-source .phps

17. Use your normal procedure for starting the Apache server. (You must
    stop and restart the server, not just cause the server to reload by
    using a HUP or USR1 signal.)

   Alternatively, to install PHP as a static object:

   Example 2-2. Installation Instructions (Static Module Installation for
   Apache) for PHP 
1.  gunzip -c apache_1.3.x.tar.gz | tar xf -
2.  cd apache_1.3.x
3.  ./configure
4.  cd ..

5.  gunzip -c php-4.x.y.tar.gz | tar xf -
6.  cd php-4.x.y
7.  ./configure --with-mysql --with-apache=../apache_1.3.x
8.  make
9.  make install

10. cd ../apache_1.3.x

11. ./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.)

12. 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)

13. cd ../php-4.x.y
14. cp php.ini-dist /usr/local/lib/php.ini

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

   Depending on your Apache install and Unix variant, there are many
   possible ways to stop and restart the server. Below are some typical
   lines used in restarting the server, for different apache/unix
   installations. You should replace /path/to/ with the path to these
   applications on your systems.

   Example 2-3. Example commands for restarting Apache
1. Several Linux and SysV variants:
/etc/rc.d/init.d/httpd restart

2. Using apachectl scripts:
/path/to/apachectl stop
/path/to/apachectl start

3. httpdctl and httpsdctl (Using OpenSSL), similar to apachectl:
/path/to/httpsdctl stop
/path/to/httpsdctl start

4. Using mod_ssl, or another SSL server, you may want to manually
stop and start:
/path/to/apachectl stop
/path/to/apachectl startssl

   The locations of the apachectl and http(s)dctl binaries often vary. If
   your system has locate or whereis or which commands, these can assist
   you in finding your server control programs.

   Different examples of compiling PHP for apache are as follows:

   ./configure --with-apxs --with-pgsql

   This will create a libphp4.so shared library that is loaded into
   Apache using a LoadModule line in Apache's httpd.conf file. The
   PostgreSQL support is embedded into this libphp4.so library.

   ./configure --with-apxs --with-pgsql=shared

   This will create a libphp4.so shared library for Apache, but it will
   also create a pgsql.so shared library that is loaded into PHP either
   by using the extension directive in php.ini file or by loading it
   explicitly in a script using the dl() function.

   ./configure --with-apache=/path/to/apache_source --with-pgsql

   This will create a libmodphp4.a library, a mod_php4.c and some
   accompanying files and copy this into the src/modules/php4 directory
   in the Apache source tree. Then you compile Apache using
   --activate-module=src/modules/php4/libphp4.a and the Apache build
   system will create libphp4.a and link it statically into the httpd
   binary. The PostgreSQL support is included directly into this httpd
   binary, so the final result here is a single httpd binary that
   includes all of Apache and all of PHP.

   ./configure --with-apache=/path/to/apache_source --with-pgsql=shared

   Same as before, except instead of including PostgreSQL support
   directly into the final httpd you will get a pgsql.so shared library
   that you can load into PHP from either the php.ini file or directly
   using dl().

   When choosing to build PHP in different ways, you should consider the
   advantages and drawbacks of each method. Building as a shared object
   will mean that you can compile apache separately, and don't have to
   recompile everything as you add to, or change, PHP. Building PHP into
   apache (static method) means that PHP will load and run faster. For
   more information, see the Apache webpage on DSO support.

     Note: Apache's default httpd.conf currently ships with a section
     that looks like this:

User nobody
Group "#-1"

     Unless you change that to "Group nogroup" or something like that
     ("Group daemon" is also very common) PHP will not be able to open
     files.

     Note: Make sure you specify the installed version of apxs when
     using --with-apxs=/path/to/apxs. You must NOT use the apxs version
     that is in the apache sources but the one that is actually
     installed on your system.
     _________________________________________________________________

Apache 2.0 on Unix systems

   This section contains notes and hints specific to Apache 2.0 installs
   of PHP on Unix systems.

   Warning

   We do not recommend using a threaded MPM in production with Apache2.
   Use the prefork MPM instead, or use Apache1. For information on why,
   read the related FAQ entry on using Apache2 with a threaded MPM

   You are highly encouraged to take a look at the Apache Documentation
   to get a basic understanding of the Apache 2.0 Server.

     PHP and Apache 2.0.x compatibility notes: The following versions of
     PHP are known to work with the most recent version of Apache 2.0.x:

     * PHP 4.3.0 or later available at http://www.php.net/downloads.php.
     * the latest stable development version. Get the source code
       http://snaps.php.net/php4-latest.tar.gz or download binaries for
       Windows http://snaps.php.net/win32/php4-win32-latest.zip.
     * a prerelease version downloadable from http://qa.php.net/.
     * you have always the option to obtain PHP through anonymous CVS.

     These versions of PHP are compatible to Apache 2.0.40 and later.

     Apache 2.0 SAPI-support started with PHP 4.2.0. PHP 4.2.3 works
     with Apache 2.0.39, don't use any other version of Apache with PHP
     4.2.3. However, the recommended setup is to use PHP 4.3.0 or later
     with the most recent version of Apache2.

     All mentioned versions of PHP will work still with Apache 1.3.x.

   Download the most recent version of Apache 2.0 and a fitting PHP
   version from the above mentioned places. This quick guide covers only
   the basics to get started with Apache 2.0 and PHP. For more
   information read the Apache Documentation. The version numbers have
   been omitted here, to ensure the instructions are not incorrect. You
   will need to replace the 'NN' here with the correct values from your
   files.

   Example 2-4. Installation Instructions (Apache 2 Shared Module
   Version) 
1.  gzip -d httpd-2_0_NN.tar.gz
2.  tar xvf httpd-2_0_NN.tar
3.  gunzip php-NN.tar.gz
4.  tar -xvf php-NN.tar
5.  cd httpd-2_0_NN
6.  ./configure --enable-so
7.  make
8.  make install

    Now you have Apache 2.0.NN available under /usr/local/apache2,
    configured with loadable module support and the standard MPM prefork.
    To test the installation use your normal procedure for starting
    the Apache server, e.g.:
    /usr/local/apache2/bin/apachectl start
    and stop the server to go on with the configuration for PHP:
    /usr/local/apache2/bin/apachectl stop.

9.  cd ../php-NN

10. Now, configure your PHP.  This is where you customize your PHP
    with various options, like which extensions will be enabled.  Do a
    ./configure --help for a list of available options.  In our example
    we'll do a simple configure with Apache 2 and MySQL support.  Your
    path to apxs may differ, in fact, the binary may even be named apxs2 on
    your system.

      ./configure --with-apxs2=/usr/local/apache2/bin/apxs --with-mysql

11. make
12. make install

    If you decide to change your configure options after installation,
    you only need to repeat the last three steps. You only need to
    restart apache for the new module to take effect. A recompile of
    Apache is not needed.

    Note that unless told otherwise, 'make install' will also install PEAR,
    various PHP tools such as phpize, install the PHP CLI, and more.

13. Setup your php.ini

    cp php.ini-dist /usr/local/lib/php.ini

    You may edit your .ini file to set PHP options.  If you prefer having
    php.ini in another location, use --with-config-file-path=/some/path in
    step 10.

    If you instead choose php.ini-recommended, be certain to read the list
    of changes within, as they affect how PHP behaves.

14. Edit your httpd.conf to load the PHP module.  The path on the right hand
    side of the LoadModule statement must point to the path of the PHP
    module on your system.  The make install from above may have already
    added this for you, but be sure to check.

    For PHP 4:

      LoadModule php4_module libexec/libphp4.so

    For PHP 5:

      LoadModule php5_module libexec/libphp5.so

15. Tell Apache to parse certain extensions as PHP.  For example,
    let's have Apache parse the .php extension as PHP.  You could
    have any extension(s) parse as PHP by simply adding more, with
    each separated by a space.  We'll add .phtml to demonstrate.

      AddType application/x-httpd-php .php .phtml

    It's also common to setup the .phps extension to show highlighted PHP
    source, this can be done with:

      AddType application/x-httpd-php-source .phps

16. Use your normal procedure for starting the Apache server, e.g.:

      /usr/local/apache2/bin/apachectl start

   Following the steps above you will have a running Apache 2.0 with
   support for PHP as SAPI module. Of course there are many more
   configuration options available for both, Apache and PHP. For more
   information use ./configure --help in the corresponding source tree.
   In case you wish to build a multithreaded version of Apache 2.0 you
   must overwrite the standard MPM-Module prefork either with worker or
   perchild. To do so append to your configure line in step 6 above
   either the option --with-mpm=worker or --with-mpm=perchild. Take care
   about the consequences and understand what you are doing. For more
   information read the Apache documentation about the MPM-Modules.

     Note: If you want to use content negotiation, read the Apache
     MultiViews FAQ.

     Note: To build a multithreaded version of Apache your system must
     support threads. This also implies to build PHP with experimental
     Zend Thread Safety (ZTS). Therefore not all extensions might be
     available. The recommended setup is to build Apache with the
     standard prefork MPM-Module.
     _________________________________________________________________

Caudium

   PHP 4 can be built as a Pike module for the Caudium webserver. Note
   that this is not supported with PHP 3. Follow the simple instructions
   below to install PHP 4 for Caudium.

   Example 2-5. Caudium Installation Instructions
1.  Make sure you have Caudium installed prior to attempting to
    install PHP 4. For PHP 4 to work correctly, you will need Pike
    7.0.268 or newer. For the sake of this example we assume that
    Caudium is installed in /opt/caudium/server/.
2.  Change directory to php-x.y.z (where x.y.z is the version number).
3.  ./configure --with-caudium=/opt/caudium/server
4.  make
5.  make install
6.  Restart Caudium if it's currently running.
7.  Log into the graphical configuration interface and go to the
    virtual server where you want to add PHP 4 support.
8.  Click Add Module and locate and then add the PHP 4 Script Support module.
9.  If the documentation says that the 'PHP 4 interpreter isn't
    available', make sure that you restarted the server. If you did
    check /opt/caudium/logs/debug/default.1 for any errors related to
    <filename>PHP4.so</filename>. Also make sure that
    <filename>caudium/server/lib/[pike-version]/PHP4.so</filename>
    is present.
10. Configure the PHP Script Support module if needed.

   You can of course compile your Caudium module with support for the
   various extensions available in PHP 4. See the reference pages for
   extension specific configure options.

     Note: When compiling PHP 4 with MySQL support you must make sure
     that the normal MySQL client code is used. Otherwise there might be
     conflicts if your Pike already has MySQL support. You do this by
     specifying a MySQL install directory the --with-mysql option.
     _________________________________________________________________

fhttpd related notes

   To build PHP as an fhttpd module, answer "yes" to "Build as an fhttpd
   module?" (the --with-fhttpd=DIR option to configure) and specify the
   fhttpd source base directory. The default directory is
   /usr/local/src/fhttpd. If you are running fhttpd, building PHP as a
   module will give better performance, more control and remote execution
   capability.

     Note: Support for fhttpd is no longer available as of PHP 4.3.0.
     _________________________________________________________________

Sun, iPlanet and Netscape servers on Sun Solaris

   This section contains notes and hints specific to Sun Java System Web
   Server, Sun ONE Web Server, iPlanet and Netscape server installs of
   PHP on Sun Solaris.

   From PHP 4.3.3 on you can use PHP scripts with the NSAPI module to
   generate custom directory listings and error pages. Additional
   functions for Apache compatibility are also available. For support in
   current webservers read the note about subrequests.

   You can find more information about setting up PHP for the Netscape
   Enterprise Server (NES) here:
   http://benoit.noss.free.fr/php/install-php4.html

   To build PHP with Sun JSWS/Sun ONE WS/iPlanet/Netscape webservers,
   enter the proper install directory for the --with-nsapi=[DIR] option.
   The default directory is usually /opt/netscape/suitespot/. Please also
   read /php-xxx-version/sapi/nsapi/nsapi-readme.txt.

    1. Install the following packages from http://www.sunfreeware.com/ or
       another download site:

       autoconf-2.13
       automake-1.4
       bison-1_25-sol26-sparc-local
       flex-2_5_4a-sol26-sparc-local
       gcc-2_95_2-sol26-sparc-local
       gzip-1.2.4-sol26-sparc-local
       m4-1_4-sol26-sparc-local
       make-3_76_1-sol26-sparc-local
       mysql-3.23.24-beta (if you want mysql support)
       perl-5_005_03-sol26-sparc-local
       tar-1.13 (GNU tar)
    2. Make sure your path includes the proper directories
       PATH=.:/usr/local/bin:/usr/sbin:/usr/bin:/usr/ccs/bin and make it
       available to your system export PATH.
    3. gunzip php-x.x.x.tar.gz (if you have a .gz dist, otherwise go to
       4).
    4. tar xvf php-x.x.x.tar
    5. Change to your extracted PHP directory: cd ../php-x.x.x
    6. For the following step, make sure /opt/netscape/suitespot/ is
       where your netscape server is installed. Otherwise, change to the
       correct path and run:

./configure --with-mysql=/usr/local/mysql \
--with-nsapi=/opt/netscape/suitespot/ \
--enable-libgcc

    7. Run make followed by make install.

   After performing the base install and reading the appropriate readme
   file, you may need to perform some additional configuration steps.

   Configuration Instructions for Sun/iPlanet/Netscape. Firstly you may
   need to add some paths to the LD_LIBRARY_PATH environment for the
   server to find all the shared libs. This can best done in the start
   script for your webserver. The start script is often located in:
   /path/to/server/https-servername/start. You may also need to edit the
   configuration files that are located in:
   /path/to/server/https-servername/config/.

    1. Add the following line to mime.types (you can do that by the
       administration server):

type=magnus-internal/x-httpd-php exts=php

    2. Edit magnus.conf (for servers >= 6) or obj.conf (for servers < 6)
       and add the following, shlib will vary depending on your system,
       it will be something like /opt/netscape/suitespot/bin/libphp4.so.
       You should place the following lines after mime types init.

Init fn="load-modules" funcs="php4_init,php4_execute,php4_auth_trans" shlib="/o
pt/netscape/suitespot/bin/libphp4.so"
Init fn="php4_init" LateInit="yes" errorString="Failed to initialize PHP!" [php
_ini="/path/to/php.ini"]

       (PHP >= 4.3.3) The php_ini parameter is optional but with it you
       can place your php.ini in your webserver config directory.
    3. Configure the default object in obj.conf (for virtual server
       classes [version 6.0+] in their vserver.obj.conf):

<Object name="default">
.
.
.
.#NOTE this next line should happen after all 'ObjectType' and before all 'AddL
og' lines
Service fn="php4_execute" type="magnus-internal/x-httpd-php" [inikey=value inik
ey=value ...]
.
.
</Object>

       (PHP >= 4.3.3) As additional parameters you can add some special
       php.ini-values, for example you can set a
       docroot="/path/to/docroot" specific to the context php4_execute is
       called. For boolean ini-keys please use 0/1 as value, not
       "On","Off",... (this will not work correctly), e.g.
       zlib.output_compression=1 instead of zlib.output_compression="On"
    4. This is only needed if you want to configure a directory that only
       consists of PHP scripts (same like a cgi-bin directory):

<Object name="x-httpd-php">
ObjectType fn="force-type" type="magnus-internal/x-httpd-php"
Service fn=php4_execute [inikey=value inikey=value ...]
</Object>

       After that you can configure a directory in the Administration
       server and assign it the style x-httpd-php. All files in it will
       get executed as PHP. This is nice to hide PHP usage by renaming
       files to .html.
    5. Setup of authentication: PHP authentication cannot be used with
       any other authentication. ALL AUTHENTICATION IS PASSED TO YOUR PHP
       SCRIPT. To configure PHP Authentication for the entire server, add
       the following line to your default object:

<Object name="default">
AuthTrans fn=php4_auth_trans
.
.
.
</Object>

    6. To use PHP Authentication on a single directory, add the
       following:

<Object ppath="d:\path\to\authenticated\dir\*">
AuthTrans fn=php4_auth_trans
</Object>

     Note: The stacksize that PHP uses depends on the configuration of
     the webserver. If you get crashes with very large PHP scripts, it
     is recommended to raise it with the Admin Server (in the section
     "MAGNUS EDITOR").
     _________________________________________________________________

CGI environment and recommended modifications in php.ini

   Important when writing PHP scripts is the fact that Sun JSWS/Sun ONE
   WS/iPlanet/Netscape is a multithreaded web server. Because of that all
   requests are running in the same process space (the space of the
   webserver itself) and this space has only one environment. If you want
   to get CGI variables like PATH_INFO, HTTP_HOST etc. it is not the
   correct way to try this in the old PHP 3.x way with getenv() or a
   similar way (register globals to environment, $_ENV). You would only
   get the environment of the running webserver without any valid CGI
   variables!

     Note: Why are there (invalid) CGI variables in the environment?

     Answer: This is because you started the webserver process from the
     admin server which runs the startup script of the webserver, you
     wanted to start, as a CGI script (a CGI script inside of the admin
     server!). This is why the environment of the started webserver has
     some CGI environment variables in it. You can test this by starting
     the webserver not from the administration server. Use the command
     line as root user and start it manually - you will see there are no
     CGI-like environment variables.

   Simply change your scripts to get CGI variables in the correct way for
   PHP 4.x by using the superglobal $_SERVER. If you have older scripts
   which use $HTTP_HOST, etc., you should turn on register_globals in
   php.ini and change the variable order too (important: remove "E" from
   it, because you do not need the environment here):
variables_order = "GPCS"
register_globals = On
     _________________________________________________________________

Special use for error pages or self-made directory listings (PHP >= 4.3.3)

   You can use PHP to generate the error pages for "404 Not Found" or
   similar. Add the following line to the object in obj.conf for every
   error page you want to overwrite:
Error fn="php4_execute" code=XXX script="/path/to/script.php" [inikey=value ini
key=value...]

   where XXX is the HTTP error code. Please delete any other Error
   directives which could interfere with yours. If you want to place a
   page for all errors that could exist, leave the code parameter out.
   Your script can get the HTTP status code with $_SERVER['ERROR_TYPE'].

   Another possibility is to generate self-made directory listings. Just
   create a PHP script which displays a directory listing and replace the
   corresponding default Service line for
   type="magnus-internal/directory" in obj.conf with the following:
Service fn="php4_execute" type="magnus-internal/directory" script="/path/to/scr
ipt.php" [inikey=value inikey=value...]

   For both error and directory listing pages the original URI and
   translated URI are in the variables $_SERVER['PATH_INFO'] and
   $_SERVER['PATH_TRANSLATED'].
     _________________________________________________________________

Note about nsapi_virtual() and subrequests (PHP >= 4.3.3)

   The NSAPI module now supports the nsapi_virtual() function (alias:
   virtual()) to make subrequests on the webserver and insert the result
   in the webpage. This function uses some undocumented features from the
   NSAPI library. On Unix the module automatically looks for the needed
   functions and uses them if available. If not, nsapi_virtual() is
   disabled.

     Note: But be warned: Support for nsapi_virtual() is EXPERIMENTAL!!!
     _________________________________________________________________

CGI and commandline setups

   The default is to build PHP as a CGI program. This creates a
   commandline interpreter, which can be used for CGI processing, or for
   non-web-related PHP scripting. If you are running a web server PHP has
   module support for, you should generally go for that solution for
   performance reasons. However, the CGI version enables users to run
   different PHP-enabled pages under different user-ids.

   Warning

   By using the CGI setup, your server is open to several possible
   attacks. Please read our CGI security section to learn how to defend
   yourself from those attacks.

   As of PHP 4.3.0, some important additions have happened to PHP. A new
   SAPI named CLI also exists and it has the same name as the CGI binary.
   What is installed at {PREFIX}/bin/php depends on your configure line
   and this is described in detail in the manual section named Using PHP
   from the command line. For further details please read that section of
   the manual.
     _________________________________________________________________

Testing

   If you have built PHP as a CGI program, you may test your build by
   typing make test. It is always a good idea to test your build. This
   way you may catch a problem with PHP on your platform early instead of
   having to struggle with it later.
     _________________________________________________________________

Benchmarking

   If you have built PHP 3 as a CGI program, you may benchmark your build
   by typing make bench. Note that if safe mode is on by default, the
   benchmark may not be able to finish if it takes longer then the 30
   seconds allowed. This is because the set_time_limit() can not be used
   in safe mode. Use the max_execution_time configuration setting to
   control this time for your own scripts. make bench ignores the
   configuration file.

     Note: make bench is only available for PHP 3.
     _________________________________________________________________

Using Variables

   Some server supplied environment variables are not defined in the
   current CGI/1.1 specification. Only the following variables are
   defined there: AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE,
   GATEWAY_INTERFACE, PATH_INFO, PATH_TRANSLATED, QUERY_STRING,
   REMOTE_ADDR, REMOTE_HOST, REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD,
   SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PROTOCOL, and
   SERVER_SOFTWARE. Everything else should be treated as 'vendor
   extensions'.
     _________________________________________________________________

HP-UX specific installation notes

   This section contains notes and hints specific to installing PHP on
   HP-UX systems. (Contributed by paul_mckay at clearwater-it dot co dot
   uk).

     Note: These tips were written for PHP 4.0.4 and Apache 1.3.9.

    1. You need gzip, download a binary distribution from
       http://hpux.connect.org.uk/ftp/hpux/Gnu/gzip-1.2.4a/gzip-1.2.4a-sd
       -10.20.depot.Z uncompress the file and install using swinstall.
    2. You need gcc, download a binary distribution from
       http://gatekeep.cs.utah.edu/ftp/hpux/Gnu/gcc-2.95.2/gcc-2.95.2-sd-
       10.20.depot.gz. uncompress this file and install gcc using
       swinstall.
    3. You need the GNU binutils, you can download a binary distribution
       from
       http://hpux.connect.org.uk/ftp/hpux/Gnu/binutils-2.9.1/binutils-2.
       9.1-sd-10.20.depot.gz. uncompress this file and install binutils
       using swinstall.
    4. You now need bison, you can download a binary distribution from
       http://hpux.connect.org.uk/ftp/hpux/Gnu/bison-1.28/bison-1.28-sd-1
       0.20.depot.gz, install as above.
    5. You now need flex, you need to download the source from one of the
       http://www.gnu.org mirrors. It is in the non-gnu directory of the
       ftp site. Download the file, gunzip, then tar -xvf it. Go into the
       newly created flex directory and run ./configure, followed by
       make, and then make install.
       If you have errors here, it's probably because gcc etc. are not in
       your PATH so add them to your PATH.
    6. Download the PHP and apache sources.
    7. gunzip and tar -xvf them. We need to hack a couple of files so
       that they can compile OK.
    8. Firstly the configure file needs to be hacked because it seems to
       lose track of the fact that you are a hpux machine, there will be
       a better way of doing this but a cheap and cheerful hack is to put
       lt_target=hpux10.20 on line 47286 of the configure script.
    9. Next, the Apache GuessOS file needs to be hacked. Under
       apache_1.3.9/src/helpers change line 89 from echo
       "hp${HPUXMACH}-hpux${HPUXVER}"; exit 0 to: echo
       "hp${HPUXMACH}-hp-hpux${HPUXVER}"; exit 0
   10. You cannot install PHP as a shared object under HP-UX so you must
       compile it as a static, just follow the instructions at the Apache
       page.
   11. PHP and Apache should have compiled OK, but Apache won't start.
       you need to create a new user for Apache, e.g. www, or apache. You
       then change lines 252 and 253 of the conf/httpd.conf in Apache so
       that instead of

User nobody
Group nogroup

       you have something like

User www
Group sys

       This is because you can't run Apache as nobody under hp-ux. Apache
       and PHP should then work.
     _________________________________________________________________

OpenBSD installation notes

   This section contains notes and hints specific to installing PHP on
   OpenBSD 3.6.
     _________________________________________________________________

Using Binary Packages

   Using binary packages to install PHP on OpenBSD is the recommended and
   simplest method. The core package has been separated from the various
   modules, and each can be installed and removed independently from the
   others. The files you need can be found on your OpenBSD CD or on the
   FTP site.

   The main package you need to install is php4-core-4.3.8.tgz, which
   contains the basic engine (plus gettext and iconv). Next, take a look
   at the module packages, such as php4-mysql-4.3.8.tgz or
   php4-imap-4.3.8.tgz. You need to use the phpxs command to activate and
   deactivate these modules in your php.ini.

   Example 2-6. OpenBSD Package Install Example
# pkg_add php4-core-4.3.8.tgz
# /usr/local/sbin/phpxs -s
# cp /usr/local/share/doc/php4/php.ini-recommended /var/www/conf/php.ini
  (add in mysql)
# pkg_add php4-mysql-4.3.8.tgz
# /usr/local/sbin/phpxs -a mysql
  (add in imap)
# pkg_add php4-imap-4.3.8.tgz
# /usr/local/sbin/phpxs -a imap
  (remove mysql as a test)
# pkg_delete php4-mysql-4.3.8
# /usr/local/sbin/phpxs -r mysql
  (install the PEAR libraries)
# pkg_add php4-pear-4.3.8.tgz

   Read the packages(7) manual page for more information about binary
   packages on OpenBSD.
     _________________________________________________________________

Using Ports

   You can also compile up PHP from source using the ports tree. However,
   this is only recommended for users familiar with OpenBSD. The PHP 4
   port is split into two sub-directories: core and extensions. The
   extensions directory generates sub-packages for all of the supported
   PHP modules. If you find you do not want to create some of these
   modules, use the no_* FLAVOR. For example, to skip building the imap
   module, set the FLAVOR to no_imap.
     _________________________________________________________________

Common Problems

     * The default install of Apache runs inside a chroot(2) jail, which
       will restrict PHP scripts to accessing files under /var/www. You
       will therefore need to create a /var/www/tmp directory for PHP
       session files to be stored, or use an alternative session backend.
       In addition, database sockets need to be placed inside the jail or
       listen on the localhost interface. If you use network functions,
       some files from /etc such as /etc/resolv.conf and /etc/services
       will need to be moved into /var/www/etc. The OpenBSD PEAR package
       automatically installs into the correct chroot directories, so no
       special modification is needed there. More information on the
       OpenBSD Apache is available in the OpenBSD FAQ.
     * The OpenBSD 3.6 package for the gd extension requires XFree86 to
       be installed. If you do not wish to use some of the font features
       that require X11, install the php4-gd-4.3.8-no_x11.tgz package
       instead.
     _________________________________________________________________

Older Releases

   Older releases of OpenBSD used the FLAVORS system to compile up a
   statically linked PHP. Since it is hard to generate binary packages
   using this method, it is now deprecated. You can still use the old
   stable ports trees if you wish, but they are unsupported by the
   OpenBSD team. If you have any comments about this, the current
   maintainer for the port is Anil Madhavapeddy (avsm at openbsd dot
   org).
     _________________________________________________________________

Solaris specific installation tips

   This section contains notes and hints specific to installing PHP on
   Solaris systems.
     _________________________________________________________________

Required software

   Solaris installs often lack C compilers and their related tools. Read
   this FAQ for information on why using GNU versions for some of these
   tools is necessary. The required software is as follows:

     * gcc (recommended, other C compilers may work)
     * make
     * flex
     * bison
     * m4
     * autoconf
     * automake
     * perl
     * gzip
     * tar
     * GNU sed

   In addition, you will need to install (and possibly compile) any
   additional software specific to your configuration, such as Oracle or
   MySQL.
     _________________________________________________________________

Using Packages

   You can simplify the Solaris install process by using pkgadd to
   install most of your needed components.
     _________________________________________________________________

Gentoo installation notes

   This section contains notes and hints specific to installing PHP on
   Gentoo Linux.
     _________________________________________________________________

Using Portage (emerge)

   While you can just download the PHP source and compile it yourself,
   using Gentoo's packaging system is the simplest and cleanest method of
   installing PHP. If you are not familiar with building software on
   Linux, this is the way to go.

   If you have built your Gentoo system so far, you are probably used to
   Portage already. Installing Apache and PHP is no different than the
   other system tools.

   The first decision you need to make is whether you want to install
   Apache 1.3.x or Apache 2.x. While both can be used with PHP, the steps
   given below will use Apache 1.3.x. Another thing to consider is
   whether your local Portage tree is up to date. If you have not updated
   it recently, you need to run emerge sync before anything else. This
   way, you will be using the most recent stable version of Apache and
   PHP.

   Now that everything is in place, you can use the following example to
   install Apache and PHP:

   Example 2-7. Gentoo Install Example with Apache 1.3
# emerge \<apache-2
# USE="-*" emerge php mod_php
# ebuild /var/db/pkg/dev-php/mod_php-<your PHP version>/mod_php-<your PHP versi
on>.ebuild config
# nano /etc/conf.d/apache
  Add "-D PHP4" to APACHE_OPTS

# rc-update add apache default
# /etc/init.d/apache start

   You can read more about emerge in the excellent Portage Manual
   provided on the Gentoo website.

   If you need to use Apache 2, you can simply use emerge apache in the
   last example.
     _________________________________________________________________

Better control on configuration

   In the last section, PHP was emerged without any activated modules. As
   of this writing, the only module activated by default with Portage is
   XML which is needed by PEAR. This may not be what you want and you
   will soon discover that you need more activated modules, like MySQL,
   gettext, GD, etc.

   When you compile PHP from source yourself, you need to activate
   modules via the configure command. With Gentoo, you can simply provide
   USE flags which will be passed to the configure script automatically.
   To see which USE flags to use with emerge, you can try:

   Example 2-8. Getting the list of valid USE flags
# USE="-*" emerge -pv php

[ebuild  N    ] dev-php/php-4.3.6-r1  -X -berkdb -crypt -curl -debug -doc
-fdftk -firebird -flash -freetds -gd -gd-external -gdbm -gmp -hardenedphp
-imap -informix -ipv6 -java -jpeg -kerberos -ldap -mcal -memlimit -mssql
-mysql -ncurses -nls -oci8 -odbc -pam -pdflib -png -postgres -qt -readline
-snmp -spell -ssl -tiff -truetype -xml2 -yaz  3,876 kB

   As you can see from the last output, PHP considers a lot of USE flags.
   Look at them closely and choose what you need. If you choose a flag
   and you do not have the proper libraries, Portage will compile them
   for you. It is a good idea to use emerge -pv again to see what Portage
   will compile in accordance to your USE flags. As an example, if you do
   not have X installed and you choose to include X in the USE flags,
   Portage will compile X prior to PHP, which can take a couple of hours.

   If you choose to compile PHP with MySQL, cURL and GD support, the
   command will look something like this:

   Example 2-9. Install PHP with USE flags
   # USE="-* curl mysql gd" emerge php mod_php

   As in the last example, do not forget to emerge php as well as
   mod_php. php is responsible for the command line version of PHP as
   mod_php is for the Apache module version of PHP.
     _________________________________________________________________

Common Problems

     * If you see the PHP source instead of the result the script should
       produce, you have probably forgot to edit /etc/conf.d/apache.
       Apache needs to be started with the -D PHP4 flag. To see if the
       flag is present, you should be able to see it when using ps ax |
       grep apache while Apache is running.
     * Due to slotting problems, you might end up with more than one
       version of PHP installed on your system. If this is the case, you
       need to unmerge the old versions manually by using emerge unmerge
       mod_php-<old version>.
     * If you cannot emerge PHP because of Java, try putting -* in front
       of your USE flags like in the above examples.
     * If you are having problems configuring Apache and PHP, you can
       always search the Gentoo Forums. Try searching with the keywords
       "Apache PHP".
     _________________________________________________________________

Chapter 3. Installation on Mac OS X

   This section contains notes and hints specific to installing PHP on
   Mac OS X. There are two slightly different versions of Mac OS X,
   Client and Server, our manual deals with installing PHP on both
   systems. Note that PHP is not available for MacOS 9 and earlier
   versions.
     _________________________________________________________________

Using Packages

   There are a few pre-packaged and pre-compiled versions of PHP for Mac
   OS X. This can help in setting up a standard configuration, but if you
   need to have a different set of features (such as a secure server, or
   a different database driver), you may need to build PHP and/or your
   web server yourself. If you are unfamiliar with building and compiling
   your own software, it's worth checking whether somebody has already
   built a packaged version of PHP with the features you need.
     _________________________________________________________________

Compiling for OS X Server

   Mac OS X Server install. 

    1. Get the latest distributions of Apache and PHP.
    2. Untar them, and run the configure program on Apache like so.

./configure --exec-prefix=/usr \
--localstatedir=/var \
--mandir=/usr/share/man \
--libexecdir=/System/Library/Apache/Modules \
--iconsdir=/System/Library/Apache/Icons \
--includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
--enable-shared=max \
--enable-module=most \
--target=apache

    3. If you want the compiler to do some optimization, you may also
       want to add this line:

setenv OPTIM=-O2

    4. Next, go to the PHP 4 source directory and configure it.

./configure --prefix=/usr \
    --sysconfdir=/etc \
    --localstatedir=/var \
    --mandir=/usr/share/man \
    --with-xml \
    --with-apache=/src/apache_1.3.12

       If you have any other additions (MySQL, GD, etc.), be sure to add
       them here. For the --with-apache string, put in the path to your
       apache source directory, for example /src/apache_1.3.12.
    5. Type make and make install. This will add a directory to your
       Apache source directory under src/modules/php4.
    6. Now, reconfigure Apache to build in PHP 4.

./configure --exec-prefix=/usr \
--localstatedir=/var \
--mandir=/usr/share/man \
--libexecdir=/System/Library/Apache/Modules \
--iconsdir=/System/Library/Apache/Icons \
--includedir=/System/Library/Frameworks/Apache.framework/Versions/1.3/Headers \
--enable-shared=max \
--enable-module=most \
--target=apache \
--activate-module=src/modules/php4/libphp4.a

       You may get a message telling you that libmodphp4.a is out of
       date. If so, go to the src/modules/php4 directory inside your
       Apache source directory and run this command: ranlib libmodphp4.a.
       Then go back to the root of the Apache source directory and run
       the above configure command again. That'll bring the link table up
       to date. Run make and make install again.
    7. Copy and rename the php.ini-dist file to your bin directory from
       your PHP 4 source directory: cp php.ini-dist
       /usr/local/bin/php.ini or (if your don't have a local directory)
       cp php.ini-dist /usr/bin/php.ini.
     _________________________________________________________________

Compiling for MacOS X Client

   The following instructions will help you install a PHP module for the
   Apache web server included in MacOS X. This version includes support
   for the MySQL and PostgreSQL databases. These instructions are
   graciously provided by Marc Liyanage.

   Warning

   Be careful when you do this, you could screw up your Apache web
   server!

   Do this to install:

    1. Open a terminal window.
    2. Type wget
       http://www.diax.ch/users/liyanage/software/macosx/libphp4.so.gz,
       wait for the download to finish.
    3. Type gunzip libphp4.so.gz.
    4. Type sudo apxs -i -a -n php4 libphp4.so
    5. Now type sudo open -a TextEdit /etc/httpd/httpd.conf. TextEdit
       will open with the web server configuration file. Locate these two
       lines towards the end of the file: (Use the Find command)

#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

       Remove the two hash marks (#), then save the file and quit
       TextEdit.
    6. Finally, type sudo apachectl graceful to restart the web server.

   PHP should now be up and running. You can test it by dropping a file
   into your Sites folder which is called test.php. Into that file, write
   this line: <?php phpinfo() ?>.

   Now open up 127.0.0.1/~your_username/test.php in your web browser. You
   should see a status table with information about the PHP module.
     _________________________________________________________________

Chapter 4. Installation of PECL extensions

Introduction to PECL Installations

   PHP extensions may be installed in a variety of ways. PECL is a
   repository of PHP extensions living within the PEAR structure, and the
   following demonstrates how to install these extensions.

   These instructions assume /your/phpsrcdir/ is the path to the PHP
   source, and extname is the name of the PECL extension. Adjust
   accordingly. These instructions also assume a familiarity with the
   pear command.

   Shared extensions may be installed by including them inside of php.ini
   using the extension PHP directive. See also the extensions_dir
   directive, and dl(). The installation methods described below do not
   automatically configure PHP to include these extensions, this step
   must be done manually.

   When building PHP modules, it's important to have the appropriate
   versions of the required tools (autoconf, automake, libtool, etc.) See
   the Anonymous CVS Instructions for details on the required tools, and
   required versions.
     _________________________________________________________________

Downloading PECL extensions

   There are several options for downloading PECL extensions, such as:

     * http://pecl.php.net
       Listed here is information like the ChangeLog, release
       information, requirements, revisions, etc. Although not every PECL
       extension has a webpage, most do.
     * pear download extname
       The pear command may also be used to download source files.
       Specific revisions may also be specified.
     * CVS
       All PECL files reside in CVS. A web-based view may be seen at
       http://cvs.php.net/pecl/. To download straight from CVS, consider
       the following where phpfi is the password for user cvsread:

$ cvs -d:pserver:cvsread@cvs.php.net:/repository login
$ cvs -d:pserver:cvsread@cvs.php.net:/repository co pecl/extname

     * Windows downloads
       Windows users may find compiled PECL binaries by downloading the
       Collection of PECL modules from the PHP Downloads page, and by
       retrieving a PECL Snapshot. To compile PHP under Windows, read the
       Win32 Build README.
     _________________________________________________________________

PECL for Windows users

   Like with any other PHP extension DLL, to install move the PECL
   extension DLLs into the extension_dir folder and include them within
   php.ini. For example:

   extension=php_extname.dll

   After doing this, restart the web server.
     _________________________________________________________________

Compiling shared PECL extensions with PEAR

   PEAR makes it easy to create shared PHP extensions. Using the pear
   command, do the following:

   $ pear install extname

   That will download the source for extname, and compile it on the
   system. This results in an extname.so file that may then be included
   in php.ini

   In case the systems preferred_state is set higher than an available
   extname version, like it's set to stable and the extension is still in
   beta, either alter the preferred_state via pear config-set or specify
   a specific version of the PECL extension. For example:

   $ pear install extname-0.1.1

   Regardless, pear will copy this extname.so into the extensions
   directory. Adjust php.ini accordingly.
     _________________________________________________________________

Compiling shared PECL extensions with phpize

   If using pear is not an option, like for building shared PECL
   extensions from CVS, or for unreleased PECL packages, then creating a
   shared extension may also be done by manually using the phpize
   command. The pear command essentially does this but it may also be
   done manually. Assuming the source file is named extname.tgz, and that
   it was downloaded into the current directory, consider the following:

$ pear download extname
$ gzip -d < extname.tgz | tar -xvf -
$ cd extname
$ phpize
$ ./configure && make

   Upon success, this will create extname.so and put it into the modules/
   and/or .libs/ directory within the extname/ source. Move this shared
   extension (extname.so) into the PHP extensions directory, and adjust
   php.ini accordingly.
     _________________________________________________________________

Compiling PECL extensions statically into PHP

   To statically include the extension within the PHP build, put the
   extensions source into the ext/ directory found in the PHP source. For
   example:

$ cd /your/phpsrcdir/ext
$ pear download extname
$ gzip -d < extname.tgz | tar -xvf -
$ mv extname-x.x.x extname
$ rm package.xml

   This will result in the following directory:

   /your/phpsrcdir/ext/extname

   From here, build PHP as normal:

$ cd /your/phpsrcdir
$ ./buildconf
$ ./configure --help
$ ./configure --with-extname --enable-someotherext --with-foobar
$ make
$ make install

   Whether --enable-extname or --with-extname is used depends on the
   extension. Typically an extension that does not require external
   libraries uses --enable. To be sure, run the following after
   buildconf:

   $ ./configure --help | grep extname
     _________________________________________________________________

Chapter 5. Problems?

Read the FAQ

   Some problems are more common than others. The most common ones are
   listed in the PHP FAQ, part of this manual.
     _________________________________________________________________

Other problems

   If you are still stuck, someone on the PHP installation mailing list
   may be able to help you. You should check out the archive first, in
   case someone already answered someone else who had the same problem as
   you. The archives are available from the support page on
   http://www.php.net/support.php. To subscribe to the PHP installation
   mailing list, send an empty mail to
   php-install-subscribe@lists.php.net. The mailing list address is
   php-install@lists.php.net.

   If you want to get help on the mailing list, please try to be precise
   and give the necessary details about your environment (which operating
   system, what PHP version, what web server, if you are running PHP as
   CGI or a server module, safe mode, etc...), and preferably enough code
   to make others able to reproduce and test your problem.
     _________________________________________________________________

Bug reports

   If you think you have found a bug in PHP, please report it. The PHP
   developers probably don't know about it, and unless you report it,
   chances are it won't be fixed. You can report bugs using the
   bug-tracking system at http://bugs.php.net/. Please do not send bug
   reports in mailing list or personal letters. The bug system is also
   suitable to submit feature requests.

   Read the How to report a bug document before submitting any bug
   reports!
     _________________________________________________________________

Chapter 6. Runtime Configuration

The configuration file

   The configuration file (called php3.ini in PHP 3, and simply php.ini
   as of PHP 4) is read when PHP starts up. For the server module
   versions of PHP, this happens only once when the web server is
   started. For the CGI and CLI version, it happens on every invocation.

   The default location of php.ini is a compile time option (see the FAQ
   entry), but can be changed for the CGI and CLI version with the -c
   command line switch, see the chapter about using PHP from the command
   line. You can also use the environment variable PHPRC for an
   additional path to search for a php.ini file.

   If php-SAPI.ini exists (where SAPI is used SAPI, so the filename is
   e.g. php-cli.ini or php-apache.ini), it's used instead of php.ini.

     Note: The Apache web server changes the directory to root at
     startup causing PHP to attempt to read php.ini from the root
     filesystem if it exists.

   The php.ini directives handled by extensions are documented
   respectively on the pages of the extensions themselves. The list of
   the core directives is available in the appendix. Probably not all the
   PHP directives are documented in the manual though. For a completel
   list of directives available in your PHP version, please read your
   well commented php.ini file. Alternatively, you may find the the
   latest php.ini from CVS helpful too.

   Example 6-1. php.ini example
; any text on a line after an unquoted semicolon (;) is ignored
[php] ; section markers (text within square brackets) are also ignored
; Boolean values can be set to either:
;    true, on, yes
; or false, off, no, none
register_globals = off
track_errors = yes

; you can enclose strings in double-quotes
include_path = ".:/usr/local/lib/php"

; backslashes are treated the same as any other character
include_path = ".;c:\php\lib"
     _________________________________________________________________

How to change configuration settings

Running PHP as an Apache module

   When using PHP as an Apache module, you can also change the
   configuration settings using directives in Apache configuration files
   (e.g. httpd.conf) and .htaccess files. You will need "AllowOverride
   Options" or "AllowOverride All" privileges to do so.

   With PHP 4 and PHP 5, there are several Apache directives that allow
   you to change the PHP configuration from within the Apache
   configuration files. For a listing of which directives are
   PHP_INI_ALL, PHP_INI_PERDIR, or PHP_INI_SYSTEM, have a look at the
   List of php.ini directives appendix.

     Note: With PHP 3, there are Apache directives that correspond to
     each configuration setting in the php3.ini name, except the name is
     prefixed by "php3_".

   php_value name value
          Sets the value of the specified directive. Can be used only
          with PHP_INI_ALL and PHP_INI_PERDIR type directives. To clear a
          previously set value use none as the value.

     Note: Don't use php_value to set boolean values. php_flag (see
     below) should be used instead.

   php_flag name on|off
          Used to set a boolean configuration directive. Can be used only
          with PHP_INI_ALL and PHP_INI_PERDIR type directives.

   php_admin_value name value
          Sets the value of the specified directive. This can not be used
          in .htaccess files. Any directive type set with php_admin_value
          can not be overridden by .htaccess or virtualhost directives.
          To clear a previously set value use none as the value.

   php_admin_flag name on|off
          Used to set a boolean configuration directive. This can not be
          used in .htaccess files. Any directive type set with
          php_admin_flag can not be overridden by .htaccess or
          virtualhost directives.

   Example 6-2. Apache configuration example
<IfModule mod_php5.c>
  php_value include_path ".:/usr/local/lib/php"
  php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php4.c>
  php_value include_path ".:/usr/local/lib/php"
  php_admin_flag safe_mode on
</IfModule>
<IfModule mod_php3.c>
  php3_include_path ".:/usr/local/lib/php"
  php3_safe_mode on
</IfModule>

   Caution

   PHP constants do not exist outside of PHP. For example, in httpd.conf
   you can not use PHP constants such as E_ALL or E_NOTICE to set the
   error_reporting directive as they will have no meaning and will
   evaluate to 0. Use the associated bitmask values instead. These
   constants can be used in php.ini
     _________________________________________________________________

Changing PHP configuration via the Windows registry

   When running PHP on Windows, the configuration values can be modified
   on a per-directory basis using the Windows registry. The configuration
   values are stored in the registry key HKLM\SOFTWARE\PHP\Per Directory
   Values, in the sub-keys corresponding to the path names. For example,
   configuration values for the directory c:\inetpub\wwwroot would be
   stored in the key HKLM\SOFTWARE\PHP\Per Directory
   Values\c\inetpub\wwwroot. The settings for the directory would be
   active for any script running from this directory or any subdirectory
   of it. The values under the key should have the name of the PHP
   configuration directive and the string value. PHP constants in the
   values are not parsed. However, only configuration values changeable
   in PHP_INI_USER can be set this way, PHP_INI_PERDIR values can not.
     _________________________________________________________________

Other interfaces to PHP

   Regardless of how you run PHP, you can change certain values at
   runtime of your scripts through ini_set(). See the documentation on
   the ini_set() page for more information.

   If you are interested in a complete list of configuration settings on
   your system with their current values, you can execute the phpinfo()
   function, and review the resulting page. You can also access the
   values of individual configuration directives at runtime using
   ini_get() or get_cfg_var().
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.