How fix php.config Apache2?

Hi all, can you kindly help me to solve this problem? Thank you.

sudo apt-get purge apache2
sudo apt-get autoremove
sudo apt-get install apache2
make a new virtual host
install php module php7.4
systemctl status apache2 (is running)

Hi @systemadmin

To be able to help here it would be useful to see your actual Apache / VirtualHost Config. It would also be interesting to know which OS you are using and if all required PHP modules are installed… Did you use a specific guide to install Nextcloud?

Here are the relevant links to the official documentation:

https://docs.nextcloud.com/server/latest/admin_manual/installation/source_installation.html

https://docs.nextcloud.com/server/latest/admin_manual/installation/example_ubuntu.html

https://docs.nextcloud.com/server/latest/admin_manual/installation/example_centos.html

Side note:
I see Webmin in your screenshot, which creates its own config files for many things… I’m not a big fan of that, to be honest. But as I said, that’s just a side note :wink:

Hi @bb77, thanks for the reply

20.04.1-Ubuntu
PHP 7.4.3
Server version: Apache/2.4.41 (Ubuntu)
https://download.nextcloud.com/server/releases/nextcloud-21.0.2.zip
https://www.mlazzarotto.it/installare-nextcloud-20-su-ubuntu

Thanks for the advice on webmin

Cattura

Hmm… apart from my poor italian language skills, i have not noticed any problems with the linked instructions. :wink: Everything looks fine to me… Did you do everything exactly the same way as in the instructions?

All PHP modules installed?

apt install apache2 php7.4 php7.4-fpm php7.4-mysql php7.4-zip php7.4-curl php7.4-apcu php-dompdf php7.4-xml php7.4-mbstring php7.4-intl php-imagick php7.4-bcmath php7.4-gmp libapache2-mod-php7.4 mariadb-server unzip`

All Apache modules enabled?

a2enmod rewrite headers env dir mime ssl`

Permissions set correctly?

chown -R www-data:www-data /var/www/nextcloud

Other than that, I can’t think of anything else right now…

Hi, yes I had already checked everything you listed for me.

Could this possibly be the problem?

Is there a mod_php7? The way that is set up is to detect whether or not mod_php is installed and IF NOT, try to use PHP-FPM.

PHP-FPM is generally the preferred way to run php these days, so why not set it up that way?

*Hi @Larry_Boyd, *
What could I do?

Could you please copy/paste text instead of the pictures?

Your question is not clear, nor have you explained the purpose of your picture.
If you are implying that it is still not working after installing php-fpm, then HAVE YOU STARTED IT? php-fpm runs in its own process and needs to be started separately from apache.

@Larry_Boyd the problem was not solved

; Start a new pool named ‘www’.
; the variable $pool can be used in any directive and will be replaced by the
; pool name (‘www’ here)
[www]

; Per pool prefix
; It only applies on the following directives:
; - ‘access.log’
; - ‘slowlog’
; - ‘listen’ (unixsocket)
; - ‘chroot’
; - ‘chdir’
; - ‘php_values’
; - ‘php_admin_values’
; When not set, the global prefix (or /usr) applies instead.
; Note: This directive can also be relative to the global prefix.
; Default Value: none
;prefix = /path/to/pools/$pool

; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user’s group
; will be used.
user = www-data
group = www-data

; The address on which to accept FastCGI requests.
; Valid syntaxes are:
; ‘ip.add.re.ss:port’ - to listen on a TCP socket to a specific IPv4 address on
; a specific port;
; ‘[ip:6:addr:ess]:port’ - to listen on a TCP socket to a specific IPv6 address on
; a specific port;
; ‘port’ - to listen on a TCP socket to all addresses
; (IPv6 and IPv4-mapped) on a specific port;
; ‘/path/to/unix/socket’ - to listen on a unix socket.
; Note: This value is mandatory.
listen = /run/php/php7.4-fpm.sock

; Set listen(2) backlog.
; Default Value: 511 (-1 on FreeBSD and OpenBSD)
;listen.backlog = 511

; Set permissions for unix socket, if one is used. In Linux, read/write

php7.4-fpm.service - The PHP 7.4 FastCGI Process Manager
Loaded: loaded (/lib/systemd/system/php7.4-fpm.service; enabled; vendor preset: enabled)
Active: active (running) since Fri 2021-06-18 19:39:13 CEST; 11min ago
Docs: man:php-fpm7.4(8)
Process: 150220 ExecStartPost=/usr/lib/php/php-fpm-socket-helper install /run/php/php-fpm.sock /etc/php/7.4/fpm/pool.d/www.conf 74 (code=exi>
Main PID: 150217 (php-fpm7.4)
Status: “Processes active: 0, idle: 2, Requests: 0, slow: 0, Traffic: 0req/sec”
Tasks: 3 (limit: 38261)
Memory: 7.4M
CGroup: /system.slice/php7.4-fpm.service
├─150217 php-fpm: master process (/etc/php/7.4/fpm/php-fpm.conf)
├─150218 php-fpm: pool www
└─150219 php-fpm: pool www

So what is the problem now? Its still doing like in your first post and loading the content of the script instead of running the script?

@Larry_Boyd Exactly!

Read through this and make sure that all steps have been addressed;

@Larry_Boyd Ok, thank you very much!

@Larry_Boyd I have followed all the steps, but unfortunately the problem persists.

This all happened because apache2 crashed and I uninstalled it

I also uninstalled and reinstalled php

Do you think I would do first to reinstall the whole LAMP stack plus Nextcloud?

Well first of all, Nextcloud isn’t really “installed”. Its just copied in to a directory where its scripts can be run from.

I don’t actually use ubuntu myself, so I can’t really guess what it will do by forcing an uninstall/reinstall. If you’ve mucked with the config files, they may persist through a reinstall. You really need to check all your logs and see what is actually happening.

I solve a similar problem after uninstall and purge php.

# Stop service
sudo service apache2 stop
# Remove apache2 packages and dependencies:
sudo apt-get remove apache2;sudo apt-get autoremove --purge -y
# sudo apt-get purge apache2 apache2-utils apache2.2-bin apache2-common
# sudo apt-get autoremove --purge
# If you manually modified or installed stuff, apt might not remove it. Check what's left:
whereis apache2
# Use the answer to  remove the directories
sudo rm -Rf /etc/apache2 /usr/lib/apache2 /usr/include/apache2
sudo rm -Rf /usr/sbin/apache2 /usr/lib/apache2 /etc/apache2 /usr/share/apache2 /usr/share/man/man8/apache2.8.gz