Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php Postfixadmin不与Postgres合作_Php_Postgresql_Postfix Mta_Centos6 - Fatal编程技术网

Php Postfixadmin不与Postgres合作

Php Postfixadmin不与Postgres合作,php,postgresql,postfix-mta,centos6,Php,Postgresql,Postfix Mta,Centos6,我对postgres和postfix都是新手,我决定使用postfixadmin和postgres来获得更多经验,我已经完成了不同网站中提到的详细步骤,并且我检查了postgres的另一个工作安装,但没有postfixadmin,但是每当我从中访问setup.php for postfixadmin时,我都会得到: Error: Can't connect to database Please edit the $CONF['database_*'] parameters in config.i

我对postgres和postfix都是新手,我决定使用postfixadmin和postgres来获得更多经验,我已经完成了不同网站中提到的详细步骤,并且我检查了postgres的另一个工作安装,但没有postfixadmin,但是每当我从中访问setup.php for postfixadmin时,我都会得到:

Error: Can't connect to database
Please edit the $CONF['database_*'] parameters in config.inc.php.
DEBUG INFORMATION:
Connect: failed to connect to database.
我将postfix管理员配置为最初使用postfix用户,但由于默认情况下postfix创建为no login user,因此我创建了另一个名为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中的用户管理员:

# 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
-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)
以下是Postgres的配置:

# 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
-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'
这里我正在测试用户管理员:

# 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']='&nbsp;&nbsp;';
$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;
}
以下是显示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是:


有人能告诉我怎么回事吗?

在pg_hba.conf中查找此文件与postgresql.conf位于同一目录中,该行以host开头,其中包含127.0.0.1/32,以ident结尾,并将ident更改为md5。重新加载/重新启动Postgres

Postgres的日志中有什么?日志:无法连接到地址127.0.0.1的Identit server,端口113:连接被拒绝致命:用户后缀的Identit身份验证失败日志:无法连接到地址127.0.0.1的Identit server,端口113:连接被拒绝致命:用户后缀日志的标识身份验证失败:无法连接到地址127.0.0.1的标识服务器,端口113:连接被拒绝致命:用户后缀日志的标识身份验证失败:无法连接到地址127.0.0.1的标识服务器,端口113:连接被拒绝致命:用户adminFind的标识身份验证失败pg_hba.conf中此文件与postgresql.conf位于同一目录中,该行以host开头,其中包含127.0.0.1/32,以Ident结尾,并将Ident更改为md5。重新加载/重新启动Postgres。将pg_hba.conf的内容附加到问题后。感谢它的工作:local all ident host all 127.0.0.1/32 md5 host all::1/128 ident