Score:0

Apache server dead

mz flag

I've been struggling around to get my website running with HTTP redirect https and ssl.

Apache 2.4.41 Ubuntu 20.04 LTS

Current data:

iptables -> https://www.toptal.com/developers/hastebin/acufujubuz.sql

It was a bit long so I decided to paste it in a url

UFW ->

Status: active

To                         Action      From
--                         ------      ----
Apache Full                ALLOW       Anywhere
OpenSSH                    ALLOW       Anywhere
Apache Full (v6)           ALLOW       Anywhere (v6)
OpenSSH (v6)               ALLOW       Anywhere (v6)

VS ->

<VirtualHost *:80>
  ServerName <mydomain>
  ServerAlias  www.<mydomain> 

  Redirect permanent / https://<mydomain>/

RewriteEngine on
RewriteCond %{SERVER_NAME} =www.<mydomain> [OR]
RewriteCond %{SERVER_NAME} =<mydomain>
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
</VirtualHost>

<VirtualHost *:443>
  ServerAdmin <mydomain>
  ServerName <mydomain>
  ServerAlias <mydomain>
  DocumentRoot /var/www/<mydomain>
  ErrorLog ${APACHE_LOG_DIR}/error.log
  CustomLog ${APACHE_LOG_DIR}/access.log combined
  Protocols h2 http/1.1

<If "%{HTTP_HOST} == '<mydomain>'"> 
    Redirect permanent / https://<mydomain>/
  </If>

</VirtualHost>

Apache status ->

apache2.service - The Apache HTTP Server
     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabled)
     Active: inactive (dead) since Sun 2021-12-26 13:45:17 CET; 12min ago
       Docs: https://httpd.apache.org/docs/2.4/
    Process: 12093 ExecStart=/usr/sbin/apachectl start (code=exited, status=0/SUCCESS)
    Process: 12177 ExecStop=/usr/sbin/apachectl stop (code=exited, status=0/SUCCESS)
   Main PID: 12097 (code=exited, status=0/SUCCESS)

dec 26 13:45:14 <>.stratoserver.net systemd[1]: Starting The Apache HTTP Server...
dec 26 13:45:14 <>.stratoserver.net systemd[1]: Started The Apache HTTP Server.
dec 26 13:45:17 <>.stratoserver.net apachectl[12179]: httpd (pid 12097?) not running
dec 26 13:45:17 <>.stratoserver.net systemd[1]: apache2.service: Succeeded.

It did however work for one moment, it only showed the default page even though it is disabled. And now it just refuses to run. Some help would be great, any extra info needed let me know.

Error log ->

[Sun Dec 26 13:45:14.394312 2021] [core:warn] [pid 12097:tid 140257795902528] AH00098: pid file /var/run/apache2/apache2.pid overwritten -- Unclean shutdown of previous Apache run?
[Sun Dec 26 13:45:14.395297 2021] [mpm_event:notice] [pid 12097:tid 140257795902528] AH00489: Apache/2.4.41 (Ubuntu) OpenSSL/1.1.1f configured -- resuming normal operations
[Sun Dec 26 13:45:14.395309 2021] [core:notice] [pid 12097:tid 140257795902528] AH00094: Command line: '/usr/sbin/apache2'
[Sun Dec 26 13:45:14.397770 2021] [mpm_event:alert] [pid 12098:tid 140257795902528] (11)Resource temporarily unavailable: AH00480: apr_thread_create: unable to create worker thread
[Sun Dec 26 13:45:14.402620 2021] [mpm_event:alert] [pid 12099:tid 140257477809920] (11)Resource temporarily unavailable: AH03104: apr_thread_create: unable to create worker thread
[Sun Dec 26 13:45:16.396433 2021] [mpm_event:alert] [pid 12097:tid 140257795902528] AH02324: A resource shortage or other unrecoverable failure was encountered before any child process initialized successfully... httpd is exiting!

Ran configtest output -> Syntax OK

Could not find specifically httpd.conf, did however find a http2.conf consisting:


# mod_http2 doesn't work with mpm_prefork
<IfModule !mpm_prefork>
    Protocols h2 h2c http/1.1

    # # HTTP/2 push configuration
    # 
    # H2Push          on
    # 
    # # Default Priority Rule
    # 
    # H2PushPriority * After 16
    # 
    # # More complex ruleset:
    # 
    # H2PushPriority  *                       after
    # H2PushPriority  text/css                before
    # H2PushPriority  image/jpeg              after   32
    # H2PushPriority  image/png               after   32
    # H2PushPriority  application/javascript  interleaved
    # 
    # # Configure some stylesheet and script to be pushed by the webserver
    # 
    # <FilesMatch "\.html$">
    #     Header add Link "</style.css>; rel=preload; as=style"
    #     Header add Link "</script.js>; rel=preload; as=script"
    # </FilesMatch>
    # Since mod_http2 doesn't support the mod_logio module (which provide the %O format),
    # you may want to change your LogFormat directive as follow:
    #
    # LogFormat "%v:%p %h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" vhost_combined
    # LogFormat "%h %l %u %t \"%r\" %>s %B \"%{Referer}i\" \"%{User-Agent}i\"" combined
    # LogFormat "%h %l %u %t \"%r\" %>s %B" common
</IfModule>

And found this part in apache2.conf

# Sets the default security model of the Apache2 HTTPD server. It does
# not allow access to the root filesystem outside of /usr/share and /var/www.
# The former is used by web applications packaged in Debian,
# the latter may be used for local directories served by the web server. If
# your system is serving content from a sub-directory in /srv you must allow
# access here, or in any related virtual host.
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Require all denied
</Directory>

<Directory /usr/share>
    AllowOverride None
    Require all granted
</Directory>

<Directory /var/www/>
    Options Indexes FollowSymLinks
    AllowOverride None
    Require all granted
</Directory>

#<Directory /srv/>
#   Options Indexes FollowSymLinks
#   AllowOverride None
#   Require all granted
#</Directory>`

Also memory;

$ free  -m
              total        used        free      shared  buff/cache   available
Mem:           4096          95        3701           3         298        3997
Swap:             0           0           0
djdomi avatar
za flag
look at the error.log which is for debian/Ubuntu in /var/log/apache* moreover `apachectl configtest` should show an error usually
iAlusion avatar
mz flag
https://www.toptal.com/developers/hastebin/folonedone.yaml It errors a lot about a worker thread
iAlusion avatar
mz flag
oh the link is the full file pasted on what used to be just hastebin
iAlusion avatar
mz flag
added it in the edit ^
djdomi avatar
za flag
dont use external services, use the corresponding formating command on serverfault.com and paste the text file, strip duplicated errors, please do the same for the above (so schwer kann das ja nicht sein)
iAlusion avatar
mz flag
I dont know which part of the iptables to put in there its 180 lines long
djdomi avatar
za flag
AH02324 is your main issue, show us the output of `apachectl configtest` and the httpd conf part `<IfModule mpm_event_module>` moreover how mayn resources are available? meaning cpu&ram. Shortly said, you run out of resources
iAlusion avatar
mz flag
I have added all the things to my best, and it does not seem my vps would be short on memory
djdomi avatar
za flag
i believe that you trying to use mpm_event_module while it tries to spawn more processes as you might allowed by the vm
ca flag
check your RAM , CPU and free diskspace usage. your machine is probably not powerfull enough for what you re doing, you probably need more RAM od free diskspace, give the result of df - h and free -h , done at the same time you try to use your webserver and get this error.
Score:0
mz flag

Editing the tasks done fix this whole for me.

systemctl set-property apache2.service TasksMax=infinity
djdomi avatar
za flag
and what should solve this? maybe this might be the issue that he is not allowed to spawn infinite processes? was that's meant to as a comment?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.