Page 1 of 2 12 Last
  • Jump to page:
    #1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0

    PHP beginner - Hello world


    Hi,

    I am trying to run the below script

    <html>
    <head>
    php test
    </head>
    <body>
    <?php echo '<p> "Hello PHP"</p>'?>
    </body>
    </html>

    i have saved is as hello.php.

    Have installed php and Apache.

    In the browser - http://localhost/ loads It works page

    http://localhost/hello.php - shows an error saying
    Not found requested URL was not found in this server.

    My OS is Linux Mint.Please advice.

    Thanks for your help.
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    77
    Are you sure that you called the file hello.php?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0
    Originally Posted by jack13580
    Are you sure that you called the file hello.php?
    Yes.. its saved as hello.php
  6. #4
  7. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Aug 2012
    Posts
    194
    Rep Power
    77
    Then your apache setup is messed up
  8. #5
  9. --
    Devshed Expert (3500 - 3999 posts)

    Join Date
    Jul 2012
    Posts
    3,959
    Rep Power
    1014
    Hi,

    to me, it sounds like you haven't put the file into the right directory. Are you sure it's in the document root?
    The 6 worst sins of securityHow to (properly) access a MySQL database with PHP

    Why can’t I use certain words like "drop" as part of my Security Question answers?
    There are certain words used by hackers to try to gain access to systems and manipulate data; therefore, the following words are restricted: "select," "delete," "update," "insert," "drop" and "null".
  10. #6
  11. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0
    Originally Posted by jack13580
    Then your apache setup is messed up
    Could you please elaborate coz I am having the same issue as the OP!
  12. #7
  13. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    720
    Rep Power
    7
    DocumentRoot by default is the htdocs directory.
    Was this a manual or automated setup?
    If you place an HTML file here, does that work?
    Does the folder you saved your hello.php file in also hold the index.html that is displaying It Works!?
  14. #8
  15. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0
    Hi,

    You are right, my root directory is /var/www

    The script which i am currently running is in the php folder in my home directory.

    I am not keen on changing the permissions of my system directory /var/www and move my script to this folder.

    Is there any way to set the path in Linux to point to the /VAR/WWW directory

    Thanks



    Originally Posted by Jacques1
    Hi,

    to me, it sounds like you haven't put the file into the right directory. Are you sure it's in the document root?
  16. #9
  17. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    /var/www was created by apache specifically for this. It should be modded 774 and owned by apache and the apache group. You should put yourself in that group as well.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  18. #10
  19. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2009
    Posts
    720
    Rep Power
    7
    It's sounding everything is working right. Are you aiming to not use /var/www and hold your files elsewhere?
  20. #11
  21. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Oct 2009
    Location
    Nebraska, USA
    Posts
    876
    Rep Power
    276
    Apache in Linux "should" be setup to allow use of the USER folders by default.

    try using the link like below and see if it loads (change <yourusername> to whatever your user name is in linux)
    Code:
    http://localhost/~<yourusername>/php/hello.php
  22. #12
  23. No Profile Picture
    Banned
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    chennai
    Posts
    23
    Rep Power
    0
    you can check this demo from w3schools perfect tutorial about php beginners.
  24. #13
  25. Sarcky
    Devshed Supreme Being (6500+ posts)

    Join Date
    Oct 2006
    Location
    Pennsylvania, USA
    Posts
    10,908
    Rep Power
    6352
    Do not use w3schools. They are not affiliated with the w3c and they give bad advice.

    Also, it's irrelevant to the current discussion so I'm wondering why Peter keeps posting random unrelated things.
    HEY! YOU! Read the New User Guide and Forum Rules

    "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -Benjamin Franklin

    "The greatest tragedy of this changing society is that people who never knew what it was like before will simply assume that this is the way things are supposed to be." -2600 Magazine, Fall 2002

    Think we're being rude? Maybe you asked a bad question or you're a Help Vampire. Trying to argue intelligently? Please read this.
  26. #14
  27. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0
    Originally Posted by DonR
    Apache in Linux "should" be setup to allow use of the USER folders by default.

    try using the link like below and see if it loads (change <yourusername> to whatever your user name is in linux)
    Code:
    http://localhost/~<yourusername>/php/hello.php
    Tried this http://localhost/myusername/php/hello.php
    However getting the same error..
  28. #15
  29. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    6
    Rep Power
    0
    Originally Posted by Triple_Nothing
    DocumentRoot by default is the htdocs directory.
    Was this a manual or automated setup?
    If you place an HTML file here, does that work?
    Does the folder you saved your hello.php file in also hold the index.html that is displaying It Works!?
    My index.html is in var/www. While i try to copy my hello.php into this folder i get a message which says "Permission Denied - cannot copy regular files"
Page 1 of 2 12 Last
  • Jump to page:

IMN logo majestic logo threadwatch logo seochat tools logo