PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, September 20, 2022

[FIXED] Why is my PHP source code showing?

 September 20, 2022     apache, virtualhost     No comments   

Issue

So, I added the following to my http.conf file:

Listen443

NameVirtualHost *:443

<VirtualHost *:443>
    DocumentRoot /PATH_TO/www
    ServerName www.domain.com
    SSLEngine on
    SSLCertificateFile /PATH_TO/domain.crt
    SSLCertificateKeyFile /PATH_TO/domain.key
    SSLCertificateChainFile /PATH_TO/intermediate.crt
</VirtualHost>

https://www.domain.com works now, but it displays the PHP source code? What could be the reason for this?


Solution

"Server configuration error" is the reason ;-)

It is choosing to serve PHP files as "plain content" instead of handing them to a PHP engine for processing. This doesn't have anything to do with SSL (it will just as happily send the "plain content" over a secure connection).

From PHP: Installation:

AddModule mod_php.c
LoadModule php_module         modules/mod_php.so
LoadModule php5_module        modules/libphp5.so
AddType application/x-httpd-php .php

And from PHP pages won't load:

AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

See a pattern? :-) In any case, read the fine installation instructions for the particular platform/server.

Happy coding.



Answered By - user166390
Answer Checked By - Mildred Charles (PHPFixing Admin)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing