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.
-
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 '12 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. – Richard Keller May 28 '12 at 21:42
2 Answers
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.

- 11,176
- 5
- 41
- 63
-
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 '12 at 16:44
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.

- 855
- 6
- 8