Results 1 to 8 of 8

Thread: PHP is not working

  1. #1
    shako_sk8 NNTP User

    Default 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.

    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

    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"...

    then I saw source of page and there was this :

    PHP Code:
    Apache
    <?
    print "Works";
    ?>
    so, in spite of it is index.php, server perceives it as a html file

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

  2. #2
    Join Date
    Jun 2008
    Location
    /dev/belgium
    Posts
    1,946

    Default Re: PHP is not working

    replace <? with <?php

    <? is by default disabled

  3. #3
    Join Date
    Jun 2008
    Location
    /dev/swat
    Posts
    1,181

    Default Re: PHP is not working

    1st thing to do:

    Code:
    <?php
    echo "Works";
    ?>
    Try this, if not working..then we will proceed to next step.


    NOTE: Apache service is running?

    EDIT: microchip8 won.
    Linux[openSUSE, KDE], PHP, MySQL, Wordpress, Tech News, etc :
    http://anl4u.com

  4. #4
    shako_sk8 NNTP User

    Default Re: PHP is not working

    microchip8

    I replaced it and it worked

    Thank you so much for helping...

    and one more question

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

    mmarif4u

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

  5. #5

    Default Re: PHP is not working

    -----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
    >
    > 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
    >
    >

    -----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-----

  6. #6
    Join Date
    Jun 2008
    Location
    /dev/belgium
    Posts
    1,946

    Default Re: PHP is not working

    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

  7. #7
    shako_sk8 NNTP User

    Default Re: PHP is not working

    microchip8

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

    Thank you again!

  8. #8
    Join Date
    Jun 2008
    Location
    /dev/belgium
    Posts
    1,946

    Default Re: PHP is not working

    Quote Originally Posted by shako_sk8 View Post
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •