PHP on centos 6 not working
26,417
Solution 1
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/libphp5.so
AddType application/x-httpd-php .php
And you should check your .htaccess
. It may have some configurations that overrided apache's config.
Solution 2
yum install mod_php -y
systemctl restart httpd.service
Related videos on Youtube
Author by
MikeH
Updated on September 18, 2022Comments
-
MikeH over 1 year
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 tolocalhost/test/index.php
then it shows only PHP source code like this:
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?-
Admin almost 10 yearsIs
SELinux
enable? -
Admin almost 10 yearsif it is enable should i disable it? and if so does it effects on the security?
-
Admin almost 10 yearsIf
SELinux
is enable, you should check if it allow cgi script to execute and make sure ownership of php file, and allow it executable. -
Admin almost 10 yearsThankyou, i am currently reeading documentation from here wiki.centos.org/HowTos/SELinux
-
-
MikeH almost 10 yearsDon'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
-
cuonglm almost 10 years@rakibtg: No, you should check that those lines is in your apache config and are not commented.
-
MikeH almost 10 yearsOps! i think i have nothing like LoadModule php... in my httpd.conf file , any idea?
-
cuonglm almost 10 years@rakibtg: Do you have any
php.conf
file in/etc/httpd/conf.d
? -
MikeH almost 10 yearsI think no there isn't any file like php.conf ! i.stack.imgur.com/Lv7v1.png What i should do now? Thanks for your time :)
-
cuonglm almost 10 yearsOh, You should install
mod_php
. -
MikeH almost 10 yearsHow i can install mod_php, because i have already installed apache?
-
cuonglm almost 10 yearsMaybe
yum --enablerepo=centosplus install mod_php
-
Gravy over 8 yearsPlease note that on a
CentOS 6
machine,systemctl restart httpd.service
will return a "command not found."service httpd restart
would be the correct means of restarting the httpd service. -
Jack almost 8 yearsThanks worked, can I specify the php version?
-
GTS Joe over 7 yearsThis worked for me after I restarted Apache. Thanks! =)