Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs
@ 2026-07-01 23:04 Fiona Klute via buildroot
  2026-07-01 23:04 ` [Buildroot] [PATCH 2/2] support/testing: TestApache: use read-only rootfs image Fiona Klute via buildroot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Fiona Klute via buildroot @ 2026-07-01 23:04 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Bernd Kuhls, Hervé Codina, Fiona Klute

The previous configuration placed both logs and PID file in /var/logs,
which is not writable with a read-only rootfs (e.g. squashfs), as well
as non-standard. Starting HTTPD during boot failed with:

(30)Read-only file system: AH00091: httpd: could not open error log file /var/logs/error_log.
AH00015: Unable to open logs

An additional issue was that the Buildroot-default --prefix=/usr
override meant various Apache-internal directories (e.g. htdocs) were
placed directly in /usr. Note that the upstream default prefix is
/usr/local/apache2, not /usr/local.

Using the "Debian" layout provides a standard-compatible layout with
logs in /var/log/apache2 and PID file in /var/run/apache2 (both in
tmpfs with the default Buildroot fstab). Both directories need to
exist when the server starts, so handle that in the init script.

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
---
The "right" filesystem layout is certainly debatable, but I think that
HTTPD should work with a read-only rootfs is not. Apply patch 2
without this one and run the test to see the problem in action.

The "layout" values are defined in config.layout in the package source
(or see
https://svn.apache.org/repos/asf/httpd/httpd/trunk/config.layout),
patching it to add a Buildroot one would also be an
option. Unfortunately I don't see a way to override the directories
for logs and PID file independently on the ./configure command line.

I'm also CCing the people listed in DEVELOPERS for
package/modsecurity2 because changes to package/apache naturally
affect any modules, I've tested it still compiles.

 package/apache/S50apache      |  2 ++
 package/apache/apache.mk      | 13 ++++++++-----
 package/apache/apache.service |  1 +
 3 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/package/apache/S50apache b/package/apache/S50apache
index 71e8837bae..fd1c58312f 100644
--- a/package/apache/S50apache
+++ b/package/apache/S50apache
@@ -2,6 +2,8 @@
 # shellcheck disable=SC2034 # checkpackage-required variable
 DAEMON="apache"
 
+mkdir -p "/var/log/apache2" "/var/run/apache2"
+
 case "$1" in
 	start|restart|graceful|graceful-stop|stop)
 		apachectl -k "$1"
diff --git a/package/apache/apache.mk b/package/apache/apache.mk
index 2466bc9461..debc999bcd 100644
--- a/package/apache/apache.mk
+++ b/package/apache/apache.mk
@@ -43,7 +43,9 @@ APACHE_CONF_OPTS = \
 	--without-suexec-bin \
 	--enable-mods-shared=all \
 	--with-mpm=$(APACHE_MPM) \
-	--disable-luajit
+	--disable-luajit \
+	--enable-layout=Debian \
+	--prefix=/
 
 ifeq ($(BR2_PACKAGE_BROTLI),y)
 APACHE_CONF_OPTS += --enable-brotli
@@ -111,14 +113,15 @@ endif
 
 define APACHE_FIX_STAGING_APACHE_CONFIG
 	$(SED) 's%"/usr/bin"%"$(STAGING_DIR)/usr/bin"%' $(STAGING_DIR)/usr/bin/apxs
-	$(SED) 's%/usr/build%$(STAGING_DIR)/usr/build%' $(STAGING_DIR)/usr/bin/apxs
-	$(SED) 's%^prefix =.*%prefix = $(STAGING_DIR)/usr%' $(STAGING_DIR)/usr/build/config_vars.mk
-	$(SED) 's%^sbindir =.*%sbindir = $(STAGING_DIR)/usr/bin%' $(STAGING_DIR)/usr/build/config_vars.mk
+	$(SED) 's%/usr/share/apache2/build%$(STAGING_DIR)/usr/share/apache2/build%' $(STAGING_DIR)/usr/bin/apxs
+	$(SED) 's%^prefix =.*%prefix = $(STAGING_DIR)/%' $(STAGING_DIR)/usr/share/apache2/build/config_vars.mk
+	$(SED) 's%^sbindir =.*%sbindir = $(STAGING_DIR)/usr/sbin%' $(STAGING_DIR)/usr/share/apache2/build/config_vars.mk
+	$(SED) 's%^includedir = .*%includedir = $(STAGING_DIR)/usr/include/apache2%' $(STAGING_DIR)/usr/share/apache2/build/config_vars.mk
 endef
 APACHE_POST_INSTALL_STAGING_HOOKS += APACHE_FIX_STAGING_APACHE_CONFIG
 
 define APACHE_CLEANUP_TARGET
-	$(RM) -rf $(TARGET_DIR)/usr/manual $(TARGET_DIR)/usr/build
+	$(RM) -rf $(TARGET_DIR)/usr/share/apache2/default-site/htdocs/manual $(TARGET_DIR)/usr/share/apache2/build
 endef
 APACHE_POST_INSTALL_TARGET_HOOKS += APACHE_CLEANUP_TARGET
 
diff --git a/package/apache/apache.service b/package/apache/apache.service
index b8747e2658..561e4e2851 100644
--- a/package/apache/apache.service
+++ b/package/apache/apache.service
@@ -4,6 +4,7 @@ After=network.target
 
 [Service]
 Type=forking
+ExecStartPre=/bin/mkdir -p /var/log/apache2 /var/run/apache2
 ExecStart=/usr/bin/apachectl start
 ExecReload=/usr/bin/apachectl graceful
 ExecStop=/usr/bin/apachectl stop
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Buildroot] [PATCH 2/2] support/testing: TestApache: use read-only rootfs image
  2026-07-01 23:04 [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Fiona Klute via buildroot
@ 2026-07-01 23:04 ` Fiona Klute via buildroot
  2026-08-16 15:04 ` [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Thomas Petazzoni via buildroot
  2026-08-22 12:41 ` Titouan Christophe via buildroot
  2 siblings, 0 replies; 4+ messages in thread
From: Fiona Klute via buildroot @ 2026-07-01 23:04 UTC (permalink / raw)
  To: buildroot; +Cc: Julien Olivain, Bernd Kuhls, Hervé Codina, Fiona Klute

With this the test verifies not only that Apache can work in
principle, but also that it works with a read-only rootfs. Because of
the read-only rootfs the test itself cannot write to /root, so store
the test download in /tmp.

Signed-off-by: Fiona Klute <fiona.klute@gmx.de>
---
 support/testing/tests/package/test_apache.py | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/support/testing/tests/package/test_apache.py b/support/testing/tests/package/test_apache.py
index f29f4e2524..d44e7927bd 100644
--- a/support/testing/tests/package/test_apache.py
+++ b/support/testing/tests/package/test_apache.py
@@ -1,5 +1,6 @@
 import os
 
+import infra
 import infra.basetest
 
 
@@ -7,17 +8,22 @@ class TestApache(infra.basetest.BRTest):
     config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \
         """
         BR2_PACKAGE_APACHE=y
-        BR2_TARGET_ROOTFS_CPIO=y
+        BR2_TARGET_ROOTFS_SQUASHFS=y
+        BR2_TARGET_ROOTFS_SQUASHFS4_LZO=y
         # BR2_TARGET_ROOTFS_TAR is not set
         """
 
     def test_run(self):
-        cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio")
-        self.emulator.boot(arch="armv5",
+        rootfs = os.path.join(self.builddir, "images", "rootfs.squashfs")
+        infra.img_round_power2(rootfs)
+        self.emulator.boot(arch="armv7",
                            kernel="builtin",
-                           options=["-initrd", cpio_file])
+                           kernel_cmdline=["root=/dev/mmcblk0",
+                                           "rootfstype=squashfs"],
+                           options=["-drive",
+                                    "file={},if=sd,format=raw".format(rootfs)])
         self.emulator.login()
 
         self.assertRunOk("httpd -V")
-        self.assertRunOk("wget http://localhost/index.html")
-        self.assertRunOk("grep -F 'It works!' index.html")
+        self.assertRunOk("wget -O /tmp/index.html http://localhost/index.html")
+        self.assertRunOk("grep -F 'It works!' /tmp/index.html")
-- 
2.53.0

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs
  2026-07-01 23:04 [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Fiona Klute via buildroot
  2026-07-01 23:04 ` [Buildroot] [PATCH 2/2] support/testing: TestApache: use read-only rootfs image Fiona Klute via buildroot
@ 2026-08-16 15:04 ` Thomas Petazzoni via buildroot
  2026-08-22 12:41 ` Titouan Christophe via buildroot
  2 siblings, 0 replies; 4+ messages in thread
From: Thomas Petazzoni via buildroot @ 2026-08-16 15:04 UTC (permalink / raw)
  To: Fiona Klute; +Cc: buildroot, Julien Olivain, Bernd Kuhls, Hervé Codina

On Thu, Jul 02, 2026 at 01:04:08AM +0200, Fiona Klute via buildroot wrote:
> The previous configuration placed both logs and PID file in /var/logs,
> which is not writable with a read-only rootfs (e.g. squashfs), as well
> as non-standard. Starting HTTPD during boot failed with:
> 
> (30)Read-only file system: AH00091: httpd: could not open error log file /var/logs/error_log.
> AH00015: Unable to open logs
> 
> An additional issue was that the Buildroot-default --prefix=/usr
> override meant various Apache-internal directories (e.g. htdocs) were
> placed directly in /usr. Note that the upstream default prefix is
> /usr/local/apache2, not /usr/local.
> 
> Using the "Debian" layout provides a standard-compatible layout with
> logs in /var/log/apache2 and PID file in /var/run/apache2 (both in
> tmpfs with the default Buildroot fstab). Both directories need to
> exist when the server starts, so handle that in the init script.
> 
> Signed-off-by: Fiona Klute <fiona.klute@gmx.de>

Thanks, series applied!

Thomas
-- 
Thomas Petazzoni, co-owner and CEO, Bootlin
Embedded Linux and Kernel engineering and training
https://bootlin.com
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs
  2026-07-01 23:04 [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Fiona Klute via buildroot
  2026-07-01 23:04 ` [Buildroot] [PATCH 2/2] support/testing: TestApache: use read-only rootfs image Fiona Klute via buildroot
  2026-08-16 15:04 ` [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Thomas Petazzoni via buildroot
@ 2026-08-22 12:41 ` Titouan Christophe via buildroot
  2 siblings, 0 replies; 4+ messages in thread
From: Titouan Christophe via buildroot @ 2026-08-22 12:41 UTC (permalink / raw)
  To: Fiona Klute, buildroot; +Cc: Julien Olivain, Bernd Kuhls, Hervé Codina

On 2/07/26 01:04, Fiona Klute via buildroot wrote:
> The previous configuration placed both logs and PID file in /var/logs,
> which is not writable with a read-only rootfs (e.g. squashfs), as well
> as non-standard. Starting HTTPD during boot failed with:
>
> (30)Read-only file system: AH00091: httpd: could not open error log file /var/logs/error_log.
> AH00015: Unable to open logs
>
> An additional issue was that the Buildroot-default --prefix=/usr
> override meant various Apache-internal directories (e.g. htdocs) were
> placed directly in /usr. Note that the upstream default prefix is
> /usr/local/apache2, not /usr/local.
>
> Using the "Debian" layout provides a standard-compatible layout with
> logs in /var/log/apache2 and PID file in /var/run/apache2 (both in
> tmpfs with the default Buildroot fstab). Both directories need to
> exist when the server starts, so handle that in the init script.
>
> Signed-off-by: Fiona Klute <fiona.klute@gmx.de>

Series applied to 2025.02.x and 2026.05.x, thanks !

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-08-22 12:41 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-01 23:04 [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Fiona Klute via buildroot
2026-07-01 23:04 ` [Buildroot] [PATCH 2/2] support/testing: TestApache: use read-only rootfs image Fiona Klute via buildroot
2026-08-16 15:04 ` [Buildroot] [PATCH 1/2] package/apache: use "Debian" filesystem layout to fix read-only rootfs Thomas Petazzoni via buildroot
2026-08-22 12:41 ` Titouan Christophe via buildroot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox