richardforth / apache2buddy

apache2buddy
Apache License 2.0
385 stars 72 forks source link

[virtualmin] pid file not found #195

Closed dutch2005 closed 7 years ago

dutch2005 commented 7 years ago

################################################################ apache2buddy.pl report for ksxxxxxxx.kimsufi.com (5.xxx.xxx.xxx) ################################################################ [ OK ] This script is being run as root. [ OK ] The utility 'pmap' exists and is available for use: /usr/bin/pmap [ OK ] The utility 'netstat' exists and is available for use: /bin/netstat [ OK ] 'php' exists and is available for use: /usr/bin/php [ OK ] The utility 'apachectl' exists and is available for use: /usr/sbin/apachectl [ OK ] The port (port 80) is a valid port. [ -- ] We are attempting to discover the operating system type and version number ... [ -- ] Distro: Ubuntu [ -- ] Version: 16.04 [ -- ] Codename: xenial [ @@ ] New OS/Version verification checks are being worked on, you may get errors and teething problems. 02-04-2017 [ @@ ] Apologies for any inconvenience, this message will disappear when all issues resolved. 02-04-2017 [ OK ] This distro is supported by apache2buddy.pl. [ OK ] This distro version is supported by apache2buddy.pl. [ -- ] Hostname: ks3290068.kimsufi.com [ -- ] Primary IP: 5.135.183.145 [ -- ] We are checking the service running on port 80... [ -- ] The process listening on port 80 is /usr/sbin/apache2 [ -- ] The process running on port 80 is Apache/2.4.25 (Ubuntu). [ -- ] Apache has been running 0d 01h 42m 21s. [ !! ] LOW UPTIME . [ @@ ] The following recommendations may be misleading - apache has been restarted within the last 24 hours. [ -- ] The full path to the Apache config file is: /etc/apache2/apache2.conf [ -- ] Apache is using event model. [ -- ] pidfile setting is /var/run/apache2$SUFFIX/apache2.pid. [ !! ] Unable to locate pid file. Exiting.

each process is being run as the /home user

For security reasons they dont have sudo rights

Any ways to circumvent the whole apache2.pid section?

richardforth commented 7 years ago

Easiest way is to use the --no-check-pid option. See --help

On 21 May 2017 23:18, "dutch2005" notifications@github.com wrote:

################################################################ apache2buddy.pl report for ksxxxxxxx.kimsufi.com (5.xxx.xxx.xxx) ################################################################ [ OK ] This script is being run as root. [ OK ] The utility 'pmap' exists and is available for use: /usr/bin/pmap [ OK ] The utility 'netstat' exists and is available for use: /bin/netstat [ OK ] 'php' exists and is available for use: /usr/bin/php [ OK ] The utility 'apachectl' exists and is available for use: /usr/sbin/apachectl [ OK ] The port (port 80) is a valid port. [ -- ] We are attempting to discover the operating system type and version number ... [ -- ] Distro: Ubuntu [ -- ] Version: 16.04 [ -- ] Codename: xenial [ @@ ] New OS/Version verification checks are being worked on, you may get errors and teething problems. 02-04-2017 [ @@ ] Apologies for any inconvenience, this message will disappear when all issues resolved. 02-04-2017 [ OK ] This distro is supported by apache2buddy.pl. [ OK ] This distro version is supported by apache2buddy.pl. [ -- ] Hostname: ks3290068.kimsufi.com [ -- ] Primary IP: 5.135.183.145 [ -- ] We are checking the service running on port 80... [ -- ] The process listening on port 80 is /usr/sbin/apache2 [ -- ] The process running on port 80 is Apache/2.4.25 (Ubuntu). [ -- ] Apache has been running 0d 01h 42m 21s. [ !! ] LOW UPTIME . [ @@ ] The following recommendations may be misleading - apache has been restarted within the last 24 hours. [ -- ] The full path to the Apache config file is: /etc/apache2/apache2.conf [ -- ] Apache is using event model. [ -- ] pidfile setting is /var/run/apache2$SUFFIX/apache2.pid. [ !! ] Unable to locate pid file. Exiting.

each process is being run as the /home user

For security reasons they dont have sudo rights

Any ways to circumvent the whole apache2.pid section?

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/richardforth/apache2buddy/issues/195, or mute the thread https://github.com/notifications/unsubscribe-auth/AFpUV8-daBAxMWw8-CEyiGiGWBbBClooks5r8LhQgaJpZM4Nhvhy .

richardforth commented 7 years ago

sorry i misunderstood the problem

Leaving this open at the moment

richardforth commented 7 years ago

unfortunately that particular section cannot be bypassed I thought you were referring to another section.

This ones a particular pain my my side because there are no standards and the configs are not consistent or explicit so i have to use a lot of guesswork, which is annoying.

richardforth commented 7 years ago

Hi

I wasnt able to replicate this in my lab, can you tell me how you came to install apache on your ubuntu 16:04 server?

Kind Regards Richard

dutch2005 commented 7 years ago

Sure

Install webmin / virtualmin, then run it and you'll have to use the PID thingy to get it resolved.

https://virtualmin.com // http://www.webmin.com/

it stored the file (the PID in/at a non-default section, using the PID flag does fix it as it just doesnt check that thing

richardforth commented 7 years ago

Thanks, I will check it out.

A couple of things to note, everything I do is based off of the stock packages in each distro, by that i mean httpd as provided by yum, in centos 6 /7, and apache2 as provided by apt-get in Ubuntu and Debian.

I dont really support any third party variations eg installed from source or control panels like plesk, cPanel or Webmin/VirtualMin, however some work has gone i to make it work ina few cases, so its a bit hit and miss, I have a limited testing environment as i earn no money from this at all its purely a hobby. So i tend to stick with the mainstream package maintainers' versions of apache.

Ive used webmin before and i know that doesnt install any apache packages, so i suapect its the VirtualMin element. if its Free I will have a little play, if its a subscriber service i will have to do what I did with the cpanel guy and get you to send me some information on where I can find that pid file.

It would have been great if apache just stuck to being explicit about the exact and absolute path to the pidfile, as I could just pull that out of the config and move on with my life, as there seem to be no standards, the code that handles this looks a bit hacky:

https://github.com/richardforth/apache2buddy/blob/master/apache2buddy.pl#L1709

richardforth commented 7 years ago

Interesting,

im just running through the virtualmin installation on a fresh 16.04 cloudserver and it does in fact install the apache2 package but from its OWN repositories:

INFO - Removing Debian standard Webmin package, if they exist...
INFO - Removing Debian apache packages...

INFO - Installing dependencies using command: /usr/bin/apt-get --config-file apt.conf.noninteractive -y --force-yes install bsdutils postfix postfix-pcre webmin usermin ruby libxml-simple-perl libcrypt-ssleay-perl unzip zip libfcgi-dev bind9 spamassassin spamc procmail procmail-wrapper libnet-ssleay-perl libpg-perl libdbd-pg-perl libdbd-mysql-perl quota iptables openssl python mailman subversion ruby irb rdoc ri mysql-server mysql-client mysql-common postgresql postgresql-client awstats webalizer dovecot-common dovecot-imapd dovecot-pop3d proftpd libcrypt-ssleay-perl awstats clamav-base clamav-daemon clamav clamav-freshclam clamav-docs clamav-testfiles libapache2-mod-fcgid apache2-suexec-custom scponly apache2 apache2-doc libapache2-svn libsasl2-2 libsasl2-modules sasl2-bin php-pear php php-cgi libapache2-mod-php php-mysql ntpdate
richardforth commented 7 years ago

This update was brought to you by Haribo Tangfastics.

Haribo please send me free stuff.

thanks

richardforth commented 7 years ago

Hi,

I wasnt able to replicate this, it works for me, see below:

hostname: Name or service not known
############################################
apache2buddy.pl report for  (162.209.88.159)
############################################
[ OK ] This script is being run as root.
[ OK ] The utility 'pmap' exists and is available for use: /usr/bin/pmap
[ OK ] The utility 'netstat' exists and is available for use: /bin/netstat
[ OK ] 'php' exists and is available for use: /usr/bin/php
[ OK ] The utility 'apachectl' exists and is available for use: /usr/sbin/apachectl
[ OK ] The 'python' binary exists and is available for use: /usr/bin/python
[ OK ] The port (port 80) is a valid port.
[ -- ] We are attempting to discover the operating system type and version number ...
[ -- ] Distro: Ubuntu
[ -- ] Version: 16.04
[ -- ] Codename: xenial
[ OK ] This distro is supported by apache2buddy.pl.
[ OK ] This distro version is supported by apache2buddy.pl.
hostname: Name or service not known
[ -- ] Hostname:
[ -- ] Primary IP: 162.209.88.159
[ -- ] We are checking the service running on port 80...
[ -- ] The process listening on port 80 is /usr/sbin/apache2
[ -- ] The process running on port 80 is Apache/2.4.18 (Ubuntu).
[ -- ] The full path to the Apache config file is: /etc/apache2/apache2.conf
[ -- ] Apache is using prefork model.
[ -- ] pidfile setting is /var/run/apache2/apache2$SUFFIX.pid.
[ -- ] Actual pidfile is /var/run/apache2/apache2.pid.
[ -- ] Parent PID: 11250.
[ OK ] Memory usage of parent PID is less than 50MB: 6432 Kilobytes.

...script continues to completion....
richardforth commented 7 years ago

root@web1:~# /usr/sbin/virtualmin info | grep "webmin version" webmin version: 1.850

richardforth commented 7 years ago

Brucey bonus for you:

https://github.com/richardforth/apache2buddy/issues/211

richardforth commented 7 years ago
root@web1:~/apache2buddy# grep "\$SUFFIX" apache2buddy.pl
                        } elsif ($pidfile_cfv eq "/var/run/apache2/apache2\$SUFFIX.pid") {
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX.pid") {
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX/apache2.pid") {

[ -- ] pidfile setting is /var/run/apache2$SUFFIX/apache2.pid. [ !! ] Unable to locate pid file. Exiting.


root@web1:~/apache2buddy# grep -A1 "\$SUFFIX" apache2buddy.pl
                        } elsif ($pidfile_cfv eq "/var/run/apache2/apache2\$SUFFIX.pid") {
                                our $pidfile = "/var/run/apache2/apache2.pid";
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX.pid") {
                                our $pidfile = "/var/run/apache2.pid";
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX/apache2.pid") {
                                our $pidfile = "/var/run/apache2/apache2.pid";

So basically on YOUR machine, our guess at the real location was wrong:

/var/run/apache2/apache2.pid

can you please run this for me and let me know the results:

# updatedb
# locate apache2.pid
richardforth commented 7 years ago

Notes to self re virtualmin installation:

1  wget http://software.virtualmin.com/gpl/scripts/install.sh
2  source install.sh
dutch2005 commented 7 years ago

root@sd-123974:~# updatedb root@sd-123974:~# locate apache2.pid root@sd-123974:~#

Looks like it it cant find the file (apache2 is running)

dutch2005 commented 7 years ago

https://www.virtualmin.com/node/15877

Looks like it has to do with the suffix detection...

dutch2005 commented 7 years ago

/run/apache2/apache2.pid is where I was able to find the file

Update: see screenshot: https://i.imgur.com/heCNATx.jpg

update2: seems a hotlink issue orso.. https://i.imgur.com/j09EgOx.jpg it links to a /var link, but must be something wrong in the linking as the detection to /run does not seem to exist.

richardforth commented 7 years ago

Yes I found that also,

I found that find /var/run/apache2 | grep pid worked for me.

richardforth commented 7 years ago

When you update to a later version of webmin/virtualmin you might find the problem goes away,i will see what i can do to alleviate this though

dutch2005 commented 7 years ago

root@sd-123974:~# find /var/run/apache2 | grep pid /var/run/apache2/apache2.pid root@sd-123974:~#

Working for me aswell 👍

richardforth commented 7 years ago

cool,

i think i will change the final else statement to fall back to find /var/run/apache2 | grep pid

richardforth commented 7 years ago

just standing up another virtualmin server to apply that last change as I had dleeted my cloudservers and was about to shut down and go to bed when you replied, so im back on it.! lol

richardforth commented 7 years ago

Can you please try the following for me:

# curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl - --verbose | grep pid

then run it normally for me:

# curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl

Let me know how it goes

richardforth commented 7 years ago
                        } elsif ($pidfile_cfv eq "/var/run/apache2/apache2\$SUFFIX.pid") {
                                our $pidfile = "/var/run/apache2/apache2.pid";
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX.pid") {
                                our $pidfile = "/var/run/apache2.pid";
                        } elsif ($pidfile_cfv eq "/var/run/apache2\$SUFFIX/apache2.pid") {
                                our $pidfile = "/var/run/apache2/apache2.pid";
                        } else {
                                # revert to a find command as a last ditch effort to find the pid
                                if ($VERBOSE) { print "VERBOSE: Looking for pid file ..." }
                                our $pidguess = `find /var/run/apache2 | grep pid`;
                                chomp($pidguess);
                                if ( -f $pidguess ) {
                                        our $pidfile = $pidguess;
                                        if ($VERBOSE) { print "VERBOSE: Located pidfile at $pidfile." }
                                } else {
                                        show_crit_box; print "${RED}Unable to locate pid file${ENDC}. Exiting.\n";
                                        exit;
                                }
                        }
                }
dutch2005 commented 7 years ago

root@sd-123974:~# curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl - --verbose | grep pid VERBOSE: Searching Apache configuration for the pidfile directive VERBOSE: Using Ubuntu workaround for: pidfile [ -- ] pidfile setting is /var/run/apache2$SUFFIX/apache2.pid. [ -- ] Actual pidfile is /var/run/apache2/apache2.pid.

root@console:~# curl -sL https://raw.githubusercontent.com/richardforth/apache2b uddy/master/apache2buddy.pl | perl ######################################################################### apache2buddy.pl report for czzzzzzzzzzzzzzzzzzzzzz (163.172.xx.yyy) ######################################################################### [ OK ] This script is being run as root. [ OK ] The utility 'pmap' exists and is available for use: /usr/bin/pmap [ OK ] The utility 'netstat' exists and is available for use: /bin/netstat [ OK ] 'php' exists and is available for use: /usr/bin/php [ OK ] The utility 'apachectl' exists and is available for use: /usr/sbin/apache ctl [ OK ] The 'python' binary exists and is available for use: /usr/bin/python [ OK ] The port (port 80) is a valid port. [ -- ] We are attempting to discover the operating system type and version numbe r ... [ -- ] Distro: Ubuntu [ -- ] Version: 16.04 [ -- ] Codename: xenial [ OK ] This distro is supported by apache2buddy.pl. [ OK ] This distro version is supported by apache2buddy.pl. [ -- ] Hostname: zzzzzzzzzzzzzzzzzzzzzzzzzz [ -- ] Primary IP: 163.172xx.yyy [ -- ] We are checking the service running on port 80... [ -- ] The process listening on port 80 is /usr/sbin/apache2 [ -- ] The process running on port 80 is Apache/2.4.26 (Ubuntu). [ -- ] The full path to the Apache config file is: /etc/apache2/apache2.conf [ -- ] Apache is using prefork model. [ -- ] pidfile setting is /var/run/apache2$SUFFIX/apache2.pid. [ -- ] Actual pidfile is /var/run/apache2/apache2.pid. [ -- ] Parent PID: 1608. [ OK ] Memory usage of parent PID is less than 50MB: 10408 Kilobytes. [ -- ] Apache has been running 6d 10h 48m 47s. [ -- ] Your server has 32073 MB of PHYSICAL memory. [ >> ] ServerLimit directive not found, assuming default values. [ -- ] Your ServerLimit setting is 256. [ -- ] Your MaxRequestWorkers setting is 700. [ OK ] Current Apache Process Count is 62, including the parent PID. [ -- ] Number of vhosts detected: 12. [ -- ] |____ of which 5 are HTTP (specifically, port 80). [ -- ] |____ of which 7 are HTTPS (specifically, port 443). [ OK ] Current Apache vHost Count is less than maxrequestworkers. [ >> ] MaxRequestsPerChild directive not found. [ -- ] This server is NOT running Plesk. [ -- ] This server is NOT running cPanel. [ -- ] Virtualmin Version: 5.99.gpl [ -- ] Webmin Version: 1.850 [ -- ] Your PHP Memory Limit (Per-Process) is 128 MB. [ -- ] MySQL Detected => Using 384.89 MB of memory.

[ OK ] No large logs files were found in /var/log/apache2. [ OK ] MaxClients has not been hit recently. [ OK ] No PHP Fatal Errors were found.

richardforth commented 7 years ago

do you still have access to that older machine that had the original issue?

################################################################ apache2buddy.pl report for ksxxxxxxx.kimsufi.com (5.xxx.xxx.xxx) ################################################################

dutch2005 commented 7 years ago

no, but this is a recent re-install same OS, same settings and I had the issue on this one aswell (and other server )

richardforth commented 7 years ago

ok sweet, you happy its all working as expected?

dutch2005 commented 7 years ago

yes, thnx for looking it up :)

richardforth commented 7 years ago

Sorry it took so long to get around to this I had been working on my exams (RHCE 7 coming up soon).

Glad youre happy, have a great weekend!