mod_php note: The following instructions apply to the CGI version of
PHP as well as to the module version. If you are working with mod_php,
you must restart your web server to force a reload of the php3.ini file, though.
If you are using mod_php, you have additional configuration options:
See the section below on using PHPlib with mod_php.
Create a directory php parallel to your cgi:
/home/www/servers/www.example.com/pages <- document root
cgi <- php binary
php <- includes and prepends
Make this php directory your php include directory: Put
include_path = /home/www/servers/www.example.com/php
into cgi/php3.ini. If you already have an include path
defined in your setup, add the PHPlib include path to the
existing include path using the separator character applicable
for your operating system (":" on UNIX, ";" on Windows).
Defining an include path will not actually include code on your
pages; it only tells the PHP interpreter in which directories to
look for files referenced in require() and include()
statements.
Into the php directory go all the files from the /php
directory of the distribution. Into documentroot, put all the
files and directories from the /pages directory of the
distribution.
Have documentation handy and read it.
Database access with MySQL
The following information applies to MySQL only. No information
is provided for other database servers as of now. You are
encouraged to copy this section, adapt it for your database
server and submit it to the authors. It will be included in
further releases of PHPlib.
Edit prepend.php3. Change the first require()
statement to require("db_mysql.inc");. This will
include the MySQL database interface (Interfaces for other
databases are provided in
db_<databasename>.inc. The require()
statement has to be adapted to reflect this).
Assuming your database server is named database.example.com and your CGI
user is webuser and you are accessing the database myapp, do
mysql -h database -u webuser myapp
If it does not work, connect your database as administrator and
create the proper mysql access permissions. Adapt and run
create_database.mysql from the /stuff
subdirectory of the distribution to create the databases
active_sessions and auth_user as well as
the sample user kris with password test. Try again to
connect like shown above. Can you do select * from
active_sessions? and insert into
active_sessions values ("1", "2", "3", "") as well as
delete from active_sessions? Can you select *
from auth_user
Note: Additional database creation scripts are provided for
several different databases in the /stuff directory of the
distribution.
Merging PHPlib with your PHP files
Decide if you want to use include or
auto_prepend_file. We do use
auto_prepend_file
here and we add the statement auto_prepend_file =
/home/www/servers/www.example.com/php/prepend.php3 to our
php3.ini.
Not all classes are included/required by prepend.php3, only
core functionality files are: db_xxx.inc,
ct_sql.inc, session.inc, auth.inc, perm.inc, user.inc, local.inc and
page.inc. The library provides other, less essential
classes that can be included manually on a page-by-page basis.
Some classes make themselves persistent, if used. These classes
require that you include their definitions in the
prepend.php3 file where indicated to function correctly.
See the usage instructions for these classes for details.
Having done this, access index.php3. The counter
should increment when that page is being reloaded. Also, checking
active_sessions in the database should reflect that
session.