<p>If your website is showing the <em>text</em> of your <code>index.php</code> instead of the actual website code, something is misconfigured with your server setup. Anything <code>.php</code> should be passed along to <code>php-fpm</code> or whatever CGI handler you're using.</p>

CC BY-SA 3.0
2017-12-21T09:32:19.947Z
I've migrated the site over to from [TSO Host](https://www.tsohost.com) to [Fortrabbit](https://www.fortrabbit.com/craft-hosting). Something wasn't right on their linux hosting, so hopefully I won't run into further issues.
Sam
CC BY-SA 3.0
2017-12-20T19:59:00.533Z
2017-12-20T19:59:00.533Z
andrew.welch
<p>A website I built frequently throws up the following code instead of the homepage:</p>

<pre><code>&lt;?php

// Path to your craft/ folder
$craftPath = '../craft';

// Do not edit below this line
$path = rtrim($craftPath, '/').'/app/index.php';

if (!is_file($path))
{
    if (function_exists('http_response_code'))
    {
        http_response_code(503);
    }

    exit('Could not find your craft/ folder. Please ensure that &lt;strong&gt;&lt;code&gt;$craftPath&lt;/code&gt;&lt;/strong&gt; is set correctly in '.__FILE__);
}

require_once $path;
</code></pre>

<p>I have followed the Craft CMS install guide to the letter. Here's the output from php.ini:</p>

<pre><code>engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision    =  12
y2k_compliance = On
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
serialize_precision = 100
safe_mode = Off
disable_functions =
realpath_cache_size=256k
expose_php = Off
max_execution_time = 600     ; Maximum execution time of each script, in seconds
max_input_time = 6000   ; Maximum amount of time each script may spend parsing request data
memory_limit = 768M      ; Maximum amount of memory a script may consume (128MB)
error_reporting  =  E_ALL &amp; ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /var/sites/t/domain.com/public_html/error_log
log_errors_max_len = 1024
report_memleaks = On
track_errors = Off
variables_order = "EGPCS"
register_globals = Off
register_argc_argv = On
auto_globals_jit = On
upload_max_filesize = 100M
post_max_size = 100M
magic_quotes_runtime = Off
magic_quotes_gpc = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
extension_dir = "/usr/newage/lib/php/extensions/no-debug-non-zts-20151012"
enable_dl = Off
file_uploads = On
upload_tmp_dir = /tmp
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
date.timezone = Europe/London
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.connect_timeout = 60
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = On
[Session]
session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor     = 100
session.gc_maxlifetime = 14400
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0

#zend_extension="/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_5.6.so"
#zend_extension_ts="/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_5.6_ts.so"
#zend_extension=/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ZendGuardLoader.so
always_populate_raw_post_data=-1
</code></pre>

<p>The error log set in php.ini is showing up empty.</p>

<p>Via the Craft CPanel, I'm seeing the following recurring errors from the logs tab:</p>

<p><a href="https://i.sstatic.net/JBUxU.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/JBUxU.png" alt="CPanel logs"></a></p>

<p>Here's the Server info via the Craft CPanel:</p>

<p><a href="https://i.sstatic.net/NWgl4.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/NWgl4.png" alt="CPanel Server info"></a></p>

<p>My host has told me that ImageMagick isn't available on the PHP version I'm running (7.1). </p>

<p>For iconv extension, the info bubble is reading:</p>

<blockquote>
  <p>You have a buggy version of iconv installed. (See PHP bug #48147 and
  iconv bug #13541</p>
</blockquote>

<p>My host has recently fixed load issues on one of their hosting clusters, which I initially thought might be causing the problems, but I'm still getting 503 errors.</p>

<p>This may be unrelated, but the site also jumps from having normal permalinks, like so: </p>

<p><a href="https://www.domain.com/pretty-page-url" rel="nofollow noreferrer">https://www.domain.com/pretty-page-url</a></p>

<p>To messy permalinks, like this: </p>

<p><a href="https://www.domain.com/index.php/pretty-page-url" rel="nofollow noreferrer">https://www.domain.com/index.php/pretty-page-url</a></p>

CC BY-SA 3.0
2017-12-19T13:01:29.090Z
None of the information you've provided give any clues about any errors.

1) See if you can find any relevant entries in the Craft log (craft/storage/runtime/logs/ - check both craft.log and phperrors.log)

2) Check your webserver error logs, 503 are often logged there as well.
Erik Weber
CC BY-SA 3.0
2017-12-19T15:06:01.267Z
I've looked through craft.log, craft.log.1, craft.log.2, craft.log.3, craft.log.4 and craft.log.5 under /logs. I can only find 404 errors here for 301 redirects I haven't set up.

The php error log under /logs is just showing login errors, like so: `[03-Dec-2017 13:11:28 UTC] PHP Warning: Declaration of Craft\UserSessionService::afterLogin() should be compatible with CWebUser::afterLogin($fromCookie) in /var/sites/t/domain.com/craft/app/services/UserSessionService.php on line 17`.

I've also checked the web server error logs (error_log), but this is completely blank.
Sam
CC BY-SA 3.0
2017-12-19T18:57:10.397Z
This is very likely a server config issue, either your Apache config/.htaccess file or your Nginx config
andrew.welch
CC BY-SA 3.0
2017-12-19T23:00:05.107Z
You can ignore the iconv message. Imagick is definitely available for PHP 7.1. Where are you seeing the 503's? Not seeing from what you've shared. You can use this to remove index.php from URLs: https://craftcms.com/support/remove-index.php
Brad Bell
CC BY-SA 3.0
2017-12-20T09:52:10.743Z
I'm not actually seeing a 503 error. The site loads code instead of the homepage frequently. The code indicates that it should show a 503 response. Question changed to reflect this. Tried the steps in the link you shared @BradBell, but it happens randomly, so can't troubleshoot the issue. Think a change in host is in order.
Sam
<server><hosting>
Code shows instead of homepage
# Code shows instead of homepage

(Asked by: username_0 on 2017-12-19)

A website I built frequently throws up the following code instead of the homepage:
$craftPath is set correctly in '.__FILE__);
}

require_once $path;

I have followed the Craft CMS install guide to the letter. Here's the output from php.ini:
engine = On
zend.ze1_compatibility_mode = Off
short_open_tag = On
asp_tags = Off
precision    =  12
y2k_compliance = On
output_buffering = Off
zlib.output_compression = Off
implicit_flush = Off
serialize_precision = 100
safe_mode = Off
disable_functions =
realpath_cache_size=256k
expose_php = Off
max_execution_time = 600     ; Maximum execution time of each script, in seconds
max_input_time = 6000   ; Maximum amount of time each script may spend parsing request data
memory_limit = 768M      ; Maximum amount of memory a script may consume (128MB)
error_reporting  =  E_ALL & ~E_NOTICE
display_errors = Off
display_startup_errors = Off
log_errors = On
error_log = /var/sites/t/domain.com/public_html/error_log
log_errors_max_len = 1024
report_memleaks = On
track_errors = Off
variables_order = "EGPCS"
register_globals = Off
register_argc_argv = On
auto_globals_jit = On
upload_max_filesize = 100M
post_max_size = 100M
magic_quotes_runtime = Off
magic_quotes_gpc = Off
magic_quotes_sybase = Off
auto_prepend_file =
auto_append_file =
default_mimetype = "text/html"
extension_dir = "/usr/newage/lib/php/extensions/no-debug-non-zts-20151012"
enable_dl = Off
file_uploads = On
upload_tmp_dir = /tmp
allow_url_fopen = On
allow_url_include = Off
default_socket_timeout = 60
date.timezone = Europe/London
mysql.allow_persistent = On
mysql.max_persistent = -1
mysql.max_links = -1
mysql.default_port =
mysql.connect_timeout = 60
mysqli.max_links = -1
mysqli.default_port = 3306
mysqli.default_socket =
mysqli.default_user =
mysqli.default_pw =
mysqli.reconnect = On
[Session]
session.save_handler = files
session.save_path = /tmp
session.use_cookies = 1
session.name = PHPSESSID
session.auto_start = 0
session.cookie_lifetime = 0
session.cookie_path = /
session.cookie_domain =
session.cookie_httponly = 
session.serialize_handler = php
session.gc_probability = 0
session.gc_divisor     = 100
session.gc_maxlifetime = 14400
session.bug_compat_42 = 1
session.bug_compat_warn = 1
session.referer_check =
session.entropy_length = 0
session.entropy_file =
session.cache_limiter = nocache
session.cache_expire = 180
session.use_trans_sid = 0
session.hash_function = 0

