1

Topic: Internal Server Error while opening iredadmin

Hi,

I am getting Internal Server Error while opening iredadmin. I've set the debug to True in iredadmin settings.ini and here is my apache logs when trying to access /iredadmin


[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100] mod_wsgi (pid=2692): Target WSGI script '/var/www/iredadmin/iredadmin.py'

cannot be loaded as Python module.
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100] mod_wsgi (pid=2692): Exception occurred processing WSGI script

'/var/www/iredadmin/iredadmin.py'.
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100] Traceback (most recent call last):
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]   File "/var/www/iredadmin/iredadmin.py", line 32, in ?
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]     from libs import iredbase, iredutils
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]   File "/var/www/iRedAdmin-0.1.1/libs/iredbase.py", line 64, in ?
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]     web.config.debug = eval(cfg.general.get('debug', 'False'))
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]   File "<string>", line 0, in ?
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100] NameError: name 'Yes' is not defined


I can run iredadmin in standalone process  by ./iredadmin.py   This way the iredadmin listens on port 8080 

But i need to run in usual way with apache..
Please help

Thanks,
Sandeep S

2

Re: Internal Server Error while opening iredadmin

sandeep.singh wrote:

[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]     web.config.debug = eval(cfg.general.get('debug', 'False'))
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100]   File "<string>", line 0, in ?
[Mon Dec 27 04:53:04 2010] [error] [client 123.456.789.100] NameError: name 'Yes' is not defined

You set "debug = Yes" in settings.ini, it should be True or False.

3

Re: Internal Server Error while opening iredadmin

Apologies for the wrong information..
I've set it to True now.. restarted apache and here goes the apache logs..


[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100] Traceback (most recent call last):
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/application.py", line 240, in process
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     return p(lambda: process(processors))
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 55, in _processor
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     self._cleanup()
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 135, in _cleanup
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     self.store.cleanup(timeout)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 280, in cleanup
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     self.db.delete(self.table, where="$last_allowed_time > atime", vars=locals())
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 863, in delete
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     db_cursor = self._db_cursor()
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 541, in _db_cursor
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     return self.ctx.db.cursor()
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 482, in _getctx
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     self._load_context(self._ctx)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 493, in _load_context
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     ctx.db = self._connect(self.keywords)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 521, in _connect
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     return self.db_module.connect(**keywords)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     return Connection(*args, **kwargs)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 164, in __init__
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100]     super(Connection, self).__init__(*args, **kwargs2)
[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100] OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

4

Re: Internal Server Error while opening iredadmin

sandeep.singh wrote:

[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100] OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

Can't connect to MySQL server. Is MySQL server running? Check it:

# /etc/init.d/mysqld status

Try to restart MySQL, and then restart Apache.

5

Re: Internal Server Error while opening iredadmin

restared both still no luck

still the same error

6

Re: Internal Server Error while opening iredadmin

[Mon Dec 27 05:10:44 2010] [error] [client 123.456.789.100] OperationalError: (2002, "Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)")

Check MySQL related settings in config file "settings.ini", verify username/passwords, port, server address. For example:

[iredadmin]
host = localhost
port = 3306
db = iredadmin
user = iredadmin
passwd = hNFi8P81Q6b21viCFCJBV95bqpxLBR

Run command to verify it:

# mysql -hlocalhohst -uiredadmin -phNFi8P81Q6b21viCFCJBV95bqpxLBR iredadmin

If it gives you a "mysql>" prompt symbol, it works.

7

Re: Internal Server Error while opening iredadmin

Hi Zhang,

Mysql connection is working absolutely fine. i can get to the mysql prompt, that means user iredadmin can connect to the iredadmin database.

I've also followed other posts related to internal server error but still no luck,, all i can see is the mysql error in the end..

8

Re: Internal Server Error while opening iredadmin

Could you please post output of commands you used to verify mysql connection? both commands and output messages

9

Re: Internal Server Error while opening iredadmin

[root@sandeep iredadmin]# mysql -u iredadmin -p'mypassword'
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 23
Server version: 5.0.77 Source distribution

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>

10

Re: Internal Server Error while opening iredadmin

Does "mysql -hlocalhost -u iredadmin -p'password'" work for you?

Also, please post /etc/my.cnf here.

11

Re: Internal Server Error while opening iredadmin

yes i can connect using    mysql -u iredadmin -hlocalhost  -p'mypassword'


And here is my  /etc/my.cnf


#---------------------------------------------------------------------
# This file is part of iRedMail, which is an open source mail server
# solution for Red Hat(R) Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedMail is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedMail is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedMail.  If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------

#
# Sample MySQL configuration file. It should be localted at:
#
#   - RHEL/CentOS:  /etc/my.cnf
#
# Shipped within iRedMail project:
#   http://code.google.com/p/iredmail/
#

[mysqld]
#bind-address            = 127.0.0.1
port                    = 3306
default-character-set   = utf8
datadir                 = /var/lib/mysql
socket                  = /var/lib/mysql/mysql.sock
user                    = mysql

# Default to using old password format for compatibility with mysql 3.x
# clients (those using the mysqlclient10 compatibility package).
old_passwords=1

skip-locking
#skip-bdb
#skip-networking

query-cache-type    = 1
# Use up to 64Mb of RAM to store query results.
query-cache-size    = 64M
query_cache_limit   = 10M

thread_cache_size   = 8

#set-variable = max_connections=1000
#set-variable = max_connect_errors=150

#ssl-ca =
ssl-cert = /etc/pki/tls/certs/iRedMail_CA.pem
ssl-key = /etc/pki/tls/private/iRedMail.key
ssl-cipher = ALL

[client]
default-character-set=utf8

[mysql.server]
user        = mysql
basedir     = /var/lib

[mysqld_safe]
log-error   = /var/log/mysqld.log
pid-file    = /var/run/mysqld/mysqld.pid

12

Re: Internal Server Error while opening iredadmin

Try to set mysql server as '127.0.0.1' in settings.ini instead of "localhost", restart apache and see what will happen.

With "127.0.0.1", all mysql connection will be TCP/IP based, "localhost" will be unix socket based (e.g. /usr/lib/mysql/mysql.sock).

13

Re: Internal Server Error while opening iredadmin

The error messages changed in apache error logs after setting 127.0.0.1 and restarting apache


Here is what error log says




[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100] Traceback (most recent call last):
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/application.py", line 240, in process
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     return p(lambda: process(processors))
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 55, in _processor
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     self._cleanup()
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 135, in _cleanup
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     self.store.cleanup(timeout)
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/session.py", line 280, in cleanup
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     self.db.delete(self.table, where="$last_allowed_time > atime", vars=locals())
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 863, in delete
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     db_cursor = self._db_cursor()
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 541, in _db_cursor
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     return self.ctx.db.cursor()
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 482, in _getctx
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     self._load_context(self._ctx)
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 493, in _load_context
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     ctx.db = self._connect(self.keywords)
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/web.py-0.34-py2.4.egg/web/db.py", line 521, in _connect
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     return self.db_module.connect(**keywords)
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/MySQLdb/__init__.py", line 75, in Connect
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     return Connection(*args, **kwargs)
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]   File "/usr/lib/python2.4/site-packages/MySQLdb/connections.py", line 198, in __init__
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]     self.converter[FIELD_TYPE.STRING].insert(-1, (None, string_decoder))
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100] TypeError: unsubscriptable object
[Tue Dec 28 06:52:58 2010] [error] [client 123.456.789.100]

14

Re: Internal Server Error while opening iredadmin

This is odd...

Could you please post whole settings.ini here? REPLACE sensitive information before posting please.

15 (edited by sandeep.singh 2010-12-28 20:20:44)

Re: Internal Server Error while opening iredadmin

#---------------------------------------------------------------------
# This file is part of iRedAdmin-OSE, which is official web-based admin
# panel (Open Source Edition) for iRedMail.
#
# iRedMail is an open source mail server solution for Red Hat(R)
# Enterprise Linux, CentOS, Debian and Ubuntu.
#
# iRedAdmin-OSE is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# iRedAdmin-OSE is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with iRedAdmin-OSE.  If not, see <http://www.gnu.org/licenses/>.
#---------------------------------------------------------------------

[general]
# Site webmaster's mail address.
webmaster = admin@localhost

# Debug mode: True, False.
# Warning: Do *NOT* enable debug in product server.
debug = True

# Default skin.
skin = default

# Default language.
lang = en_US

# Database backend: ldap.
backend = ldap

# Base directory used to store all mail data.
# You can find it via command:
#   $ sudo postconf virtual_mailbox_base
storage_base_directory = /emails

# Mailbox type: maildir, mbox.
# maildir is recommend for better performance.
mailbox_type = maildir

# Hashed maildir: True, False.
# Example:
#   - hashed: domain.ltd/u/us/use/username-2009.09.04.12.05.33/
#   - non-hashed: domain.ltd/username-2009.09.04.12.05.33/
# hashed maildir is RECOMMEND for better performance.
hashed_maildir = False

# Default quota size (in MB). 0 means unlimited.
default_quota = 50

# Default mta transport.
# Warning: Please DO use 'dovecot' as transport for iRedMail.
mtaTransport = 3306

# Show user login date instead of created date: True, False.
# Note: iRedAdmin open source edition doesn't support this feature now.
show_login_date = False

# Min/Max password length.
#   - min_passwd_length: 0 means unlimited, but at least 1 character
#                        is required.
#   - max_passwd_length: 0 means unlimited.
min_passwd_length = 6
max_passwd_length = 0

[iredadmin]
# Database used to store iRedAdmin data. e.g. sessions, log.
# NOTE: currently, only mysql dbn is supported.
dbn = mysql
host = 127.0.0.1
port = 3306
db = iredadmin
user = iredadmin
passwd = mypassword
[ldap]
# Settings used for LDAP backend.

# LDAP server uri.
# Warning: LDAPS is not supported yet.
uri = ldap://127.0.0.1:389/

# LDAP protocol version. 3 (LDAP v3) is recommend.
protocol_version = 3

# Trace level of LDAP operations: 0, 2, [...], 255.
# 0 is recommend for production use.
trace_level = 0

# LDAP suffix.
# basedn: dn which contains virtual domains.
# domainadmin_dn: dn which contains virtual domain admins.
basedn = o=domains,dc=mydomain,dc=com
domainadmin_dn = o=domainAdmins,dc=mydomain,dc=com

# Bind dn and password.
# Note:
#   - bind dn should have write privilege in LDAP.
#   - bind pw is plain text, not encryped/hashed.
bind_dn = cn=vmailadmin,dc=mydomain,dc=com
bind_pw = mypassword

# Default password scheme: SSHA, PLAIN.
# SSHA is recommended.
default_pw_scheme = SSHA

16

Re: Internal Server Error while opening iredadmin

sandeep.singh wrote:

mtaTransport = 3306

This should be 'dovecot' (without quotes). Others look good.

Try to flush table 'sessions' in MySQL database 'iredadmin', restart apache and see what will happen:

$ mysql -uroot -p
mysql> use iredadmin;
mysql> DELETE FROM sessions;

17

Re: Internal Server Error while opening iredadmin

Hi Zhang,

I've modified settings.ini, cleared the session table, restarted apache,, still it's giving the same error.

I've already mentioned that   i can run iredadmin by executing iredadmin.py interactively, that way it listens on port 8080 

So what i am thinking is apache is not able to parse .py or something like that

18

Re: Internal Server Error while opening iredadmin

This is my   iredadmin.conf     in /etc/httpd/conf.d


WSGIScriptAlias /iredadmin /var/www/iredadmin/iredadmin.py/
Alias /iredadmin/static /var/www/iredadmin/static/

AddType text/html .py

<Directory /var/www/iredadmin/>
    Order deny,allow
    Allow from all
</Directory>

19

Re: Internal Server Error while opening iredadmin

Sorry, i missed that information, my fault.

Could you please show me the package version numbers:

# rpm -qa | grep -i wsgi
# rpm -qa | grep 'MySQL'

20

Re: Internal Server Error while opening iredadmin

[root@sandeep ]# rpm -qa |grep -i wsgi
mod_wsgi-2.5-2.ired


[root@sandeep ]# rpm -qa | grep 'MySQL'
perl-DBD-MySQL-3.0007-2.el5
MySQL-python-1.2.1-1

21

Re: Internal Server Error while opening iredadmin

Looks good.

No idea yet, if you can run it directly, that means iredadmin code is ok, maybe something wrong with Apache.

When you run iredadmin in command line, any error while accessing it via web browser?

22

Re: Internal Server Error while opening iredadmin

No not at all..   
It works fine and listens on port 8080

But like i said it runs as a standalone process and tho moment i logout from terminal. It stops listening ...