Changing the Apache root directory for ZM

Forum for questions and support relating to the 1.28.x releases only.
Locked
daveharris
Posts: 25
Joined: Mon Oct 26, 2009 2:47 pm

Changing the Apache root directory for ZM

Post by daveharris »

Hi, I recently installed ZoneMinder on a Hyper-V (again) and all is good: http://dave.harris.uno/installing-zonem ... n-hyper-v/

However, I would like to change the setup to remove the /zm in the URL and previously I have managed to change the root directory in Apache2 to accomplish this.

It seems that perhaps there have been some Apache security updates/changes since last time that I did this and I just cannot get it to work.

I'm predominantly a Windows guy and only have the odd play with Linux. I've used guides from the following places but with no luck, the most I managed to get to was the root showing "Forbidden - You don't have permission to access / on this server."
I'm hoping it a pretty straight forward change, could anyone possibly help me out here please?

Regards,

Dave.
theforce
Posts: 129
Joined: Tue May 11, 2010 5:22 am

Re: Changing the Apache root directory for ZM

Post by theforce »

I think you can change the Alias line in /etc/apache2/conf.d/zoneminder.conf

Normally its /zm I think you can change it to / but not sure. I changed mine to /cameras for mysetup.
daveharris
Posts: 25
Joined: Mon Oct 26, 2009 2:47 pm

Re: Changing the Apache root directory for ZM

Post by daveharris »

Ok, so after a lot of playing around I couldn't seem to change the root, I kept running into permission errors. So instead I just copied all the ZoneMinder web files to the default root directory with:

sudo su
command cp -r /usr/share/zoneminder/* /var/www


and that seems to work.
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Changing the Apache root directory for ZM

Post by knight-of-ni »

Windows? What's that? Well, I won't hold it against you, but it does explain, to me anyway, the solution you chose to implement.

In the long run, you are better off going with the way your distro intended things to be, rather than going against it.

All the major Linux distros make use of Aliases to link in folders from other locations on your hard drive into your web server. Often, that other location is under /usr/share. They no longer place production files, other than perhaps a default "your web server is working" file, directly into or under the document root folder.

Since this is Linux, you can certainly undo that and do whatever you want. However, working against the default rules your system follows can create problems later on. For example, a package update can easily overwrite your changes.

Later on, if you decide to add some other package that also has a web portal, you may end up having to undo the changes you made yourself anyway.

The way to avoid all that is to use Alias as mentioned in the previous post.

An alternative would be to place a small index.html into your document root that just redirects to /zm. On simple systems, this is how I have done it.
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/
daveharris
Posts: 25
Joined: Mon Oct 26, 2009 2:47 pm

Re: Changing the Apache root directory for ZM

Post by daveharris »

Thanks knnniggett for spending the time to explain this.
The VM is purely for ZM, and this is only in a home environment and so not critical.
I will have a bit more a play now and will let you know how I get on.
Thanks again,
Regards,
Dave.
Nerre
Posts: 100
Joined: Thu Sep 25, 2014 10:22 am

Re: Changing the Apache root directory for ZM

Post by Nerre »

daveharris wrote: It seems that perhaps there have been some Apache security updates/changes since last time that I did this and I just cannot get it to work.
What error messages did you get? (You DID look in the logs to see why it didn't work, didn't you?)

And you did a full graceful reload of Apache to make it read the new config?
daveharris
Posts: 25
Joined: Mon Oct 26, 2009 2:47 pm

Re: Changing the Apache root directory for ZM

Post by daveharris »

They seemed to be permissions based errors from memory, I will have a look this evening and see if I can gather any more.

Yes, restarted Apache2 and even restarted the machine. The config changes were being recognised as I got an error, I just never managed to get past that error :)

For now, having copied the files over seems to work well enough for me, long term it would be better to find a neat solution though so ill keep at it. As its a VM, I can roll back any changes pretty easily.
Nerre
Posts: 100
Joined: Thu Sep 25, 2014 10:22 am

Re: Changing the Apache root directory for ZM

Post by Nerre »

There are some security settings in Apache that I think makes sure that the files need to be owned by the user the web server is run as. But if the /zm alias works it doesn't really make sense...
Locked