在Postgres上安装silverstripe 2.4.10在数据库连接上经常失败


Installing silverstripe 2.4.10 on Postgres constantly fails on db connection

我正在尝试用Postgres在Red Hat上安装Silversstripe 2.4.10。

所以我下载了v2.4.10,在httpd.conf:中添加了一个新的vHost

<VirtualHost *:80> 
ServerName silverstripe.localhost 
ServerAlias silverstripe.localhost 
ServerAdmin root@silverstripe.localhost 
DocumentRoot /var/www/html/SilverStripe-cms-v2.4.10 
ErrorLog /var/www/html/silverstripe/silverstripe.com-error_log 
CustomLog /var/www/html/silverstripe/silverstripe.com-access_log common 
<Directory "/var/www/html/silverstripe/SilverStripe-cms-v2.4.10"> 
Options Indexes FollowSymLinks 
AllowOverride All 
Order allow,deny 
Allow from all 
</Directory> 
</VirtualHost>

我下载了postgres包,并将其解压到/var/www/html/siverstripe/silverstripe-cms-v2.4.10中。

我导航到SilverStripe的子域URL:http://silverstripe.localhost/

这将需要我安装.php,我添加我的Postgres数据库凭据,但Silverstripe不断地告诉我它无法连接到数据库。

我通过创建一个小的PHP脚本来验证我的数据库凭据:

<?php 
$db = pg_connect("host=127.0.0.1 port=5432 dbname=SS_mysite user=silverstripe password="); 
$result = pg_query($db, "SELECT * FROM test_table_pgtest");
while ($row = pg_fetch_row($result)) { 
echo "Id: $row[0] Name: $row[1]"; 
echo "<br />'n"; 
} 
?>

脚本执行良好,但silverstripe不接受相同的DB凭据。错误是:我在127.0.0.1:5432上找不到数据库服务器:PostgreSQL需要有效的用户名和密码来确定服务器是否存在。

这真的很烦人。

Postgres模块给出了运行说明:开发/构建

不幸的是,这只会导致404错误。http://silverstripe.localhost/dev/build简单地返回404错误。我还可以做什么或检查以改进这一点?

当然,数据库确实存在,用户确实可以工作(请参阅我运行得很好的测试脚本)。

此外,这个开发/构建的东西根本不起作用,从文档中还不清楚这是否打算在运行安装程序之前起作用。因为如果是。。。有点奇怪的是,Postgres模块告诉用户在安装前运行这个脚本。

mysite/''uconfig.php中的以下配置应该可以工作(这绕过了安装程序中遵循的过程),并假设在_SS_environment.php中定义了postgresql常量SS_PGSQL_DATABASE_SERVER、SS_PGSQL_DATABASE_USERNAME和SS_PGSQL _DATABASE_PASSWORD:

global $database;
$database = 'SS_mysite';
require_once('conf/ConfigureFromEnv.php');
global $databaseConfig;
$databaseConfig['type'] = 'PostgreSQLDatabase';
$databaseConfig['server'] = SS_PGSQL_DATABASE_SERVER;
$databaseConfig['username'] = SS_PGSQL_DATABASE_USERNAME;
$databaseConfig['password'] = SS_PGSQL_DATABASE_PASSWORD;