Futz'n with LEMP

Forum for questions and support relating to the 1.32.x releases only.
Post Reply
Pedulla
Posts: 167
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Futz'n with LEMP

Post by Pedulla »

It might be a little premature for this, but I'm futz'n with 1.32.0 on Ubuntu 18.04, NGNIX, MariaDB.

I pulled together steps from the following links:
https://wiki.zoneminder.com/Ubuntu_Serv ... .2C_PHP.29
https://wiki.zoneminder.com/Ubuntu_Serv ... e_easy_way

That resulted in the following steps (bash history with screwed up commands removed):

Code: Select all

   10  sudo apt install nginx mariadb-server php-fpm php-mysql fcgiwrap
   12  sudo mysql_secure_installation
   13  sudo systemctl restart mysql
   14  sudo nano /etc/php/7.2/fpm/php.ini   (set timezone)
   17  sudo nano /etc/php/7.2/fpm/php.ini   (set cgi.fix_pathinfo=0)
   18  sudo systemctl restart php7.2-fpm
   20  sudo apt install -y software-properties-common
   21  sudo add-apt-repository ppa:iconnor/zoneminder    (shows list of repositories to choose)
   22  sudo add-apt-repository ppa:iconnor/zoneminder-1.32
   23  sudo apt update
   25  sudo apt install zoneminder
   26  sudo systemctl enable zoneminder
   27  sudo service zoneminder start
   28  sudo adduser www-data video
   29  sudo chown -R www-data:www-data /usr/share/zoneminder/
   30  sudo nano /etc/nginx/sites-available/default   (added "index.php" in the server section)
   31  sudo nano /etc/nginx/zoneminder.conf   (created zoneminder.conf from first link above)
   32  sudo nano /etc/nginx/sites-enabled/default  (added "include /etc/nginx/zoneminder.conf;" in the server section)
   33  sudo systemctl restart nginx
   34  sudo nano /etc/default/fcgiwrap    (created file and added "DAEMON_OPTS=-c 10" per instructions in first link above)
   35  sudo systemctl restart fcgiwrap
First access to the Zoneminder console (http://<<IP>>/zm) brings up the new terms page then proceeds to the console as expected, after accepting. Zoneminder survives a system reboot, so it seems like I've got everything.
Now it's on to adding monitors.

If anyone can see any misses here please let me know.
Pedulla
Posts: 167
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: Futz'n with LEMP

Post by Pedulla »

So first crack at adding a monitor throws the following error in the syslog:

Code: Select all

Sep 26 19:38:13 zm web_php[279]: ERR [Uncaught ReferenceError: addMonitor is not defined]
Sep 26 19:39:02 zm systemd[1]: Starting Clean php session files...
Sep 26 19:39:02 zm kernel: [6180511.795264] audit: type=1400 audit(1537990742.597:137): apparmor="DENIED" operation="mount" info="failed flags match" error=-13 profile="lxc-container-default-cgns" name="/" pid=3003 comm="(ionclean)" flags="rw, rslave"
Sep 26 19:39:02 zm systemd[1]: Started Clean php session files.
Guess I should have mentioned I'm running this in a container on ProxMox as opposed to a full VM.

So is this a /etc/nginx/zoneminder.conf issue or possibly a container issue?

The release notes say that paths have been integrated into conf.d folder, but I don't know what that means for my setup.
Pedulla
Posts: 167
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: Futz'n with LEMP

Post by Pedulla »

Screenshot at 2018-09-27 08-48-56.png
Screenshot at 2018-09-27 08-48-56.png (41.48 KiB) Viewed 7170 times
I realized the Web interface might have some indications as to what part of the config is messed up.
Seems like elements like Name and Source are displaying fallback info rather than the intended content.

Does this help anybody to give me a clue?
moorsey
Posts: 53
Joined: Sun Jan 03, 2010 8:56 am

Re: Futz'n with LEMP

Post by moorsey »

For me, this was a missing "cache" folder in "/var/cache/zoneminder"

Not sure if same issue, I'm using Docker and not sure if unique to that. But may be along the same lines

https://github.com/QuantumObject/docker ... -423478617
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Futz'n with LEMP

Post by knight-of-ni »

We had a user contribute his working nginx config, which contains the needed alias to the new cache folder:
https://github.com/ZoneMinder/zoneminde ... -423321998

This user installed from source, so most everyone will need to edit the paths in the config.
Once we get a consensus on what works for the majority user base, I'll merge this into the project.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
Pedulla
Posts: 167
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: Futz'n with LEMP

Post by Pedulla »

Applying the include method from the instructions in the first post, I've matched up all the settings/directives. (and converted to Ubuntu paths)
Here's my /etc/nginx/zoneminder.conf

Code: Select all

location /zm/cgi-bin {
    gzip off;
    alias /usr/lib/zoneminder/cgi-bin;

    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}

location /zm/cache {
    alias /var/cache/zoneminder/;
    try_files $uri $uri/;
}

location /zm {
#   if ($scheme ~ ^http:){
# rewrite ^(.*)$  https://$host$1 permanent;
#   }

    gzip off;
    alias /usr/share/zoneminder/www;
    try_files $uri $uri/ /index.html /index.php;
    index index.php;

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }
        expires             epoch;
        include             /etc/nginx/fastcgi_params;
        fastcgi_param       SCRIPT_FILENAME         $request_filename;
        fastcgi_index       index.php;
        fastcgi_pass        unix:/var/run/php/php7.2-fpm.sock;
    }


    location ~ \.(jpg|jpeg|gif|png|ico)$ {
        access_log          off;
        expires         33d;
    }
    location /zm/api/ {
        alias                   /usr/share/zoneminder/www/api;
        rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
# added app/webroot from sample file
    }
}
There is a discrepancy in the rewrite line of the zm/api section, but changing it does not change the issue.

