Website shows Source Code after Letsencrypt install

My domain is: belania.net

I ran this commands:

  • apt install certbot python3-certbot-apache -y
  • certbot --authenticator webroot --installer apache -w /var/www/html -d belania.net -d www.belania.net

It produced this output:

Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer apache
Enter email address (used for urgent renewal and security notices) (Enter 'c' to
cancel): support@belania.net

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Please read the Terms of Service at
https://letsencrypt.org/documents/LE-SA-v1.2-November-15-2017.pdf. You must
agree in order to register with the ACME server at
https://acme-v02.api.letsencrypt.org/directory
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(A)gree/(C)ancel: A

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Would you be willing to share your email address with the Electronic Frontier
Foundation, a founding partner of the Let's Encrypt project and the non-profit
organization that develops Certbot? We'd like to send you email about our work
encrypting the web, EFF news, campaigns, and ways to support digital freedom.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
(Y)es/(N)o: n
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for belania.net
http-01 challenge for www.belania.net
Using the webroot path /var/www/html for all unmatched domains.
Waiting for verification...
Cleaning up challenges
Created an SSL vhost at /etc/apache2/sites-available/000-default-le-ssl.conf
Enabled Apache socache_shmcb module
Enabled Apache ssl module
Deploying Certificate to VirtualHost /etc/apache2/sites-available/000-default-le-ssl.conf
Enabling available site: /etc/apache2/sites-available/000-default-le-ssl.conf

We were unable to find a vhost with a ServerName or Address of www.belania.net.
Which virtual host would you like to choose?
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: 000-default.conf               |                       |       | Enabled
2: 000-default-le-ssl.conf        | belania.net           | HTTPS | Enabled
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Deploying Certificate to VirtualHost /etc/apache2/sites-available/000-default-le-ssl.conf

Please choose whether or not to redirect HTTP traffic to HTTPS, removing HTTP access.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Select the appropriate number [1-2] then [enter] (press 'c' to cancel): 2
Enabled Apache rewrite module
Redirecting vhost in /etc/apache2/sites-enabled/000-default.conf to ssl vhost in /etc/apache2/sites-available/000-default-le-ss        l.conf

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Congratulations! You have successfully enabled https://belania.net and
https://www.belania.net

You should test your configuration at:
https://www.ssllabs.com/ssltest/analyze.html?d=belania.net
https://www.ssllabs.com/ssltest/analyze.html?d=www.belania.net
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -

My web server is (include version): Apache2

The operating system my web server runs on is (include version): Debian 11

My hosting provider, if applicable, is: Strato.de

I can login to a root shell on my machine (yes or no, or I don't know): yes

I'm using a control panel to manage my site (no, or provide the name and version of the control panel): no

The version of my client is (e.g. output of certbot --version or certbot-auto --version if you're using Certbot): certbot 0.31.0

My Problem is: The website on https://belania.net is not loading, but just showing its source code... Any help would be nice.

Greetings

I see your website just fine on both domain names. Can you give an example of a page that isn't behaving the way you expect?

2 Likes


This is what it looks like for me...

Looks like a server configuration problem. You don't set a content-type in the http headers so a browser is left to guess. Your "html" page starts with php tags. You may not have Apache setup to handle php properly. You may not have your index page set correctly.

None of these are related to Let's Encrypt or https. You would be better served on forums that help with basic server configuration.

Could even search google for apache why do I see php source

Best of luck

4 Likes

It might be slightly related to Certbot: if Certbot used an incorrect VirtualHost as template for the ~-le-ssl.conf, some required directives could have been "overlooked" and didn't make the new VirtualHost.

This usually is due to incorrect Apache configurations with multiple VirtualHost looking almost exactly the same (i.e., same ServerName directives et cetera).

OP should provide all the Apache configuration files so we can take a look.

5 Likes

Hmm, OK.

@Belania.net Was your site working with HTTP before trying Certbot?

Also, if you want us to look further can you show the result of below command?

apachectl -S
3 Likes

Hey, sorry for the late answer.

My Website worked just perfectly before I installed certbot.

When i excecute

  • apachectl -S

I receive:

VirtualHost configuration:
*:443                  belania.net (/etc/apache2/sites-enabled/000-default-le-ssl.conf:2)
*:80                   h2966281.stratoserver.net (/etc/apache2/sites-enabled/000-default.conf:1)
ServerRoot: "/etc/apache2"
Main DocumentRoot: "/var/www/html"
Main ErrorLog: "/var/log/apache2/error.log"
Mutex watchdog-callback: using_defaults
Mutex rewrite-map: using_defaults
Mutex ssl-stapling-refresh: using_defaults
Mutex ssl-stapling: using_defaults
Mutex ssl-cache: using_defaults
Mutex default: dir="/var/run/apache2/" mechanism=default
PidFile: "/var/run/apache2/apache2.pid"
Define: DUMP_VHOSTS
Define: DUMP_RUN_CFG
User: name="www-data" id=33
Group: name="www-data" id=33

My Configs can be found on Pastebin:

Greetings

1 Like

I don't really see anything weird in those configuration files.

You should be able to revert to your previous Apache configuration with the following command:

certbot rollback --apache

And check if PHP is enabled again on your HTTP site.

4 Likes

Yeah, I don't either. Certbot behaved properly and I don't see how it could affect php:

  1. It setup the new https (port 443) VirtualHost with the same options from the port 80 VirtualHost just adding ServerName, ServerAlias, and the SSL config.
  2. It added https redirects to the port 80 virtual host

@Belania.net You can try the rollback. Or, if you are experienced, you could comment out the redirects in 000-default.conf, restart Apache and see if http://belania.net works. Once you resolve the php issue with http:// you can un-comment the redirects, restart apache and all should be fine with https://

2 Likes

I don't see belania.net:80

1 Like

No, but, there is only one port 80 VirtualHost so would catch any name. Not an ideal config to start with but I am convinced the problem with php was not certbot related.

The port 443 VirtualHost had explicit names (from certbot).

In fact, right now requests to http://belania.net still return the php source and https:// requests fail so looks like they tried the rollback and still have php problem.

Or, do you see something that I (again) missed.
I might be having an off day :slight_smile:

3 Likes

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.