我是postgres和postfix的新手,我决定使用Postfix的postfixadmin获得如此实力,我已经完成了不同网站中提到的详细步骤,并且我已经检查了Postgres的另一个工作安装(但是没有postfixadmin ),但每当我从http://mydomain.com:8080访问来自{{3}}的postfixadmin的setup.php时,我都会:
Error: Can't connect to database
Please edit the $CONF['database_*'] parameters in config.inc.php.
DEBUG INFORMATION:
Connect: failed to connect to database.
我将postfixadmin配置为最初使用postfix用户,但由于postfix默认创建为无登录用户,所以我创建了另一个名为admin的用户,并在config.inc.php中更改了此项,但我仍然得到相同的错误
以下是在系统上创建的与此相关的用户:
# cat /etc/passwd
root:x:0:0:root:/root:/bin/bash
postfix:x:89:89::/var/spool/postfix:/sbin/nologin
postgres:x:26:26:PostgreSQL Server:/var/lib/pgsql:/bin/bash
admin:x:500:500::/home/admin:/bin/bash
我在Postgres中配置用户admin:
# su - postgres
-bash-4.1$ template1
-bash: template1: command not found
-bash-4.1$ template1#
-bash: template1#: command not found
-bash-4.1$ psql template1
psql (8.4.18)
Type "help" for help.
template1=# CREATE USER admin WITH PASSWORD 'complexpassword';
CREATE ROLE
template1=# GRANT ALL PRIVILEGES ON DATABASE postfix to admin;
GRANT
template1=# \q
-bash-4.1$ logout
以下是Postgres的配置:
-bash-4.1$ psql
psql (8.4.18)
Type "help" for help.
postgres=# \list
List of databases
Name | Owner | Encoding | Collation | Ctype | Access privileges
-----------+----------+----------+-------------+-------------+-----------------------
postfix | postfix | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =Tc/postfix
: postfix=CTc/postfix
: admin=CTc/postfix
postgres | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 |
template0 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
template1 | postgres | UTF8 | en_US.UTF-8 | en_US.UTF-8 | =c/postgres
: postgres=CTc/postgres
(4 rows)
这是postgresql.conf:
#cat postgresql.conf
listen_addresses = 'localhost' # what IP address(es) to listen on;
port = 5432 # (change requires restart)
max_connections = 100 # (change requires restart)
shared_buffers = 32MB # min 128kB
synchronous_commit = off # optimization
log_destination = 'stderr' # Valid values are combinations of
logging_collector = on # Enable capturing of stderr and csvlog
log_directory = 'pg_log' # directory where log files are written,
log_filename = 'postgresql-%a.log' # log file name pattern,
log_truncate_on_rotation = on # If on, an existing log file of the
log_rotation_age = 1d # Automatic rotation of logfiles will
log_rotation_size = 0 # Automatic rotation of logfiles will
datestyle = 'iso, mdy'
lc_messages = 'en_US.UTF-8' # locale for system error message
lc_monetary = 'en_US.UTF-8' # locale for monetary formatting
lc_numeric = 'en_US.UTF-8' # locale for number formatting
lc_time = 'en_US.UTF-8' # locale for time formatting
default_text_search_config = 'pg_catalog.english'
我在这里测试用户admin:
# su - admin
$ psql -d postfix -U admin
psql (8.4.18)
Type "help" for help.
postfix=> exit
postfix-> \q
这里我正在测试postfix用户(nologin):
# su - postfix
This account is currently not available.
这是postfixadmin的config.inc.php:
<?php
$CONF['configured'] = true;
$CONF['setup_password'] = 'complexpassword';
$CONF['postfix_admin_path'] = dirname(__FILE__);
$CONF['default_language'] = 'en';
$CONF['database_type'] = 'pgsql';
$CONF['database_host'] = 'localhost';
$CONF['database_user'] = 'admin';
$CONF['database_password'] = 'complexpassword';
$CONF['database_name'] = 'postfix';
$CONF['database_port'] = '5432';
$CONF['database_prefix'] = '';
$CONF['database_tables'] = array (
'admin' => 'admin',
'alias' => 'alias',
'alias_domain' => 'alias_domain',
'config' => 'config',
'domain' => 'domain',
'domain_admins' => 'domain_admins',
'fetchmail' => 'fetchmail',
'log' => 'log',
'mailbox' => 'mailbox',
'vacation' => 'vacation',
'vacation_notification' => 'vacation_notification',
'quota' => 'quota',
'quota2' => 'quota2',
);
$CONF['admin_email'] = 'postmaster@mydomain.com';
$CONF['smtp_server'] = 'localhost';
$CONF['smtp_port'] = '25';
$CONF['encrypt'] = 'md5crypt';
$CONF['authlib_default_flavor'] = 'md5raw';
$CONF['min_password_length'] = 5;
$CONF['generate_password'] = 'NO';
$CONF['show_password'] = 'NO';
$CONF['page_size'] = '10';
$CONF['default_aliases'] = array (
'abuse' => 'abuse@mydomain.com',
'hostmaster' => 'hostmaster@mydomain.com',
'postmaster' => 'postmaster@mydomain.com',
'webmaster' => 'webmaster@mydomain.com'
);
$CONF['domain_path'] = 'NO';
$CONF['domain_in_mailbox'] = 'YES';
$CONF['maildir_name_hook'] = 'NO';
maildir_name_hook example function
Called by create-mailbox.php if $CONF['maildir_name_hook'] == '<name_of_the_function>'
- allows for customized maildir paths determined by a custom function
- the example below will prepend a single-character directory to the
beginning of the maildir, splitting domains more or less evenly over
36 directories for improved filesystem performance with large numbers
of domains.
Returns: maildir path
function maildir_name_hook($domain, $user) {
$chars = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
$dir_index = hexdec(substr(md5($domain), 28)) % strlen($chars);
$dir = substr($chars, $dir_index, 1);
}
$CONF['aliases'] = '10';
$CONF['mailboxes'] = '10';
$CONF['maxquota'] = '10';
$CONF['quota'] = 'NO';
$CONF['quota_multiplier'] = '1024000';
$CONF['transport'] = 'NO';
$CONF['transport_options'] = array (
);
$CONF['transport_default'] = 'virtual';
$CONF['vacation'] = 'NO';
$CONF['vacation_domain'] = 'autoreply.hassans.nl';
$CONF['vacation_control'] ='YES';
$CONF['vacation_control_admin'] = 'YES';
$CONF['alias_control'] = 'NO';
$CONF['alias_control_admin'] = 'NO';
$CONF['special_alias_control'] = 'NO';
$CONF['alias_goto_limit'] = '0';
$CONF['alias_domain'] = 'YES';
$CONF['backup'] = 'YES';
$CONF['sendmail'] = 'YES';
$CONF['logging'] = 'YES';
$CONF['fetchmail'] = 'YES';
$CONF['fetchmail_extra_options'] = 'NO';
$CONF['show_header_text'] = 'NO';
$CONF['header_text'] = ':: Postfix Admin ::';
$CONF['show_footer_text'] = 'YES';
$CONF['footer_text'] = 'Return to mail.mydomain.com';
$CONF['welcome_text'] = <<<EOM
Hi,
Welcome to your new account.
EOM;
$CONF['emailcheck_resolve_domain']='YES';
$CONF['show_status']='NO';
$CONF['show_status_key']='NO';
$CONF['show_status_text']=' ';
$CONF['show_undeliverable']='NO';
$CONF['show_undeliverable_color']='tomato';
$CONF['show_undeliverable_exceptions']=array("unixmail.domain.ext","exchangeserver.domain.ext","gmail.com");
$CONF['show_popimap']='NO';
$CONF['show_popimap_color']='darkgrey';
$CONF['show_custom_domains']=array("subdomain.domain.ext","domain2.ext");
$CONF['show_custom_colors']=array("lightgreen","lightblue");
$CONF['recipient_delimiter'] = "";
$CONF['create_mailbox_subdirs_prefix']='INBOX.';
$CONF['used_quotas'] = 'NO';
$CONF['new_quota_table'] = 'NO';
$CONF['xmlrpc_enabled'] = false;
}
以下是安装的php包:
#rpm -qa| grep php
php-common-5.3.3-26.el6.x86_64
php-pgsql-5.3.3-26.el6.x86_64
php-xmlrpc-5.3.3-26.el6.x86_64
php-cli-5.3.3-26.el6.x86_64
php-5.3.3-26.el6.x86_64
php-gd-5.3.3-26.el6.x86_64
php-pear-1.9.4-4.el6.noarch
php-imap-5.3.3-26.el6.x86_64
php-xml-5.3.3-26.el6.x86_64
php-pdo-5.3.3-26.el6.x86_64
php-mbstring-5.3.3-26.el6.x86_64
以下是显示Postgres正在收听posrt 5432的检查:
#netstat -an|grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
unix 2 [ ACC ] STREAM LISTENING 12136 /tmp/.s.PGSQL.5432
# telnet localhost 5432
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
^]
telnet> quit
Connection closed.
但是当我尝试运行setup.php页面时,我真的很奇怪,我可以看到以下内容:
# netstat -an| grep 5432
tcp 0 0 127.0.0.1:5432 0.0.0.0:* LISTEN
tcp 0 0 127.0.0.1:45445 127.0.0.1:5432 TIME_WAIT
unix 2 [ ACC ] STREAM LISTENING 12136 /tmp/.s.PGSQL.5432
Postgres'日志包含:
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused
FATAL: Ident authentication failed for user "postfix"
LOG: could not connect to Ident server at address "127.0.0.1", port 113: Connection refused FATAL:
Ident authentication failed for user "admin"
而pg_hba.conf
是:
local all all ident
host all all 127.0.0.1/32 ident
host all all ::1/128 ident
有人可以指导我出错了吗?
答案 0 :(得分:0)
在pg_hba.conf
中查找(此文件与postgresql.conf
在同一目录中)以&#34; host&#34;开头的行,包含&#34; 127.0.0.1/32& #34;在其中以&#34; ident&#34;结尾并改变&#34; ident&#34;到&#34; md5&#34;。重新加载/重新启动Postgres。