Chapter 3 Installation This chapter will guide you on how to install and set up PHP3. and introduce the necessary knowledge and software. Basic UNIX skills (learn how to operate and "make" a C compiler) A standard ANSI C compiler A WEB server (obviously required) Compile and install from UNIX source code Download the source file The latest source code can be found at: http://www.php.net 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-3.0.x.tar .gz 4. tar xvf php-3.0.x.tar 5. cd apache_1.3.x 6. ./configure --prefix=/www 7. cd ../php-3.0.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. ./configure --prefix =/www --activate-module=src/modules/php3/libphp3.a 13. make 14. make install Instead of this step you may prefer to simply copy the httpd binaryovertop of your existing binary. Make sure you shut down yourserver first though. (You can also use the method of directly copying the httpd binary file to overwrite the existing binary file instead of the above steps, but you must shut down your server first.) 15. cd ../php-3.0.x 16. cp php3.ini-dist /usr/local/lib/php3.ini You can edit /usr/local/lib/php3.ini file to set PHP options. If you prefer this file in another location, use --with-config- file=/path in step 8. (You can directly edit the /usr/local/lib/php3.ini file to set PHP options. If you store this file in another location, then use with-config in step 8. -file=/path) 17. Edit your httpd.conf or srm.conf file and add: AddType application/x-httpd-php3 .php3 You can choose any extension you wish here. .php3 is simply the one we suggest. ( You can choose any extension you wish, we think PHP3 is a very simple thing. ) 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.) Use the server's RELOAD (reload) function) There are two ways to set up PHP3 1. Use the "setup" scripting language that came with PHP3. The script will ask the user a series of questions (mostly similar to PHP/FI 2.0's "install" script) and finally run "configure". To run this script, enter: "./setup". This script will also create a file called "do-conf" that will be passed to the data in the settings. You can edit this file to change some settings (just a few) without re-running the setup program. Then, type: "./do-conf" to set up with these options. 2. Manual run settings. To see the setup options available to you, enter: "./configure --help". Details of the different settings are listed below. Apache mode To build PHP3 according to the Apache mode, you should answer "yes" to the question "Build as an Apache module?" (set according to the Apache mode?) (set -with-apache=DIR) and then explain in detail what Apache distributes Basic directory. If you have unzipped your Apache distribution package in "/usr/local/www/apache_1.2.4", then this is the base directory of your Apache distribution. The default directory is "/usr/local/etc/httpd".fhttpd mode To build PHP3 according to fhttpd mode, answer "yes" to the question "Build as an fhttpd module?" (set -with-fhttpd=DIR) and specify the source data directory for fhttpd mode. The default directory is "/usr/local/src/fhttpd" If you are running fhttpd, setting up PHP in this mode will provide better performance, greater control and remote execution capabilities. CGI Version The default setting is to build PHP3 as a CGI program. If you are running a web server with PHP3 that has support for this mode, you will typically choose this solution for performance reasons. However, the CGI version of PHP3 allows Apache users to run different pages using PHP3 under different user identities. Please read the security section carefully if you will be running PHP as CGI. Database support options PHP has built-in support for many databases (also ODBC) Adabas D --with-adabas=DIR Add support for the Adabas D database when compiling. This parameter is the installation directory of Adabas D. The default is /usr/local/adabasd. DBase --with-dbase activates the built-in Dbase database support, no external library is required. FilePro activates built-in read-only filePro support, no external libraries are required. mSQL --with-msql=DIR In order to activate mSQL support, the parameter of this option is the mSQL installation directory, and the default is /usr/local/Hughes. This is the default directory for mSQL 2.0 installations. Configure can automatically detect the mSQL version installed on the system. PHP3 supports both versions 1.0 and 2.0. If you compile PHP3 and mSQL1.0, you can only access the database and replacement scheduling algorithm in 1.0. MySQL --with-mysql=DIR In order to activate MySQL support, the parameter of this option is the MySQL installation directory. The default is /usr/local/. This is the default directory for MySQL installations. iODBC --with-iodbc=DIR includes iODBC support. This feature was originally designed and developed for iODBC Driver Manager, a free redistribution of the ODBC Driver Manager that works under many UNIX systems. This parameter is the directory where iODBC is installed. The default is /usr/local. OpenLink ODBC --with-openlink=DIR includes OpenLink ODBC support. The parameter of this option is the installation directory of OpenLink ODBC. The default is /usr/local/openlink. Oracle --with-oracle=DIR includes Oracle support. After testing, it can work normally under at least Oracle7.0 and 7.3. This parameter is the ORACLE_HOME directory. If your Oracle environment has been configured, you do not need to specify this parameter. PostgreSQL --with-pgsql=DIR includes support for PostgreSQL. This parameter is the base directory for PostgreSQL installation. The default is /usr/local/pgsql. The support for other common databases is roughly the same as listed above. If necessary, please refer to the instructions for the database you selected. Other configuration options --enable-sysvsem include support for the Sys V signal (supported by most Unix systems). See the signals and shared memory documentation for more information. --enable-sysvshm includes support for Sys V shared memory (supported by most Unix systems). See the signals and shared memory documentation for more information. --with-xml includes support for an informal version of XML syntax, using James Clark’s expat library. See the XML Functions Guide for details. --enable-maintainer-mode turns on additional related and compilation warning messages, which are often used by PHP3 developers. --with-system-regex Use the system regular expression library rather than the bundled one. If you compile PHP3 as a server component, you must use the same library when compiling and connecting to the server. Turn this option on if your system has what you need. If possible, it is recommended that you use the libraries bundled with PHP3. --with-config-file-path This path is used to find the location of the php3.ini file when PHP3 starts. --with-exec-dir only allows execution in the directory in safe mode, the default is /usr/local/bin/. This option can only be set to default, which can be achieved later by modifying safe_mode_exec_dir in the configuration file. --disable-debug Do not include debugging information in the library or execution. Debug information can help you quickly pinpoint the problem, so as long as PHP is still in the alpha or beta testing stage, it is best to retain debug information. --enable-safe-mode The default is to turn on the "safe_mode" (safe mode) option. This option imposes some restrictions on PHP functions. For example, you can only open files under your WEB root directory. Please read the safety section in detail. chapter for details. CGI users should always keep this option turned on. This option can only be set as default, but you can later turn this option on or off by modifying the configuration file (php3.ini). --enable-track-vars Use PHP3 to save traces of GWT/POST/cookie requests from HTTP_GET_VARS, HTTP_POST_VARS or HTTP_COOKIE_VARS. This option is set to the default value, and the user can later change its attributes (enabled or disabled) by setting the value of track_vars in the configuration file. The --enable-magic-quotes setting makes magic quotes the default. This option only sets the default, which can be enabled or disabled by specifying magic_quotes_runtime in the configuration file.Please refer to the corresponding content on magic_quotes_gpc and magic_quotes_sybase. --enable-debugger Activates the built-in PHP3 debugger support. This feature is still only in the experimental stage. Please refer to the relevant content of Debugger Configuration in the configuration file. --enable-discard-path If this attribute is set to available, PHP's binary CGI can be safely protected outside the WED tree, and others cannot use some special means to gain access. Please refer to the section in the security chapter about this option. --enable-bcmath enables BC-style arbitrary precision math functions to be used. Please refer to the configuration file for configuration file options. --enable-force-cgi-redirect Use security checks for internal server redirections. If users run CGI programs on Apache, they need to use this feature. When using PHP as a CGI binary, as a default setting, PHP will first check whether it is used for redirection (for example, using active indicators on Apache). This will confirm that the PHP binary cannot be used to call directly thereby bypassing the standard web server authentication procedure, for example: http://my.host/cgi-bin/php/secret/doc.html. This example accesses http://my.host/secret/doc.html, but does not perform the security settings made by HTTPD for the directory /secret. Not using this option turns off this check and bypasses HTTPD security and identity settings. If you do this, unless your server software cannot indicate a safe redirect; the files in your folder root and user directories will be accessible to anyone. Please refer to the Security chapter for information about this option. --disable-short-tags Disable short-format PHP3 tags ?>. If you want to use XML (Extensible Markup Language), you must disable ?>, then the only PHP code tags left are . This option can only be set to default. This option can be turned on or off by modifying the short open tag command in the configuration file. --enable-url-includes Through the include() function, PHP3 can directly run the code of other HTTP and FTP sites. See the include path option in the configuration file. --disable-syntax-hl turns off syntax highlighting. CPPFLAGS and LDFL