Page 1 of 1

can't access my original apache document root anymore

Posted: Sat Nov 13, 2021 5:32 pm
by danielmalaga
Hi,

somehow the ZoneMinder install managed to change my document root from /srv/www/htdocs to /usr/share/zoneminder/www so that now everything under my original document root causes a 404 error.

what can I do so that I can again run my own apps (and phpMyAdmin!) using, for example, http://localhost/phpMyAdmin or http://localhost/myfolder/index.php and still run ZoneMinder?

I use Opensuse 15.2 linux, and have not much idea about configuring apache apart of the basics...

Thank you for your help!

Re: can't access my original apache document root anymore

Posted: Sun Nov 14, 2021 6:53 am
by moholstein
It shouldn't have .. typically zoneminder is it's on ./apache2/sites-enabled/zoneminder.conf (symlink to) ./sites-avaible/zoneminder.conf. This is what a2ensite (site) or a2enconf (for ./conf-availabe, same gist as before) ... and zoneminder becomes live at ::80/zm

you config sounds like you have zoneminder now what you get at HTTP://localhost:80 .. is that what happens or do you get the "It works" Apache default?

If you have ::80/webmin or whatever .. generally there's a separate conf file for it that has the correct DoccumentRoot for it, it's highly unwise to eg: install webmin and then copy (or link) the contents in to /blah/blah/www/ (default site) and just make a new directory that way, as it inherits all the (fairly loose) permission of the default.

So since I don't know exactly what happened here the fastest way is to find out what files changed so just do "grep -r "\/srv\/www\/htdocs" /etc/apache2/ and see what it spits out that contains the old path. did it get moved, overwritten, ?

try "find / -name sites-enabled"
and see where apache is installed .. do an "ls -l /that/path/sites-enabled" and see if you find symlinks to where /srv/www/htdocs is at? ... if not, which file from the above step contains it? try and do "a2ensite (name of that file - confg) ... eg "a2ensite 000-vhost-default.conf"

Been a while since I've seen web served out of /srv but arging about Linux is like arguing about beer .. just use what you like as long as it works for you.

Re: can't access my original apache document root anymore

Posted: Sun Nov 14, 2021 11:25 am
by danielmalaga
http://localhost:80 (as well as simply http://localhost) shows the Zoneminder index page, but without stying, obviously css not loaded. (the styled page appears under localhost/zm)
Before the ZoneMinder install it was apache's "it works".

Code: Select all

 # grep -r "\/srv\/www\/htdocs" /etc/apache2/
/etc/apache2/conf.d/phpMyAdmin.conf:<Directory /srv/www/htdocs/phpMyAdmin>
/etc/apache2/conf.d/phpMyAdmin.conf:        php_admin_value open_basedir "/srv/www/htdocs/phpMyAdmin:/var/lib/php5:/tmp:/usr/share/doc/packages/phpMyAdmin:/etc/phpMyAdmin:/proc/meminfo:/proc/stat"
/etc/apache2/conf.d/phpMyAdmin.conf:        php_admin_value open_basedir "/srv/www/htdocs/phpMyAdmin:/var/lib/php7:/tmp:/usr/share/doc/packages/phpMyAdmin:/etc/phpMyAdmin:/proc/meminfo:/proc/stat"
/etc/apache2/conf.d/phpMyAdmin.conf:<Directory /srv/www/htdocs/phpMyAdmin/libraries>
/etc/apache2/conf.d/phpMyAdmin.conf:<Directory /srv/www/htdocs/phpMyAdmin/templates>
/etc/apache2/conf.d/phpMyAdmin.conf:<Directory /srv/www/htdocs/phpMyAdmin/tmp>
/etc/apache2/default-server.conf:DocumentRoot "/srv/www/htdocs"
/etc/apache2/default-server.conf:<Directory "/srv/www/htdocs">
/etc/apache2/vhosts.d/vhost-ssl.template:       DocumentRoot "/srv/www/htdocs"
/etc/apache2/vhosts.d/zm.conf:    <Directory /srv/www/htdocs/zm/events/>

Code: Select all

# find / -name sites-enabled
find: ‘/run/user/1000/gvfs’: Permission denied 
I've come across a file "sites-enabled" during my google search, but on my computer it doesn't exist. This is an OpenSuse 15.2 Linux and maybe apache standard install is slightly different?

"a2ensite" and it's counterpart are not installed here.

I've seen that there exists a file "zm.conf" in /etc/apache2/vhosts.d that cotains the following:

Code: Select all

 <VirtualHost *:80>
    ServerAdmin webmaster@localhost

    DocumentRoot "/usr/share/zoneminder/www"

    # Order matters. This alias must come first.
    Alias /zm/cache "/var/cache/zoneminder/"
    # IF you aren't using /zm in the url to access ZM then uncomment the following line as well
    # Alias /cache "/var/cache/zoneminder/cache"
    
    <Directory "/var/cache/zoneminder/">
        Options -Indexes +FollowSymLinks
        AllowOverride None
        <IfModule mod_authz_core.c>
           # Apache 2.4
           Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>
    
    ScriptAlias /zm/cgi-bin/ "/usr/lib/zoneminder/cgi-bin"
    ScriptAlias /cgi-bin "/usr/lib/zoneminder/cgi-bin"
    <Directory "/usr/lib/zoneminder/cgi-bin">
        Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
        AllowOverride All
        <IfModule mod_authz_core.c>
           # Apache 2.4
           Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>

    Alias /zm "/usr/share/zoneminder/www" 
    <Directory "/usr/share/zoneminder/www">
        Options -Indexes +FollowSymLinks
        AllowOverride All
        <IfModule mod_authz_core.c>
           # Apache 2.4
           Require all granted
        </IfModule>
        <IfModule !mod_authz_core.c>
            # Apache 2.2
            Order deny,allow
            Allow from all
        </IfModule>
    </Directory>
    # For better visibility, the following directives have been migrated from the
    # default .htaccess files included with the CakePHP project.
    # Parameters not set here are inherited from the parent directive above.
    <Directory "/usr/share/zoneminder/www/api">
       RewriteEngine on
       RewriteRule ^$ app/webroot/ [L]
       RewriteRule (.*) app/webroot/$1 [L]
       RewriteBase /zm/api
    </Directory>

    <Directory "/usr/share/zoneminder/www/api/app">
       RewriteEngine on
       RewriteRule ^$ webroot/ [L]
       RewriteRule (.*) webroot/$1 [L]
       RewriteBase /zm/api
    </Directory>

    <Directory "/usr/share/zoneminder/www/api/app/webroot">
        RewriteEngine On
        RewriteCond %{REQUEST_FILENAME} !-d
        RewriteCond %{REQUEST_FILENAME} !-f
        RewriteRule ^ index.php [L]
        RewriteBase /zm/api
    </Directory>
   # Use the first option to have Apache logs written to the general log
    # directory, or the second to have them written to the regular Apache
    # directory (you may have to change the path to that used on your system)
    ErrorLog /var/log/zm/apache-error.log
    #ErrorLog /var/log/httpd/zm-error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    # Use the first option to have Apache logs written to the general log
    # directory.
    #CustomLog /var/log/zm/apache-access.log combined
    
    # for old install disable direct image access
    <Directory /srv/www/htdocs/zm/events/>
        Require all denied
    </Directory>

</VirtualHost>

I have never dealt with Virtual Hosts and don't kow if I just have to add another virtual host (and how) that would re-enable my /srv/www/htdocs document root without disturbing zm install... Also I don't know, if there were other files added or changed during ZoneMinder install...