Sign up ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. It's 100% free, no registration required.

I have installed PHP, MySQL, Apache on CentOS 6, now I have restarted the Apache and mysql, to test PHP i have created a index.php on /var/www/html/test/ now once i go to localhost/test/index.php then it shows only PHP soruce code like this: enter image description here

From Gnouc comment, i understand that it is due to SELinux security layer.
To work with HTML directory i did this in my terminal, but still i have the same result:

[root@localhost www]# chcon -v --type=httpd_sys_content_t html
changing security context of `html`

Any idea? Thanks

share|improve this question
Is SELinux enable? –  cuonglm May 15 '14 at 5:29
if it is enable should i disable it? and if so does it effects on the security? –  meh -_- May 15 '14 at 5:51
If SELinux is enable, you should check if it allow cgi script to execute and make sure ownership of php file, and allow it executable. –  cuonglm May 15 '14 at 5:53
Thankyou, i am currently reeading documentation from here –  meh -_- May 15 '14 at 5:57

1 Answer 1

up vote 4 down vote accepted

If your SELinux config is ok, it seems that this error occured because server configuration.

If you have installed php, then make sure that it is loaded by apache and apache is associated with php handler.

LoadModule php5_module        modules/
AddType application/x-httpd-php .php

And you should check your .htaccess. It may have some configurations that overrided apache's config.

share|improve this answer
Don't mind, i'm really new to linux, i run those commands but it shows error: bash: LoadModule: command not found bash: LoadModule: command not found Thanks –  meh -_- May 15 '14 at 7:14
@rakibtg: No, you should check that those lines is in your apache config and are not commented. –  cuonglm May 15 '14 at 7:16
@rakibtg: Do you have any php.conf file in /etc/httpd/conf.d? –  cuonglm May 15 '14 at 7:44
Oh, You should install mod_php. –  cuonglm May 15 '14 at 7:59
Maybe yum --enablerepo=centosplus install mod_php –  cuonglm May 15 '14 at 8:09

Your Answer


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.