Online Documentation Server
 ПОИСК
ods.com.ua Web
 КАТЕГОРИИ
Home
Programming
Net technology
Unixes
Security
RFC, HOWTO
Web technology
Data bases
Other docs

 


 ПОДПИСКА

 О КОПИРАЙТАХ
Вся предоставленная на этом сервере информация собрана нами из разных источников. Если Вам кажется, что публикация каких-то документов нарушает чьи-либо авторские права, сообщите нам об этом.




Installation on UNIX systems

Installation on UNIX systems

This section will guide you through the configuration and installation of PHP. Prerequisite knowledge and software:

  • Basic UNIX skills (being able to operate "make" and a C compiler)

  • An ANSI C compiler

  • A web server

Quick Installation Instructions (Apache Module Version)


1.  gunzip apache_1.3.x.tar.gz
2.  tar xvf apache_1.3.x.tar
3.  gunzip php-x.x.x.tar.gz
4.  tar xvf php-x.x.x.tar
5.  cd apache_1.3.x
6.  ./configure --prefix=/www
7.  cd ../php-x.x.x
8.  ./configure --with-mysql --with-apache=../apache_1.3.x --enable-track-vars
9.  make
10. make install
11. cd ../apache_1.3.x
12. for PHP 3: ./configure --activate-module=src/modules/php3/libphp3.a
    for PHP 4: ./configure --activate-module=src/modules/php4/libphp4.a
13. make
14. make install

  Instead of this step you may prefer to simply copy the httpd binary
  overtop of your existing binary.  Make sure you shut down your
  server first though.

15. cd ../php-x.x.x
16. for PHP 3: cp php3.ini-dist /usr/local/lib/php3.ini
    for PHP 4: cp php.ini-dist /usr/local/lib/php.ini

  You can edit your .ini file to set PHP options.  If
  you prefer this file in another location, use
  --with-config-file-path=/path in step 8.

17. Edit your httpd.conf or srm.conf file and add: 
      
     For PHP 3:   AddType application/x-httpd-php3 .php3
     For PHP 4:   AddType application/x-httpd-php .php
 
  You can choose any extension you wish here.  .php is simply the one
  we suggest.

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

Apache Module

PHP can be compiled in a number of different ways. Here is a quick summary:


./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 again 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 eihter the php.ini file or directly using dl().

fhttpd Module

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.

CGI version

The default is to build PHP as a CGI program. 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 Apache users to run different PHP-enabled pages under different user-ids. Please make sure you read through the Security chapter if you are going to run PHP as a CGI.

Database Support Options

PHP has native support for a number of databases (as well as ODBC):

Adabas D


      --with-adabas=DIR
     

Enables Adabas D support. The parameter is the Adabas D install directory and defaults to /usr/local/adabasd.

Adabas home page

dBase


      --with-dbase
     

Enables the bundled DBase support. No external libraries are required.

filePro


      --with-filepro
     

Enables the bundled read-only filePro support. No external libraries are required.

IBM DB2


      --with-ibm-db2=DIR
     

Enables IBM DB2 support. The parameter to this option is the DB2 base install directory and defaults to /home/db2inst1/sqllib.

IBM DB2 home page

mSQL


      --with-msql=DIR
     

Enables mSQL support. The parameter to this option is the mSQL install directory and defaults to /usr/local/Hughes. This is the default directory of the mSQL 2.0 distribution. configure automatically detects which mSQL version you are running and PHP supports both 1.0 and 2.0, but if you compile PHP with mSQL 1.0, you can only access mSQL 1.0 databases, and vice-versa.

See also mSQL Configuration Directives in the configuration file.

mSQL home page

MySQL


      --with-mysql=DIR
     

Enables MySQL support. The parameter to this option is the MySQL install directory and defaults to /usr/local. This is the default installation directory of the MySQL distribution.

See also MySQL Configuration Directives in the configuration file.

MySQL home page

iODBC


      --with-iodbc=DIR
     

Includes iODBC support. This feature was first developed for iODBC Driver Manager, a freely redistributable ODBC driver manager which runs under many flavors of UNIX. The parameter to this option is the iODBC installation directory and defaults to /usr/local.

FreeODBC home page or iODBC home page

OpenLink ODBC


      --with-openlink=DIR
     

Includes OpenLink ODBC support. The parameter to this option is the OpenLink ODBC installation directory and defaults to /usr/local/openlink.

OpenLink Software's home page

Oracle


      --with-oracle=DIR
     

Includes Oracle support. Has been tested and should be working at least with Oracle versions 7.0 through 7.3. The parameter is the ORACLE_HOME directory. You do not have to specify this parameter if your Oracle environment has been set up.

Oracle home page

PostgreSQL


      --with-pgsql=DIR
     

Includes PostgreSQL support. The parameter is the PostgreSQL base install directory and defaults to /usr/local/pgsql.

See also Postgres Configuration Directives in the configuration file.

PostgreSQL home page

Solid


      --with-solid=DIR
     

Includes Solid support. The parameter is the Solid install directory and defaults to /usr/local/solid.

Solid home page

Sybase


      --with-sybase=DIR
     

Includes Sybase support. The parameter is the Sybase install directory and defaults to /home/sybase.

See also Sybase Configuration Directives in the configuration file.

Sybase home page

Sybase-CT


      --with-sybase-ct=DIR
     

Includes Sybase-CT support. The parameter is the Sybase-CT install directory and defaults to /home/sybase.

See also Sybase-CT Configuration Directives in the configuration file.

Velocis


      --with-velocis=DIR
     

Includes Velocis support. The parameter is the Velocis install directory and defaults to /usr/local/velocis.

Velocis home page

A custom ODBC library


      --with-custom-odbc=DIR
     

Includes support for an arbitrary custom ODBC library. The parameter is the base directory and defaults to /usr/local.

This option implies that you have defined CUSTOM_ODBC_LIBS when you run the configure script. You also must have a valid odbc.h header somewhere in your include path. If you don't have one, create it and include your specific header from there. Your header may also require some extra definitions, particularly when it is multiplatform. Define them in CFLAGS.

For example, you can use Sybase SQL Anywhere on QNX as following: CFLAGS=-DODBC_QNX LDFLAGS=-lunix CUSTOM_ODBC_LIBS="-ldblib -lodbc" ./configure --with-custom-odbc=/usr/lib/sqlany50

Unified ODBC


      --disable-unified-odbc
     

Disables the Unified ODBC module, which is a common interface to all the databases with ODBC-based interfaces, such as Solid, IBM DB2 and Adabas D. It also works for normal ODBC libraries. Has been tested with iODBC, Solid, Adabas D, IBM DB2 and Sybase SQL Anywhere. Requires that one (and only one) of these modules or the Velocis module is enabled, or a custom ODBC library specified. This option is only applicable if one of the following options is used: --with-iodbc, --with-solid, --with-ibm-db2, --with-adabas, --with-velocis, or --with-custom-odbc.

See also Unified ODBC Configuration Directives in the configuration file.

LDAP


      --with-ldap=DIR
     

Includes LDAP (Lightweight Directory Access Protocol) support. The parameter is the LDAP base install directory, defaults to /usr/local/ldap.

More information about LDAP can be found in RFC1777 and RFC1778.

Other configure options

--with-mcrypt=DIR


      --with-mcrypt
     

Include support for the mcrypt library. See the mcrypt documentation for more information. If you use the optional DIR argument, PHP will look for mcrypt.h in DIR/include.

--enable-sysvsem


      --enable-sysvsem
     

Include support for Sys V semaphores (supported by most Unix derivates). See the Semaphore and Shared Memory documentation for more information.

--enable-sysvshm


      --enable-sysvshm
     

Include support for Sys V shared memory (supported by most Unix derivates). See the Semaphore and Shared Memory documentation for more information.

--with-xml


      --with-xml
     

Include support for a non-validating XML parser using James Clark's expat library. See the XML function reference for details.

--enable-maintainer-mode


      --enable-maintainer-mode
     

Turns on extra dependencies and compiler warnings used by some of the PHP developers.

--with-system-regex


      --with-system-regex
     

Uses the system's regular expression library rather than the bundled one. If you are building PHP as a server module, you must use the same library when building PHP as when linking the server. Enable this if the system's library provides special features you need. It is recommended that you use the bundled library if possible.

--with-config-file-path


      --with-config-file-path=DIR
     

The path used to look for the configuration file when PHP starts up.

--with-exec-dir


      --with-exec-dir=DIR
     

Only allow running of executables in DIR when in safe mode. Defaults to /usr/local/bin. This option only sets the default, it may be changed with the safe_mode_exec_dir directive in the configuration file later.

--enable-debug


      --enable-debug
     

Enables extra debug information. This makes it possible to gather more detailed information when there are problems with PHP. (Note that this doesn't have anything to do with debugging facilities or information available to PHP scripts.)

--enable-safe-mode


      --enable-safe-mode
     

Enables "safe mode" by default. This imposes several restrictions on what PHP can do, such as opening only files within the document root. Read the Security chapter for more more information. CGI users should always enable secure mode. This option only sets the default, it may be enabled or disabled with the safe_mode directive in the configuration file later.

--enable-track-vars


      --enable-track-vars
     

Makes PHP keep track of where GET/POST/cookie variables come from in the arrays HTTP_GET_VARS, HTTP_POST_VARS and HTTP_COOKIE_VARS. This option only sets the default, it may be enabled or disabled with the track_vars directive in the configuration file later.

--enable-magic-quotes


      --enable-magic-quotes
     

Enable magic quotes by default. This option only sets the default, it may be enabled or disabled with the magic_quotes_runtime directive in the configuration file later. See also the magic_quotes_gpc and the magic_quotes_sybase directives.

--enable-debugger


      --enable-debugger
     

Enables the internal PHP debugger support. This feature is still in an experimental state. See also the Debugger Configuration directives in the configuration file.

--enable-discard-path


      --enable-discard-path
     

If this is enabled, the PHP CGI binary can safely be placed outside of the web tree and people will not be able to circumvent .htaccess security. Read the section in the security chapter about this option.

--enable-bcmath


      --enable-bcmath
     

Enables bc style arbitrary precision math functions. See also the bcmath.scale option in the configuration file.

--enable-force-cgi-redirect


      --enable-force-cgi-redirect
     

Enable the security check for internal server redirects. You should use this if you are running the CGI version with Apache.

When using PHP as a CGI binary, PHP by default always first checks that it is used by redirection (for example under Apache, by using Action directives). This makes sure that the PHP binary cannot be used to bypass standard web server authentication procedures by calling it directly, like http://my.host/cgi-bin/php/secret/doc.html. This example accesses http://my.host/secret/doc.html but does not honour any security settings enforced by httpd for directory /secret.

Not enabling option disables the check and enables bypassing httpd security and authentication settings. Do this only if your server software is unable to indicate that a safe redirection was done and all your files under your document root and user directories may be accessed by anyone.

Read the section in the security chapter about this option.

--disable-short-tags


      --disable-short-tags
     

Disables the short form <? ?> PHP tags. You must disable the short form if you want to use PHP with XML. With short tags disabled, the only PHP code tag is <?php ?>. This option only sets the default, it may be enabled or disabled with the short_open_tag directive in the configuration file later.

--enable-url-includes


      --enable-url-includes
     

Makes it possible to run code on other HTTP or FTP servers directly from PHP with include(). See also the include_path option in the configuration file.

--disable-syntax-hl


      --disable-syntax-hl
     

Turns off syntax highlighting.

CPPFLAGS and LDFLAGS

To make the PHP installation look for header or library files in different directories, modify the CPPFLAGS and LDFLAGS environment variables, respectively. If you are using a sensible shell, you should be able to do LDFLAGS=-L/my/lib/dir CPPFLAGS=-I/my/include/dir ./configure

Building

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

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



With any suggestions or questions please feel free to contact us