2

I have files in public_html (index.html). When I go to the main page it gives me "Apache Test Page". When I try to add link to them manually (domain_name/index.html or index2.php) it gives me only code, like in .txt editor. I would really appreciate any help.

2
  • is it showing correctly formatted html files as text? (because that would suggest some other mime-type problem, i.e. apache is sending html files as text/plain)
    – Tom
    May 28, 2012 at 16:27
  • Please specify the operating system you're using, as well as the version of PHP currently installed. Quite likely this is simply a matter of mod_php not being installed or correctly configured. May 28, 2012 at 21:42

2 Answers 2

1

you would need to ensure that the php is installed correctly. See the output of apachectl -M and look for php5_module (shared):

# apachectl -M
 ...
 core_module (static)
 mpm_prefork_module (static)
 ... 
 php5_module (shared)   <---here, need this
 dav_svn_module (shared)
 authz_svn_module (shared)
Syntax OK

This last step is generally achieved by installing the php package, which contains support for configuring php module in httpd automatically.

Then check that php-script is configured as the php interpreter is used for scripts with the php suffix;

<IfModule prefork.c>
  LoadModule php5_module modules/libphp5.so
</IfModule>

AddHandler php5-script .php
AddType text/html .php

on centos these directives show up in /etc/httpd/conf.d/php.conf and restart apache2.

1
  • When I write in command shell: apachectl -M. It gives me that: httpd: Syntax error on line 221 of /etc/httpd/conf/httpd.conf: Syntax error on line 57 of /etc/httpd/conf.d/httpd.conf: ServerRoot must be a valid directory. 57 line: ServerRoot "/etc/httpd" 221 line: Include conf.d/*.conf
    – Mark
    May 28, 2012 at 16:44
0

It certainly looks like that your apache installation is configured to load mime module.

Please run

# apachectl -M | grep mime

and check if you can see any mime module in the list. If not, then install the mime module. Please have a look at this, http://httpd.apache.org/docs/2.0/mod/mod_mime.html

Generally apache ships with mime module and you may not need to recompile it.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .