Need help with apache server after messing up

Heyho folks,

I am need for a little help regarding Apache. I had an successful running nextcloud instance for a while. Few days ago stupid me decided to install pihole on the same server where nextcloud is running. That was a stupid mistake. After getting rid of pihole my nextcloud wasn’t available anymore. After some time I figured out Apache wasn’t configured correctly anymore. After messing around with active sites and active configs I got it to the point that a .php was displayed in plain text.

My nextcloud.conf

VirtualHost *:80>
 ServerAdmin master@localhost.com
 DocumentRoot /var/www/nextcloud/
 ServerName mydomain
 ServerAlias www.mydomain

 Alias /nextcloud "/var/www/nextcloud/"

 <Directory /var/www/nextcloud/>
    Options +FollowSymlinks
    AllowOverride All
    Require all granted
      <IfModule mod_dav.c>
        Dav off
      </IfModule>
    SetEnv HOME /var/www/nextcloud
    SetEnv HTTP_HOME /var/www/nextcloud
 </Directory>

 ErrorLog ${APACHE_LOG_DIR}/error.log
 CustomLog ${APACHE_LOG_DIR}/access.log combined
 RewriteEngine on
 RewriteCond %{SERVER_NAME} =www.mydomain [OR]
 RewriteCond %{SERVER_NAME} =mydomain
 RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]
 </VirtualHost>

My nextcloud-ssl.conf

VirtualHost *:443>
    ServerAdmin webmaster@localhost
    DocumentRoot /var/www/nextcloud
    SSLEngine on
    SSLCertificateFile /etc/apache2/myssl/server.cert.crt
    SSLCertificateKeyFile /etc/apache2/myssl/server.cert.key
 </VirtualHost>

The .php that is being displayed

I am a bit on a dry path here where I dont know what to do expect wiping the machine and starting from scratch. Any help appreciated. If further information is needed let me know.
Big thanks in advance!

Hi @lothar, maybe some modules of PHP are missing or broken maybe you should reinstall them.
your nextcloud-le-ssl.conf is good for the https access.

here is my nextcloud-le-ssl.conf ( i'm using certbot for this)
<IfModule mod_ssl.c>
<VirtualHost *:443>

DocumentRoot /var/www/nextcloud/
ServerName domain.com


<Directory /var/www/nextcloud/>
        Options +FollowSymlinks
        AllowOverride All
        Require all granted
          <IfModule mod_dav.c>
            Dav off
          </IfModule>
        SetEnv HOME /var/www/nextcloud
        SetEnv HTTP_HOME /var/www/nextcloud
     </Directory>

     ErrorLog ${APACHE_LOG_DIR}/error.log
     CustomLog ${APACHE_LOG_DIR}/access.log combined

Header always set Strict-Transport-Security "max-age=15552000; includeSubDomains"


SSLCertificateFile /etc/letsencrypt/live/domain.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/domain.com/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Could it be that Lighttpd is runnung instead of Apache?
PiHole install’s Lighttpd by default. I am running Apache, Nextcloud and PiHole on the same machine too.
Have a look at: /etc/pihole/SetupVars.conf
and see if LIGHTPD_enabled=false
Then remove Lighttpd.
That is a start.
Is apache2 running? I assume that you use RaspberryOs. So check:
sudo systemctl status apache2

@Bartman2
Yes. You are right. Lighttpd came with PiHole and was running on port 80 same as apache. But I got rid of lighttdp and pihole. After that I am now stuck in the situation mentioned above. Apache2 is running.

@Mageunic
I could try this. Do you have a hint how to reinstall all php modules on ubuntu server?

@lothar try this : sudo apt reinstall php libapache2-mod-php php-gd php-json php-mysql php-curl php-mbstring php-intl php-imagick php-xml php-zip php-mysql php-bcmath php-gmp php-apcu ( delete modules you not use and add the others wich are not in the line)

@Mageunic
Hm, reinstalling was succesful. But the php is still being displayed in plain text. Any further ideas? seems like I have to nuke the machine.

@lothar I don’t know … I’m trying to search for other solutions…