需要注意的是执行initdb的用户将拥有所建数据库目录的管理权。 使用以下命令启动PostgreSQL: $
postmaster -S 运行测试程序: $ cd test/regression $ gmake all runtest
如测试程序能正常运行则说明PostgreSQL能正常运行。 为了让
PostgreSQL在系统启动时能自动启动,需作以下变更: 首先以root登录 $ su Linux:
在/etc/rc.d/rc.local中追加以下内容: POSTGRESDIR=/usr/local/pgsql if [ -x
$POSTGRESDIR/bin/postmaster -a d $POSTGRESDIR/data ];then rm -f
/tmp/s.PGSQL.5432 su - postgres -c "postmaster -S -i" echo -n
postmaster fi FreeBSD:
在/usr/local/etc/rc.d中建立名为 pgsql.sh的文件,内容为: #!
/bin/sh POSTGRESDIR=/usr/local/pgsql if [ -x
$POSTGRESDIR/bin/postmaster -a -d $POSTGRESDIR/data ];then rm -f
/tmp/s.PGSQL.5432 su - postgres -c "postmaster -S -i" echo -n
postmaster fi 修改pgsql.sh文件的权限: # chmod 755 pgsql.sh
现在PostgreSQL的安装和设定基本已经完成了,但是目前为止能使用数据库的用户只有postgres。 为使其他用户可以使用数据库,需要登录数据库用户和生成用户数据。 如通过Web服务器Apache进行查询的用户,用户名为nobody: %
createuser nobody Enter users postgres ID or RETURN to use unix user
ID: 1000 -$#@62;1000 Is user "nobody" allowed to create
dataase(y/n)n Is user "nobody" allowed to add users?(y/n)n createuser:
nobody was successfully added
根据SQL标准,一个数据表文件(table)
在刚建立时只有建立该表文件的用户有权访问。要分配给用户访问权限,可以使用grant命令: grant $#@60; 权限种类 $#@62; on to
$#@60; 用户/组
$#@62; 权限种类:all,select,insert,update,delete,rule table名:被设置用户访问权限的表文件 用户/组:public(所有用户)
或用户名/组名 revoke命令作用与grant命令相反,用法如下: revoke $#@60;权限种类$#@62; on from
$#@60;用户/组$#@62; table已设置的用户权限可以使用pgsql的\z 命令查看。
2.
Apache+PHP3的安装及设置
2.1 源程序 Apache和PHP3的最新版本源程序可以从http://www.apache.org/和http://www.php.net/找到。 以下以Apache
1.3.6和PHP3 3.0.5 为例。 2.2 编译
假设Apache和PHP3的源程序都保存在/tmp目录下,首先登录为root: $ su # cd
/usr/local/src # tar -xzvf /tmp/apache_1.3.6.tar.gz #
./configure # cd /usr/local/src # tar -xzvf
/tmp/php3-3.0.5.tar.gz # cd php-3.0.5 # ./configure --with-pgsql
--with-apache= ../apache_1.3.6 --enable-track-vars # make # make
install