I noticed my LEMP stack included included PHP 7.2 and the referenced conf file seems to refer to PHP 7.0.

Is there something else that needs to be configured to look for 7.2?
terdinglage
Posts: 11
Joined: Thu Jan 03, 2019 7:14 am

Re: Futz'n with LEMP

Post by terdinglage »

Pedulla wrote: Sat Sep 29, 2018 6:22 am Applying the include method from the instructions in the first post, I've matched up all the settings/directives. (and converted to Ubuntu paths)
Here's my /etc/nginx/zoneminder.conf

Code: Select all

location /zm/cgi-bin {
    gzip off;
    alias /usr/lib/zoneminder/cgi-bin;

    include /etc/nginx/fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $request_filename;
    fastcgi_pass  unix:/var/run/fcgiwrap.socket;
}

location /zm/cache {
    alias /var/cache/zoneminder/;
    try_files $uri $uri/;
}

location /zm {
#   if ($scheme ~ ^http:){
# rewrite ^(.*)$  https://$host$1 permanent;
#   }

    gzip off;
    alias /usr/share/zoneminder/www;
    try_files $uri $uri/ /index.html /index.php;
    index index.php;

    location ~ \.php$ {
        if (!-f $request_filename) { return 404; }
        expires             epoch;
        include             /etc/nginx/fastcgi_params;
        fastcgi_param       SCRIPT_FILENAME         $request_filename;
        fastcgi_index       index.php;
        fastcgi_pass        unix:/var/run/php/php7.2-fpm.sock;
    }


    location ~ \.(jpg|jpeg|gif|png|ico)$ {
        access_log          off;
        expires         33d;
    }
    location /zm/api/ {
        alias                   /usr/share/zoneminder/www/api;
        rewrite ^/zm/api(.+)$ /zm/api/app/webroot/index.php?p=$1 last;
# added app/webroot from sample file
    }
}
There is a discrepancy in the rewrite line of the zm/api section, but changing it does not change the issue.

I noticed my LEMP stack included included PHP 7.2 and the referenced conf file seems to refer to PHP 7.0.

Is there something else that needs to be configured to look for 7.2?
Were you ever able to get this LEMP configuration fully functional? I am currently on 16.04 and really wanting to upgrade to 18.04, but I need a LEMP solution to do that.
rockedge
Posts: 1173
Joined: Fri Apr 04, 2014 1:46 pm
Location: Connecticut,USA

Re: Futz'n with LEMP

Post by rockedge »

make sure there is either a symlink /usr/share/zoneminder/www/cache with the target /var/cache/zoneminder/cache
or declare an alias in your NGINX config for /zm/cache with the target /var/cache/zoneminder/cache

I use Hiawatha and my rewrite for the API to work correctly looks like this:

Code: Select all

UrlToolkit {
  ToolkitID = api_rule
  Match ^/zm/api Rewrite  /zm/api/app/webroot/index.php$1
}
terdinglage
Posts: 11
Joined: Thu Jan 03, 2019 7:14 am

Re: Futz'n with LEMP

Post by terdinglage »

rockedge wrote: Thu Jan 03, 2019 4:47 pm make sure there is either a symlink /usr/share/zoneminder/www/cache with the target /var/cache/zoneminder/cache
or declare an alias in your NGINX config for /zm/cache with the target /var/cache/zoneminder/cache

I use Hiawatha and my rewrite for the API to work correctly looks like this:

Code: Select all

UrlToolkit {
  ToolkitID = api_rule
  Match ^/zm/api Rewrite  /zm/api/app/webroot/index.php$1
}
Sorry for being slow, I’m really unfamiliar with this stuff. Are you saying the lines of code you referenced are changes you made to the version last posted on this thread to make the configuration work?

Just to clarify, my goal is an nginx configuration file that will work with my reverse proxy, similar to what is shown in this tutorial, but for 18.04:

https://wiki.zoneminder.com/Ubuntu_Serv ... and_PHP.29
Pedulla
Posts: 167
Joined: Thu Nov 27, 2014 11:16 am
Location: Portland, Or

Re: Futz'n with LEMP (Solved)

Post by Pedulla »

Since I started this thread, now that I've had a chance to get back to this, I thought I post what worked.

https://wiki.zoneminder.com/Ubuntu_Serv ... .2C_PHP.29

These direction and zonminder.conf worked WITH THE EXCEPTION THAT...
I did not remove the /zm in value for ZM_PATH_ZMS in the 01-system-paths.conf file as directed (should remain at default)
-and-
in the /etc/nginx/zoneminder.conf file needs the first line to read like so:

Code: Select all

location /zm/cgi-bin {
to match the default.

It's working. Yeah!


Now it's on to the Event Server {insert dramatic music here}
Post Reply