New install 1.32.3 on Ubuntu Server 18.04 LTS

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
nexuslion
Posts: 5
Joined: Fri Feb 01, 2019 3:11 am

New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by nexuslion » Fri Feb 01, 2019 3:28 am

I had 16.04 LTS installed, and had ZM 1.32.3 running. It was working with 1 camera in Modect mode.

I upgraded to 18.04 LTS.
I uninstalled ZM and reinstalled using the tutorial https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way and now I think i have a problem with my PHP or Apache2 configuration.

When I go to my localIP/zm

instead of the normal console it shows:

Code: Select all

<?php
//
// ZoneMinder main web interface file, $Date$, $Revision$
// 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 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();
}

require_once('includes/config.php');
require_once('includes/logger.php');
require_once('includes/Server.php');
require_once('includes/Storage.php');
require_once('includes/Event.php');
require_once('includes/Group.php');
require_once('includes/Monitor.php');


if (
  (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] == 'on')
  or
  (isset($_SERVER['HTTP_X_FORWARDED_PROTO']) and ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https'))
) {
  $protocol = 'https';
} else {
  $protocol = 'http';
}
define('ZM_BASE_PROTOCOL', $protocol);

// Absolute URL's are unnecessary and break compatibility with reverse proxies 
// define( "ZM_BASE_URL", $protocol.'://'.$_SERVER['HTTP_HOST'] );

// Use relative URL's instead
define('ZM_BASE_URL', '');

// Check time zone is set
if (!ini_get('date.timezone') || !date_default_timezone_set(ini_get('date.timezone'))) {
  date_default_timezone_set('UTC');
  Fatal( "ZoneMinder is not installed properly: php's date.timezone is not set to a valid timezone" );
}

if ( isset($_GET['skin']) ) {
  $skin = $_GET['skin'];
} else if ( isset($_COOKIE['zmSkin']) ) {
  $skin = $_COOKIE['zmSkin'];
} else if ( defined('ZM_SKIN_DEFAULT') ) {
  $skin = ZM_SKIN_DEFAULT;
} else {
  $skin = 'classic';
}

$skins = array_map('basename', glob('skins/*', GLOB_ONLYDIR));

if ( ! in_array($skin, $skins) ) {
  Error("Invalid skin '$skin' setting to " . $skins[0]);
  $skin = $skins[0];
}

if ( isset($_GET['css']) ) {
  $css = $_GET['css'];
} elseif ( isset($_COOKIE['zmCSS']) ) {
  $css = $_COOKIE['zmCSS'];
} elseif ( defined('ZM_CSS_DEFAULT') ) {
  $css = ZM_CSS_DEFAULT;
} else {
  $css = 'classic';
}

$css_skins = array_map('basename', glob('skins/'.$skin.'/css/*',GLOB_ONLYDIR));
if ( !in_array($css, $css_skins) ) {
  Error("Invalid skin css '$css' setting to " . $css_skins[0]);
  $css = $css_skins[0];
}

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

$skinBase = array(); // To allow for inheritance of skins
if ( !file_exists(ZM_SKIN_PATH) )
  Fatal("Invalid skin '$skin'");
$skinBase[] = $skin;

$currentCookieParams = session_get_cookie_params(); 
//Logger::Debug('Setting cookie parameters to lifetime('.$currentCookieParams['lifetime'].') path('.$currentCookieParams['path'].') domain ('.$currentCookieParams['domain'].') secure('.$currentCookieParams['secure'].') httpOnly(1)');
session_set_cookie_params( 
    $currentCookieParams['lifetime'], 
    $currentCookieParams['path'], 
    $currentCookieParams['domain'],
    $currentCookieParams['secure'], 
    true
); 

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

session_start();

if ( !isset($_SESSION['skin']) || isset($_REQUEST['skin']) || !isset($_COOKIE['zmSkin']) || $_COOKIE['zmSkin'] != $skin ) {
  $_SESSION['skin'] = $skin;
  setcookie('zmSkin', $skin, time()+3600*24*30*12*10);
}

if ( !isset($_SESSION['css']) || isset($_REQUEST['css']) || !isset($_COOKIE['zmCSS']) || $_COOKIE['zmCSS'] != $css ) {
  $_SESSION['css'] = $css;
  setcookie('zmCSS', $css, time()+3600*24*30*12*10);
}

if ( ZM_OPT_USE_AUTH ) {
  if ( isset($_SESSION['user']) ) {
    $user = $_SESSION['user'];
  } else {
    unset($user);
  }
} else {
  $user = $defaultUser;
}
# Only one request can open the session file at a time, so let's close the session here to improve concurrency.
# Any file/page that sets session variables must re-open it.
session_write_close();

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

# Running is global but only do the daemonCheck if it is actually needed
$running = null;

# Add Cross domain access headers
CORSHeaders();

// Check for valid content dirs
if ( !is_writable(ZM_DIR_EVENTS) || !is_writable(ZM_DIR_IMAGES) ) {
  Warning("Cannot write to content dirs('".ZM_DIR_EVENTS."','".ZM_DIR_IMAGES."').  Check that these exist and are owned by the web account user");
}

# Globals
$redirect = null;
$view = null;
if ( isset($_REQUEST['view']) )
  $view = detaintPath($_REQUEST['view']);

$request = null;
if ( isset($_REQUEST['request']) )
  $request = detaintPath($_REQUEST['request']);

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

if ( ZM_OPT_USE_AUTH ) {
    if ( ZM_AUTH_HASH_LOGINS && empty($user) && ! empty($_REQUEST['auth']) ) {
      if ( $authUser = getAuthUser($_REQUEST['auth']) ) {
        userLogin($authUser['Username'], $authUser['Password'], true);
      }
    } 
   else if ( isset($_REQUEST['username']) and isset($_REQUEST['password']) ) {
	userLogin($_REQUEST['username'], $_REQUEST['password'], false);
  }
  if ( !empty($user) ) {
    // generate it once here, while session is open.  Value will be cached in session and return when called later on
    generateAuthHash(ZM_AUTH_HASH_IPS);
  }
}

if ( isset($_REQUEST['action']) ) {
  $action = detaintPath($_REQUEST['action']);
}

# The only variable we really need to set is action. The others are informal.
isset($view) || $view = NULL;
isset($request) || $request = NULL;
isset($action) || $action = NULL;

Logger::Debug("View: $view Request: $request Action: $action");
if (
  ZM_ENABLE_CSRF_MAGIC &&
  ( $action != 'login' ) &&
  ( $view != 'view_video' ) &&
  ( $view != 'image' ) &&
  ( $request != 'control' ) && 
  ( $view != 'frames' ) && 
  ( $view != 'archive' )
) {
  require_once( 'includes/csrf/csrf-magic.php' );
  #Logger::Debug("Calling csrf_check with the following values: \$request = \"$request\", \$view = \"$view\", \$action = \"$action\"");
  csrf_check();
}

# Need to include actions because it does auth
require_once('includes/actions.php');

# If I put this here, it protects all views and popups, but it has to go after actions.php because actions.php does the actual logging in.
if ( ZM_OPT_USE_AUTH and !isset($user) ) {
  Logger::Debug('Redirecting to login');
  $view = 'login';
  $request = null;
} else if ( ZM_SHOW_PRIVACY && ($action != 'privacy') && ($view !='options') && (!$request) && canEdit('System') ) {
  Logger::Debug('Redirecting to privacy');
  $view = 'privacy';
  $request = null;
}

if ( $redirect ) {
  header('Location: '.$redirect);
  return;
}

if ( $request ) {
  foreach ( getSkinIncludes('ajax/'.$request.'.php', true, true) as $includeFile ) {
    if ( !file_exists($includeFile) )
      Fatal("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) )
        Fatal("View '$view' does not exist");
      require_once $includeFile;
    }
    // If the view overrides $view to 'error', and the user is not logged in, then the
    // issue is probably resolvable by logging in, so provide the opportunity to do so.
    // The login view should handle redirecting to the correct location afterward.
    if ( $view == 'error' && !isset($user) ) {
      $view = 'login';
      foreach ( getSkinIncludes('views/login.php', true, true) as $includeFile )
        require_once $includeFile;
    }
  }
  // If the view is missing or the view still returned error with the user logged in,
  // then it is not recoverable.
  if ( !$includeFiles || $view == 'error' ) {
    foreach ( getSkinIncludes('views/error.php', true, true) as $includeFile )
      require_once $includeFile;
  }
}
?>
Do I need to change something in my php.ini?