#zend_extension="/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_5.6.so"
#zend_extension_ts="/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ioncube_loader_lin_5.6_ts.so"
#zend_extension=/usr/newage/lib/php/extensions/no-debug-non-zts-20151012/ZendGuardLoader.so
always_populate_raw_post_data=-1

The error log set in php.ini is showing up empty.
Via the Craft CPanel, I'm seeing the following recurring errors from the logs tab:

Here's the Server info via the Craft CPanel:

My host has told me that ImageMagick isn't available on the PHP version I'm running (7.1). 
For iconv extension, the info bubble is reading:

You have a buggy version of iconv installed. (See PHP bug #48147 and
  iconv bug #13541

My host has recently fixed load issues on one of their hosting clusters, which I initially thought might be causing the problems, but I'm still getting 503 errors.
This may be unrelated, but the site also jumps from having normal permalinks, like so: 
https://www.domain.com/pretty-page-url
To messy permalinks, like this: 
https://www.domain.com/index.php/pretty-page-url

**Tags:** server, hosting

> **Comments:**
> **username_1**: None of the information you've provided give any clues about any errors.  1) See if you can find any relevant entries in the Craft log (craft/storage/runtime/logs/ - check both craft.log and phperrors.log)  2) Check your webserver error logs, 503 are often logged there as well.  
> **username_0**: I've looked through craft.log, craft.log.1, craft.log.2, craft.log.3, craft.log.4 and craft.log.5 under /logs. I can only find 404 errors here for 301 redirects I haven't set up.  The php error log under /logs is just showing login errors, like so: `[03-Dec-2017 13:11:28 UTC] PHP Warning: Declaration of Craft\UserSessionService::afterLogin() should be compatible with CWebUser::afterLogin($fromCookie) in /var/sites/t/domain.com/craft/app/services/UserSessionService.php on line 17`.  I've also checked the web server error logs (error_log), but this is completely blank.  
> **username_2**: This is very likely a server config issue, either your Apache config/.htaccess file or your Nginx config  
> **username_3**: You can ignore the iconv message. Imagick is definitely available for PHP 7.1. Where are you seeing the 503's? Not seeing from what you've shared. You can use this to remove index.php from URLs: https://craftcms.com/support/remove-index.php  
> **username_0**: I'm not actually seeing a 503 error. The site loads code instead of the homepage frequently. The code indicates that it should show a 503 response. Question changed to reflect this. Tried the steps in the link you shared @BradBell, but it happens randomly, so can't troubleshoot the issue. Think a change in host is in order.  

---

## 1 answers

### Answer by username_2 on 2017-12-20. Score: 3 | Accepted answer

If your website is showing the *text* of your `index.php` instead of the actual website code, something is misconfigured with your server setup. Anything `.php` should be passed along to `php-fpm` or whatever CGI handler you're using.

> **Comments:**
> **username_0**: I've migrated the site over to from [TSO Host](https://www.tsohost.com) to [Fortrabbit](https://www.fortrabbit.com/craft-hosting). Something wasn't right on their linux hosting, so hopefully I won't run into further issues.  

---

