我一直在努力使我的网站运行 HTTP 重定向 https 和 ssl。
Apache 2.4.41 Ubuntu 20.04 LTS
当前数据:
iptables->https://www.toptal.com/developers/hastebin/acufujubuz.sql
它有点长,所以我决定将其粘贴在网址中
UFW ->
Status: active
To Action From
-- ------ ----
Apache Full ALLOW Anywhere
OpenSSH ALLOW Anywhere
Apache Full (v6) ALLOW Anywhere (v6)
OpenSSH (v6) ALLOW Anywhere (v6)
与 ->
<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 状态 ->
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.
不过,它确实工作了一段时间,尽管它已被禁用,但它只显示默认页面。现在它就是拒绝运行。有人能帮忙就太好了,如果需要任何额外的信息请告诉我。
错误日志 ->
[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!
运行配置测试输出 ->语法正确
无法找到特定的 httpd.conf,但是找到了包含以下内容的 http2.conf:
# 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>
并在 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>`
还有记忆;
$ free -m
total used free shared buff/cache available
Mem: 4096 95 3701 3 298 3997
Swap: 0 0 0
答案1
编辑已完成的任务可以为我解决整个问题。
systemctl set-property apache2.service TasksMax=infinity