Thanks for the help

pat2
Posts: 73
Joined: Fri Sep 16, 2016 6:35 pm

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by pat2 » Fri Feb 01, 2019 4:03 pm

I was able to install 18.04 and ZM 1.32. It's working but no video (=black) for ffmpeg cameras (video is ok for remote cameras).
no video (=black) for recoded images.

To install ZM 1.32 (i didn't find the package for other versions) on 18.04 I did the following:

- installed LAMP:

Code: Select all

sudo apt update && sudo apt install apache2
sudo service apache2 status

sudo apt update && sudo apt install mysql-server
sudo service mysql status

sudo apt update && sudo apt install php libapache2-mod-php php-mysql
php -version
then installed ZM 1.32 following direction at:

https://zoneminder.readthedocs.io/en/la ... untu-16-04

skipping step3.

Pedulla
Posts: 133
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by Pedulla » Fri Feb 01, 2019 4:57 pm

Just a note. I have yet to get a working system upgrading UB from any version previous to 18.04.
Just start from scratch and install the LAMP / LEMP stack.

Note: see forum for LEMP tips.

nexuslion
Posts: 5
Joined: Fri Feb 01, 2019 3:11 am

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by nexuslion » Fri Feb 01, 2019 7:12 pm

Ok thank you, I'll wipe the drive and start with a fresh install of 18.04 and LAMP.

nexuslion
Posts: 5
Joined: Fri Feb 01, 2019 3:11 am

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by nexuslion » Sat Feb 02, 2019 4:15 am

Fresh install
1.32.3 installed on
18.04 LTS with LAMP.
Followed instructions to the letter.

Still got /zm console page showing PHP as text (as my OP shows above).

on Stack Exchange I found this question:

https://askubuntu.com/questions/1028422 ... e-to-18-04

Which said to try:

Code: Select all

sudo a2enmod php7.2
Worked like a champ!

Hope this helps someone else trying to get 1.32.x running on 18.04 LTS.

bbunge
Posts: 2441
Joined: Mon Mar 26, 2012 11:40 am
Location: Pennsylvania

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by bbunge » Sat Feb 02, 2019 3:35 pm

If you use the Ubuntu install script on the Zoneminder Wiki the install works without issues!
https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way

nexuslion
Posts: 5
Joined: Fri Feb 01, 2019 3:11 am

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by nexuslion » Sat Feb 02, 2019 10:47 pm

bbunge wrote:
Sat Feb 02, 2019 3:35 pm
If you use the Ubuntu install script on the Zoneminder Wiki the install works without issues!
https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way
I'm glad the script worked for you, but the script does not enable PHP which is what I had to do to get it to load the console page.

Now I have other problems as I cannot view streams, getting tons of socket errors.

nexuslion
Posts: 5
Joined: Fri Feb 01, 2019 3:11 am

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by nexuslion » Sun Feb 03, 2019 2:25 am

I'm using Webmin to manage my Ubuntu Server. Is anyone familiar with that interface on how to verify that CGI is enabled and configured correctly?

I'm getting this error in the logs:

Code: Select all

Socket /var/run/zm/zms-675803s.sock does not exist.
This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. 
Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. 
Make sure that ZM is actually recording. 
If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. 
Please go to http://zoneminder.readthedocs.io/en/latest/faq.html#why-can-t-i-see-streamed-images-when-i-can-see-stills-in-the-zone-window-etc
for more information.

Pedulla
Posts: 133
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: New install 1.32.3 on Ubuntu Server 18.04 LTS

Post by Pedulla » Wed Feb 06, 2019 4:32 am

If your going LAMP, use tasksel to install the LAMP stack from scratch and then use the easy way script here https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way. works great.

If your going LEMP, take a fresh install and use these instructions: https://wiki.zoneminder.com/Ubuntu_Serv ... .2C_PHP.29

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest