Page 1 of 1

/usr/lib/bin/zminit fails to setup database

Posted: Sun Apr 05, 2009 2:32 am
by ugkbunb
I finally got ZoneMinder to build on Arch64... the makeflags were preventing the build from completing... disabling in the PKGBUILD via options=('!makeflags') allowed the build to complete. After installed the package I was prompted to do the following:
Note:
==> To initialize the ZoneMinder database run (as root)
==> /usr/lib/zm/bin/zminit

==> You must edit /etc/php/php.ini and uncomment "extension=mysql.so"
==> so php and MySQL can play together.

==> You must edit /etc/php/php.ini and set short_open_tag = On
==> or ZoneMinder will not work

==> You must edit /etc/php/php.ini and add to it open_basedir "/etc/" as such:
==> open_basedir = /home/:/tmp/:/usr/share/pear/:/etc/
==> Otherwise ZoneMinder will be unable to read /etc/zm.conf

Note:
==> You must edit /etc/httpd/conf/httpd.conf and uncomment the line
==> #LoadModule php5_module modules/libphp5.so

==> You must edit /etc/httpd/conf/httpd.conf
==> and add this line:
==> Include /etc/httpd/conf/extra/httpd-zm.conf
The only issue I am having is that I /usr/lib/zm/bin/zminit seems to not be setting up the database correctly. Attempting to start zm after runing zminit prompts me to run zminit again. I have httpd started... plus what I believe are all the run-time dependencies. Any suggestions are appreciated.
[*******@******-desktop ~]$ sudo /usr/lib/zm/bin/zminit
Password:
Enter MySQL Administrator username
(Default: root and password is blank)
MySQL Admin: root
Password: *****
A zm database exists, but the version is unknown
Updating is unlikely to succeed
Choose one of the following options:
pdate the database
[D]rop the old database and reinitialize
[E]xit and do nothing
D
ERROR 1175 (HY000) at line 593: You are using safe update mode and you tried to update a table without a WHERE that uses a KEY column
Bareword "ZM_PATH_LOGS" not allowed while "strict subs" in use at /usr/share/perl5/site_perl/5.10.0/ZoneMinder/Debug.pm line 265.
Compilation failed in require at /usr/lib/zm/bin/zmupdate.pl line 50.
BEGIN failed--compilation aborted at /usr/lib/zm/bin/zmupdate.pl line 50.

Posted: Sun Apr 05, 2009 4:53 am
by rdmelin
Hmm, that is puzzling.

First, did you build using the 1.24.1 or svn PKGBUILD?

Does /etc/zm.conf have 'ZM_VERSION=1.24.1' ?

Would you pleases try dropping the zm database manually and running zminit again?

If this still fails report if any different error shows.
As a last resort you should be able to create the database by doing "mysql -u root -p < /usr/lib/zm/upgrade/zm_create.sql" and then creating the zmuser manually.


I'm glad to see someone building for 64. When we get this sorted would you send me a package to host for others?

Posted: Sun Apr 05, 2009 5:02 am
by rdmelin
OK, check /etc/my.cnf and comment out "safe-updates" at least until you have the database working.

You will have to restart mysql after editting my.cnf

Posted: Sun Apr 05, 2009 5:50 am
by ugkbunb
I am using zm 1.24.1 PKGBUILD. I am unable to build the svn version... even with disabling makeflags the build errors before completion.

Dropping the database manually and re-running zminit led to the same error posted above. Commenting out safe-updates and restarting mysqld allow zminit to complete without errors. Now however when I point my browser to http://localhost/zm

I get the following:
Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

If you think this is a server error, please contact the webmaster.
Error 403
localhost
Sun Apr 5 00:48:30 2009
Apache/2.2.11 (Unix) mod_ssl/2.2.11 OpenSSL/0.9.8k DAV/2
Double checked and mysqld httpd as well as zm are all running. Any help is appreciated. Thanks for the help so far.

Posted: Sun Apr 05, 2009 1:26 pm
by rdmelin
Try http://localhost/zm/index.php
Close your browser first and reopen a fresh browser

If you still have trouble, make sure there is a line in /etc/httpd/conf/httpd.conf
LoadModule php5_module modules/libphp5.so
If not add or uncomment this line and restart httpd

Posted: Sun Apr 05, 2009 3:32 pm
by ugkbunb
I had already placed the line
LoadModule php5_module modules/libphp5.so
into the httpd.conf

Restarting the computer or browser window does nothing.

When I navigate to:
http://localhost/zm/index.php

I get the following:
//
// ZoneMinder main web interface file, $Date: 2008-09-26 10:47:20 +0100 (Fri, 26 Sep 2008) $, $Revision: 2632 $
// Copyright (C) 2001-2008 Philip Coombes
//
// This program 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 2
// of the License, or (at your option) any later version.
//
// This program 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 this program; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//

error_reporting( E_ALL );

$debug = false;
if ( $debug )
{
// Use these for debugging, though not both at once!
phpinfo( INFO_VARIABLES );
//error_reporting( E_ALL );
}

// Use new style autoglobals where possible
if ( version_compare( phpversion(), "4.1.0", "<") )
{
$_SESSION = &$HTTP_SESSION_VARS;
$_SERVER = &$HTTP_SERVER_VARS;
}

// Useful debugging lines for mobile devices
if ( false )
{
ob_start();
phpinfo( INFO_VARIABLES );
$fp = fopen( "/tmp/env.html", "w" );
fwrite( $fp, ob_get_contents() );
fclose( $fp );
ob_end_clean();
}

