PHP is not working

hello everybody.

PHP isnt working, but i dont know why. I have installed it.
I checked modules in httpd.conf and php5 was there.

# cat `rpm -ql apache2-mod_php5|grep conf`                                      
<IfModule mod_php5.c>                                                                                      
        AddHandler application/x-httpd-php .php4                                                           
        AddHandler application/x-httpd-php .php5                                                           
        AddHandler application/x-httpd-php .php                                                            
        AddHandler application/x-httpd-php-source .php4s                                                   
        AddHandler application/x-httpd-php-source .php5s                                                   
        AddHandler application/x-httpd-php-source .phps                                                    
        DirectoryIndex index.php4                                                                          
        DirectoryIndex index.php5                                                                          
        DirectoryIndex index.php                                                                           
</IfModule>   

but it still is not working :frowning:

this is my /srv/www/htdocs/index.php

# cat index.php
Apache
<?
print "Works";
?>

but http://localhost only shows “Apache”, but not “Works”…

then I saw source of page and there was this :

Apache
<?
print "Works";
?>

so, in spite of it is index.php, server perceives it as a html file :frowning:

sorry for my english, i hope you understand anything
and thanks in advance :slight_smile:

replace <? with <?php

<? is by default disabled

1st thing to do:

<?php
echo "Works";
?>

Try this, if not working…then we will proceed to next step.

NOTE: Apache service is running?

EDIT: microchip8 won.

microchip8

I replaced it and it worked :slight_smile:

Thank you so much for helping…

and one more question

how can I enable, to start php script with <? this? :slight_smile:

mmarif4u

yes apache is running, and I restarted It many times. I was a little nervous : ))

in /etc/php5/apache2 and /etc/php5/cli config files - usually php.ini

Keep in mind that using short php tags (<?) is not recommended due to portability reasons

Set short_open_tag = Off to short_open_tag = On

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

‘<?’ should be ‘<?php’.

Good luck.

shako sk8 wrote:
> hello everybody.
>
> PHP isnt working, but i dont know why. I have installed it.
> I checked modules in httpd.conf and php5 was there.
>
>
> PHP code:
> --------------------
> # cat rpm -ql apache2-mod_php5|grep conf
> <IfModule mod_php5.c>
> AddHandler application/x-httpd-php .php4
> AddHandler application/x-httpd-php .php5
> AddHandler application/x-httpd-php .php
> AddHandler application/x-httpd-php-source .php4s
> AddHandler application/x-httpd-php-source .php5s
> AddHandler application/x-httpd-php-source .phps
> DirectoryIndex index.php4
> DirectoryIndex index.php5
> DirectoryIndex index.php
> </IfModule>
> --------------------
>
>
> but it still is not working :frowning:
>
> this is my /srv/www/htdocs/index.php
>
>
> PHP code:
> --------------------
> # cat index.php
> Apache
> <?
> print “Works”;
> ?>
> --------------------
>
>
> but http://localhost only shows “Apache”, but not “Works”…
>
> sorry for my english
> and thanks in advance :slight_smile:
>
>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.9 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/

iQIcBAEBAgAGBQJKhF7DAAoJEF+XTK08PnB5DdUP/3acSr1AjvrZtTCWRK4r7iut
gIO27BKKYcd8hJjP+AjCrLVhGO4G6miGMXPCtkMsCbQXWNeG0PPX+g7NAmoMD+1Y
tN5slJYjvvF4Pquzy3ChWVcwy8WTNmDaMDbnmCn02PPtuY8h/If1/9kzyGrFVQm5
dKnxfiDOdJzTtkCTLVY9baw4O3HZbypJx5Gme7ZY9r4+v1YAt5VL4XMLYse0dFKD
26ffb0gfAW+QHEKoXkMjifd0O2ZI/n07fpVkkOakwXGJcEJHatVM+4XjCIwr9lXn
I7E8eeiQlDuLi7Feinv7me61VkZAuU16/56egF+hPJ/pkyBClbmlmwqDiYbS2y6y
LjW46/GHp5NaZ/XTnkokngbKrtT6DSia3qNOLtW8I3hqcFBo/0ACeQprNFpi9Lhc
tKKuOORypPd8GeWpZ3d/iLvqiC2upD6i0vkrHeCPP/sEc1VfL6LlBcNX6ZMV/bHn
aZCV1pNxp4IfDKwiGoG0BqT5I9aEvaHQs4WKdEpgWEK2iumUw9SrOU1UL2tbq3oz
5Su031lBTc3PbKJ6RzNmg/Tex9EVJKAUXfXltoKBTjl19lEgCKTZ48Gi4tKTHzME
/6NOghBOOgNSGxMPFq+BJWzCGzfpvjDPCEq/4E4iuuMu32fc3nmEVjsn9ARWQZpC
MPi/O0EaHW6Dbw4hLPPq
=gsZz
-----END PGP SIGNATURE-----

microchip8

I used to start php with short tags, but I think its time to grow out of that habit.

Thank you again!

Definitely. Always use long tags no matter if you’re writing you own local site in php or a big public (commercial) site :wink: