Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

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.

share|improve this question
    
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 H 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
add comment

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.

share|improve this answer
    
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
add comment

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.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.