if ( isset($_SERVER["HTTPS"]) && $_SERVER["HTTPS"] == 'on' )
{
$protocol = 'https';
}
else
{
$protocol = 'http';
}
define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );

if ( isset($_GET['skin']) )
$skin = $_GET['skin'];
elseif ( isset($_COOKIE['zmSkin']) )
$skin = $_COOKIE['zmSkin'];
else
$skin = "classic";

define( "ZM_BASE_PATH", dirname( $_SERVER['REQUEST_URI'] ) );
define( "ZM_SKIN_PATH", "skins/$skin" );

$skinBase = array(); // To allow for inheritance of skins
if ( !file_exists( ZM_SKIN_PATH ) )
die( "Invalid skin '$skin'" );
require_once( ZM_SKIN_PATH.'/includes/init.php' );
$skinBase[] = $skin;

ini_set( "session.name", "ZMSESSID" );

session_start();

if ( !isset($_SESSION['skin']) || isset($_REQUEST['skin']) )
{
$_SESSION['skin'] = $skin;
setcookie( "zmSkin", $skin );
}

require_once( 'includes/config.php' );

if ( ZM_OPT_USE_AUTH )
if ( isset( $_SESSION['user'] ) )
$user = $_SESSION['user'];
else
unset( $user );
else
$user = $defaultUser;

require_once( 'includes/lang.php' );
require_once( 'includes/functions.php' );

if ( isset($_REQUEST['view']) )
$view = validHtmlStr($_REQUEST['view']);

if ( isset($_REQUEST['action']) )
$action = validHtmlStr($_REQUEST['action']);

require_once( 'includes/actions.php' );

foreach ( getSkinIncludes( 'skin.php' ) as $includeFile )
require_once $includeFile;

if ( isset( $_REQUEST['request'] ) )
{
$request = validHtmlStr($_REQUEST['request']);
foreach ( getSkinIncludes( 'ajax/'.$request.'.php', true, true ) as $includeFile )
{
if ( !file_exists( $includeFile ) )
die( "Request '$request' does not exist" );
require_once $includeFile;
}
return;
}
else
{
if ( $includeFiles = getSkinIncludes( 'views/'.$view.'.php', true, true ) )
{
foreach ( $includeFiles as $includeFile )
{
if ( !file_exists( $includeFile ) )
die( "View '$view' does not exist" );
require_once $includeFile;
}
}
if ( !$includeFiles || $view == 'error' )
{
foreach ( getSkinIncludes( 'views/error.php', true, true ) as $includeFile )
require_once $includeFile;
}
}

Posted: Sun Apr 05, 2009 4:06 pm
by rdmelin
Sorry, I think you will need to add /var/lib/zm/ to the "open_basedir =" line in /etc/php/php.ini.

I will need to add a few lines to the install file in the PKGBUILD to fill in these gaps :oops:

Posted: Sun Apr 05, 2009 4:25 pm
by ugkbunb
I sincerely appreciate all the help. After adding the above to my openbase_dir line it looks like this:
open_basedir = /srv/http/:/home/:/tmp/:/usr/share/pear/:/etc/:/var/lib/zm/
I restarted my httpd, zm, and firefox. http://localhost/zm still complains about lack of access and http://localhost/zm/index.php still brings up the above text. Any ideas on what to try next?

Posted: Sun Apr 05, 2009 4:45 pm
by rdmelin
Examine /etc/httpd/conf/httpd.conf

There is a section that may look like this (Indenting is borked but otherwise..)
<IfModule dir_module>
DirectoryIndex index.html
</IfModule>
If so add so that it looks like this
<IfModule dir_module>
<IfModule mod_php5.c>
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps
</IfModule>
DirectoryIndex index.html
</IfModule>
This may solve the access error, maybe both, not sure about the problem with displaying instead of executing the php.

If that problem persists run ' apachectl -M' and make sure that php5_module is in fact loaded and syntax is correct

Posted: Sun Apr 05, 2009 5:02 pm
by ugkbunb
Thanks so much! The above fixed my access issue and I am now able to add my camera and view their feeds...

apachectl -M showed php5_module loaded... output below

Code: Select all

  [*******@*****-desktop ~]$ apachectl -M
Loaded Modules:
 core_module (static)
 mpm_prefork_module (static)
 http_module (static)
 so_module (static)
php5_module (shared)
 authn_file_module (shared)

Posted: Sun Apr 05, 2009 5:13 pm
by rdmelin
However when navigate to index.php it still views the file instead of executing it.
Be sure you aren't viewing a cached (by firefox) page.

If you set "browser.cache.check_doc_frequency;1" using the 'about:config' function in firefox it will also prevent some problems with viewing streams in zoneminder.

Posted: Sun Apr 05, 2009 5:54 pm
by ugkbunb
oops I feel like a moron! thanks : ) could of sworn I hit refresh. yah both are working as they should. hopefully this thread can help others if they run into the same issue.

thanks again for all your help

Posted: Sun Apr 05, 2009 5:59 pm
by rdmelin
If you would like to email me a package I'll put it up for others to download.

rdmelin (at) gmail dot com

Also thank you for testing and hanging in there. I will make some changes to the install file so others may have a smother time of it.

Posted: Sun Apr 05, 2009 6:32 pm
by ugkbunb
Sure thing... on my laptop atm but when I get home I will recompile it with the generic ARCH CFLAGS and email you the package.