Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3886

Troubleshooting • Re: failed to start service apache 2 with log in RAM

$
0
0
Hello, finally after looking at how other services work, in particular pihole, I thought it would be simpler to do as they did.
Here's what I did to solve the problem:

so I created the following file :

Code:

pi@e-pi3:~ $ cat /usr/bin/apache2ram-prestart.sh #!/usr/bin/env sh[ -d /var/log/apache2 ] || mkdir /var/log/apache2chown root:adm /var/log/apache2pi@e-pi3:~ $
then I made it executable of course :

Code:

sudo chmod +x /usr/bin/apache2ram-prestart.sh
then I edited the apache service as follows with this command :

Code:

sudo systemctl edit apache2.service
by inserting this:

Code:

### Lines below this comment will be discarded### /lib/systemd/system/apache2.service# [Unit]# Description=The Apache HTTP Server# After=network.target remote-fs.target nss-lookup.target# Documentation=https://httpd.apache.org/docs/2.4/# # [Service]# Type=forking# Environment=APACHE_STARTED_BY_SYSTEMD=true# ExecStart=/usr/sbin/apachectl start# ExecStop=/usr/sbin/apachectl graceful-stop# ExecReload=/usr/sbin/apachectl graceful# KillMode=mixed# PrivateTmp=true# Restart=on-abort# # [Install]# WantedBy=multi-user.target



After a restart, everything is perfect:

Code:

pi@e-pi3:~ $ df -TH | grep logtmpfs            tmpfs      105M    500k  105M   1% /var/logpi@e-pi3:~ $

Code:

pi@e-pi3:~ $ sudo systemctl status apache2.service● apache2.service - The Apache HTTP Server     Loaded: loaded (/lib/systemd/system/apache2.service; enabled; vendor preset: enabl>    Drop-In: /etc/systemd/system/apache2.service.d             └─override.conf     Active: active (running) since Sun 2024-06-16 10:45:35 CEST; 8min ago       Docs: https://httpd.apache.org/docs/2.4/   Main PID: 703 (apache2)      Tasks: 9 (limit: 2086)        CPU: 2.485s     CGroup: /system.slice/apache2.service             ├─ 703 /usr/sbin/apache2 -k start             ├─ 745 /usr/sbin/apache2 -k start             ├─ 746 /usr/sbin/apache2 -k start             ├─ 747 /usr/sbin/apache2 -k start             ├─ 748 /usr/sbin/apache2 -k start             ├─ 749 /usr/sbin/apache2 -k start             ├─ 984 /usr/sbin/apache2 -k start             ├─1001 /usr/sbin/apache2 -k start             └─1239 /usr/sbin/apache2 -k start

Except for :

Code:

pi@e-pi3:~ $ systemctl list-units --type=service | grep failed● rc-local.service                                            loaded failed failed  /etc/rc.local Compatibilitypi@e-pi3:~ $
Any idea on how to solve this ?

Statistics: Posted by iznobe — Sun Jun 16, 2024 9:08 am



Viewing all articles
Browse latest Browse all 3886

Trending Articles