Posted under » PHP » Ubuntu » Apache on 19 June 2026
After upgrading to upgrading to Ubuntu 26.04 I realised they strongly discourage us from hosting our web files on the home directory.
If PHP doesn't run in home directory, then you should comment out the config (php8.5.conf).
For Apache, it can run in home directory but you can't write. So your temp files and logs will not work.
you need to disable ProtectHome. Edit
systemctl edit apache2.service
You will see
### Editing /etc/systemd/system/apache2.service.d/override.conf ### Anything between here and the comment below will become the contents of the drop-in file ### Edits below this comment will be discarded ### /usr/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=notify # Environment=APACHE_STARTED_BY_SYSTEMD=true # ExecStart=/usr/sbin/apachectl start # ExecStop=/usr/sbin/apachectl graceful-stop # ExecReload=/usr/sbin/apachectl graceful # # Send SIGWINCH for graceful stop # KillSignal=SIGWINCH # KillMode=mixed # PrivateTmp=true # Restart=on-abnormal # OOMPolicy=continue # RemoveIPC=yes # # DevicePolicy=closed # KeyringMode=private # LockPersonality=yes # MemoryDenyWriteExecute=yes # PrivateDevices=yes # ProtectClock=yes # ProtectControlGroups=yes # ProtectHome=read-only # ProtectHostname=yes # ProtectKernelLogs=yes # ProtectKernelModules=yes # ProtectKernelTunables=yes # ProtectSystem=full # RestrictNamespaces=yes # RestrictRealtime=yes # RestrictSUIDSGID=yes # SystemCallArchitectures=native # ProtectProc=invisible # ProcSubset=pid
To key to editting the file is the placement. If you uncomment it, it will fail because the edit is below the coment which will not only be discarded but may lead to apache not able to run again.
Therefore.
### Anything between here and the comment below will become the contents of the drop-in file [Service] ProtectHome=no ### Edits below this comment will be discarded
If you see Successfully installed edited file '/etc/systemd/system/apache2.service.d/override.conf', then you haz success.
If you can't even run apache and got 'Failed to start apache2.service: Unit apache2.service has a bad unit file setting. See system logs and 'systemctl status apache2.service' for details.' then you have to revert to the original config.
systemctl revert apache2