SitePoint Sponsor

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 25 of 33
  1. #1
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Can't access http://localhost on Vista

    I am working with Head First's "PHP & MySQL" book, and following along in the appendix for installing the development environment on my local machine. I installed MySQL, PHP, and Apache successfully. When I enter "http://localhost" in a browser, all I get is a browser error. I made the small test PHP script that the book shows and put it in C:\Inetpub\wwwroot but of course can't execute the script because I can't access localhost.

    I didn't even have the Inetpub folder on my machine until I followed another on-line tutorial for activating the Vista server on my local machine. I followed their steps (it was geared at turning on IIS) and now have the Inetpub folder, but it appears there's much more setup I still need to do, or something I missed. After reading other Sitepoint posts, I see that Windows Vista is a big part of my problem, but all the same can someone help to get things operating right with my Vista environment? Any tech help needs to be written for a complete newbie who is unfamiliar with going into the windows environment and making behind the scenes changes. Thanks in advance.

  2. #2
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You may want to switch to Apache instead of IIS. The majority of the servers running PHP current run under Apache. Installing Apache, MySQL and PHP is as simple as running 3 installers, so you might want to give it a try -- if you can't get IIS working >.>
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  3. #3
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the quick reply but apparently my original post wasn't clear. I did install Apache and it's this that I can't get working. My reference to IIS was only in that I followed a tutorial for turning on the Vista Server on my local machine which was geared at IIS, and when turned on allowed me to see the Inetpub\wwwroot folder finally. But I am trying to figure out how to work with Apache. I cannot access http://localhost even after installing Apache, MySQL and PHP. Thanks again.

  4. #4
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    PHP + IIS 7 on Windows Vista SP1, nothing easier then reading the documentation at the official IIS website.

    Using FastCGI to Host PHP Applications on IIS 7.0
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  5. #5
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Guys thanks for the help. However, what I'm trying to do is work with Apache, not IIS. Am I going to be able to use the Apache server that I just installed on my machine? I can't access http://localhost now that I've installed it. My system tray icon shows that all Apache services are running, but I still get a browser error.

  6. #6
    SitePoint Evangelist simshaun's Avatar
    Join Date
    Apr 2008
    Location
    North Carolina
    Posts
    438
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do this the easy way... take all the stuff you installed back off, and then get XAMPP or WAMP.

  7. #7
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    try going to http://127.0.0.1 does it work? If it doesn't you may need to check if the service is actually running.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  8. #8
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Well, actually I did that too. I started with the individual programs, then when that failed I picked up on the WAMP tip by reading other posts, so I uninstalled everything and installed WAMP. WAMP would not run, and I still couldn't access http://localhost. I uninstalled WAMP and went back to the original three programs and began asking for help on this forum. I'm still wondering if I can use Apache with Windows Vista. Anyone know?

  9. #9
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oops, I didn't see the tip about going to http://127.0.0.1! I clicked on that and it worked! What does this mean?

  10. #10
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That means apache is running >.>... You don't by chance have a firewall running do you? If so, kill the firewall temporarily and check if http://localhost works. If that works, you may need to open up port 80 in your firewall.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  11. #11
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    C:\Windows\System32\drivers\etc, open "hosts", check to make sure localhost is pointed to 127.0.0.1 or that it is not commented out.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  12. #12
    SitePoint Enthusiast
    Join Date
    Dec 2007
    Posts
    40
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Go to Windows->System32->drivers->etc and open the hosts file using Wordpad.

    The file should contain the following under the commented out description section:

    Code:
    127.0.0.1       localhost
    ::1             localhost
    If those lines are not there add them to to the file and save the file. You may need to change the file permissions in order to save the file.

  13. #13
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by awright418 View Post
    ...You may need to change the file permissions in order to save the file.
    Or copy to the desktop, then move it back after the changes have been made. Or start notepad with admin rights then open the files from there.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  14. #14
    SitePoint Evangelist -T-'s Avatar
    Join Date
    Jun 2002
    Posts
    444
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Vista has a habit of mapping localhost to IPv6 instead of IPv4, so you need to set up IIS or Apache or whatever you're using to bind ports on both IPv6 and IPv4 to get localhost to work
    chrome is a wrapper that combines a browser with spyware

  15. #15
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey thanks everyone for jumping in on this. However, I turned off Windows Firewall, but got the same result. I also went into C:\Windows\System32\drivers\etc\hosts, then opened hosts with notepad, and found out that the local host was exactly as the previous posts indicated they'd be.

  16. #16
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by -T- View Post
    Vista has a habit of mapping localhost to IPv6 instead of IPv4, so you need to set up IIS or Apache or whatever you're using to bind ports on both IPv6 and IPv4 to get localhost to work
    Thanks so much for these tech tips. Can you next tell me how to do this with Apache?

  17. #17
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by banjopaul67 View Post
    Thanks so much for these tech tips. Can you next tell me how to do this with Apache?
    Check in C:\Windows\system32\drivers\etc\HOSTS file for the IPv6 setting (open and edit the HOSTS file by dragging it into a text editor).

    Find this IPv6 line:
    ::1 localhost

    Comment it out so it looks like this:
    # ::1 localhost

    Make sure the first uncommented line is:
    127.0.0.1 localhost

    Save the file, restart Apache and then try to access your localhost again.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  18. #18
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is so much appreciated everyone! What a wonderful resource. I made the changes to the host file, and now when I go to http://localhost, I actually get "IT WORKS!" returned to me.

    So now...I have a PHP script called "test.php" in C:\Inetpub\wwwroot which contains:

    <?php phpinfo(); ?>

    This script doesn't execute when I go to http://localhost, I just get the above mentioned "IT WORKS!" I then went to http://localhost/test.php and the results were that I received a page back that said "<?php phpinfo(); ?>"

    Is C:\Inetpub\wwwroot the actual file that localhost points to, or should I be putting my scripts in a different spot? Thanks!

  19. #19
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Your going to need to alter you httpd.conf file to forward files with extention .php to the php interpreter. Though, the PHP installer does this for you. Have you already installed PHP?
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  20. #20
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, PHP is installed, and I have seen the httpd file so I can get into that fine. I looked in once but it's all greek to me at this early stage in my development. Can you be more specific on how to alter the file so as to send .php files to the interpreter?

  21. #21
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    There should be something like:

    Code:
    LoadModule php5_module        modules/libphp5.so
    AddHandler php5-script php
    If there isn't, add it. modules/libphp5.so should be the path to the php module.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  22. #22
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by imaginethis View Post
    There should be something like:

    Code:
    LoadModule php5_module        modules/libphp5.so
    AddHandler php5-script php
    If there isn't, add it. modules/libphp5.so should be the path to the php module.
    None of that is in the httpd file that I can see. I just went through it 4 times. To my untrained eye, I think I can see the code in this file is grouped into sections. Can you tell me to which section I would actually add this code, and would it be preceded by a # sign or no?

  23. #23
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Its alot easier to just uninstall and reinstall PHP using the PHP5 binary installer. The installer should prompt you for the directory where httpd.conf file is located and it will modify it for you.
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!

  24. #24
    SitePoint Enthusiast
    Join Date
    Sep 2006
    Posts
    48
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    O.k. I uninstalled and re-installed PHP. Doing so reminded me of something I had forgotten earlier and that I am too "green" to have known the significance of. Every time I install or uninstall PHP, I get an error message that says "Error trying access httpd.conf file. You will need to manually configure the web server".

    Your tip told me to use the binary installer, but I don't know that term...the way I did it was to save the installer.msi file from the PHP website to my desktop, then clicked on it to begin the installation. Should I install a different way?

  25. #25
    SitePoint Guru
    Join Date
    Jan 2005
    Location
    heaven
    Posts
    953
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    That is the binary installer
    Creativity knows no other restraint than the
    confines of a small mind.
    - Me
    Geekly Humor
    Oh baby! Check out the design patterns on that framework!


Bookmarks

Posting Permissions

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