Setup Codeigniter Local Testing Environment

by Cash37
18 replies
Can anyone help me with this issue?

I downloaded my database, and files of my webapp to my localhost. It is a codeigniter application and runs fine online. I got WAMP, and it runs fine. I changed everything in database.php and config.php to the right values, and when I try to load it locally on localhost it hangs at "waiting for localhost."

Ive searched and searched around and cannot find a fix for this. If anyone can help me get this running I'd be grateful!
#codeigniter #environment #local #setup
  • Profile picture of the author spradlig
    I run WAMP some for testing of PHP scripts but I haven't done it much since I started turning old computers into Ubuntu LAMP servers. I've also used CodeIgniter and moved it from one host to another.

    I don't remember seeing this issue with CodeIgniter when moving from 1 host to another. (There were issues, generally path issues, that I had to deal with but not this one.) So I would guess this is a WAMP not on or CodeIgniter config path not right issue.

    You may have already tried this but just in case...

    The "waiting on localhost" error makes me think you haven't turned the WAMP server on. WAMP has, for the most part, just worked for me so I'm not great at troubleshooting it. When you get the "waiting on localhost" error, have you tried to go to other PHP based pages to see if the server is working properly (right then, not an hour earlier or the day before...)? I would create a phpinfo.php file that calls phpinfo to display information about your PHP install. Then I would use it as my test page to make sure that the WAMP server and its PHP are working properly. Then immediately after that is successful I would try the CodeIgniter page again.

    If phpinfo comes up fine then it is clearly a CodeIgniter issue - probably some path in the config files that was missed or some default value you never had to change before that is different because I believe WAMP will have a different base directory structure - i.e. c:\wamp\www instead of /var/www - than a Linux server.

    If you still have issues I would attempt to isolate which block of your code/which line of your code is causing the issues. I'm assuming you get this error at the index.php page from CodeIgniter, if so, isolating the code shouldn't take too long. I would hazard a guess that something in the CodeIgniter config is still wrong. Once you isolate the line of code that is causing problems it will likely be a CodeIgniter built in function that you can search for help on in the CodeIgniter website. The site will usually provide you a solution once you can search for the error and a function name.

    Hope this helps.
    {{ DiscussionBoard.errors[3389775].message }}
    • Profile picture of the author Cash37
      Originally Posted by spradlig View Post

      I run WAMP some for testing of PHP scripts but I haven't done it much since I started turning old computers into Ubuntu LAMP servers. I've also used CodeIgniter and moved it from one host to another.

      I don't remember seeing this issue with CodeIgniter when moving from 1 host to another. (There were issues, generally path issues, that I had to deal with but not this one.) So I would guess this is a WAMP not on or CodeIgniter config path not right issue.

      You may have already tried this but just in case...

      The "waiting on localhost" error makes me think you haven't turned the WAMP server on. WAMP has, for the most part, just worked for me so I'm not great at troubleshooting it. When you get the "waiting on localhost" error, have you tried to go to other PHP based pages to see if the server is working properly (right then, not an hour earlier or the day before...)? I would create a phpinfo.php file that calls phpinfo to display information about your PHP install. Then I would use it as my test page to make sure that the WAMP server and its PHP are working properly. Then immediately after that is successful I would try the CodeIgniter page again.

      If phpinfo comes up fine then it is clearly a CodeIgniter issue - probably some path in the config files that was missed or some default value you never had to change before that is different because I believe WAMP will have a different base directory structure - i.e. c:wampwww instead of /var/www - than a Linux server.

      If you still have issues I would attempt to isolate which block of your code/which line of your code is causing the issues. I'm assuming you get this error at the index.php page from CodeIgniter, if so, isolating the code shouldn't take too long. I would hazard a guess that something in the CodeIgniter config is still wrong. Once you isolate the line of code that is causing problems it will likely be a CodeIgniter built in function that you can search for help on in the CodeIgniter website. The site will usually provide you a solution once you can search for the error and a function name.

      Hope this helps.
      I've turned everything on. I think its because the application uses URL rewriting.. something about that isnt letting me load the index page. I will check my logs and see what is going on.
      {{ DiscussionBoard.errors[3391470].message }}
  • Profile picture of the author Cash37
    Seems I had to set $config['uri_protocol'] = "REQUEST_URI";

    it was on auto. Now it gives me:

    "Firefox has detected that the server is redirecting the request for this address in a way that will never complete."
    {{ DiscussionBoard.errors[3391550].message }}
    • Profile picture of the author spradlig
      I can't remember the WAMP defaults and this may sound stupid but is mod_rewrite on?
      {{ DiscussionBoard.errors[3398955].message }}
      • Profile picture of the author Cash37
        Originally Posted by spradlig View Post

        I can't remember the WAMP defaults and this may sound stupid but is mod_rewrite on?
        Yes it is not a default and it is on for me locally

        If your on windows vista or 7 your need to first turn off IIS 7
        What is IIS 7? I have Win 7.

        Originally Posted by Tim Brownlaw View Post

        Let's step back here and get to some point that works.

        Get a fresh install of CI from the codeigniter site and plonk it into your
        c:wampwww folder.

        Typing in localhost should result in you being greeted by the welcome page.

        If that works, put your CI version of your website back on.

        Now a real website uses paths like /home/mywebsite/public_html

        As spradlig suggested , sounds like a path issue.
        If you've got your DB downloaded in a .sql and the code for the site, do a search for anything to do with where the site was hosted...

        ie if it was on say www.mysite.com look for mysite and things like /home/mysite to see if there are any hard coded paths you need to change.
        Same thing in the DB and the .htaccess file.

        Let us all know how that goes.

        Cheers
        Tim
        I have done this. Everything seems to work but my index page. I also have a forum that has worked locally from day 1 that uses the same DB.

        I am sure that it is some kind of dynamic problem. I can get the URLs to generate dynamically from the index.php file into /home/blahblah but they dont load. I can see the correct URLs in my browser but I get a white screen that hangs at waiting for local host or tells me it is a loop that will never get completed.

        I have toyed around with .htaccess and nothing much changes, still white screen with correct URL that loops endlessly.
        {{ DiscussionBoard.errors[3412859].message }}
        • Profile picture of the author Tim Brownlaw
          I see you had checked the config and database files.
          Have you looked at the routes file?

          With the forum, is that a off the shelf script or a custom one built on CI?


          {{ DiscussionBoard.errors[3413797].message }}
  • Profile picture of the author nxtgencreative
    If your on windows vista or 7 your need to first turn off IIS 7
    {{ DiscussionBoard.errors[3399331].message }}
  • Profile picture of the author Tim Brownlaw
    Let's step back here and get to some point that works.

    Get a fresh install of CI from the codeigniter site and plonk it into your
    c:\wamp\www folder.

    Typing in localhost should result in you being greeted by the welcome page.

    If that works, put your CI version of your website back on.

    Now a real website uses paths like /home/mywebsite/public_html

    As spradlig suggested , sounds like a path issue.
    If you've got your DB downloaded in a .sql and the code for the site, do a search for anything to do with where the site was hosted...

    ie if it was on say www.mysite.com look for mysite and things like /home/mysite to see if there are any hard coded paths you need to change.
    Same thing in the DB and the .htaccess file.

    Let us all know how that goes.

    Cheers
    Tim
    {{ DiscussionBoard.errors[3401917].message }}
  • Profile picture of the author Cash37
    Cleared that error in .htaccess with adding a slash to

    RewriteRule ^(.*)/$ index.php/$1 [L]

    NOW /home/ is not found. Some controller... ugh

    /home was not found on this server.
    {{ DiscussionBoard.errors[3414903].message }}
    • Profile picture of the author Tim Brownlaw
      Originally Posted by Cash37 View Post

      Cleared that error in .htaccess with adding a slash to

      RewriteRule ^(.*)/$ index.php/$1 [L]

      NOW /home/ is not found. Some controller... ugh

      /home was not found on this server.
      How about trying this...
      RewriteRule ^(.*)$ /index.php/$1 [L]

      There is a wee difference to what you had.
      {{ DiscussionBoard.errors[3415212].message }}
      • Profile picture of the author Cash37
        Originally Posted by Tim Brownlaw View Post

        How about trying this...
        RewriteRule ^(.*)$ /index.php/$1 [L]

        There is a wee difference to what you had.
        That setting redirects me to the wamp welcome page under my custom written url. Weird!
        {{ DiscussionBoard.errors[3419273].message }}
        • Profile picture of the author Tim Brownlaw
          Originally Posted by Cash37 View Post

          That setting redirects me to the wamp welcome page under my custom written url. Weird!
          What if you rename your .htaccess file to something that's not .htaccess and type in the full URL to one of your controllers?

          I'm in Melbourne, Australia which puts us in Time Zone funness! but I still think this would be a whole lot faster if I could eyeball what you've got there.

          PM me a good time you'll be online, as this is driving me nuts not being able to get you sorted out!

          Cheers
          Tim
          {{ DiscussionBoard.errors[3419974].message }}
  • Profile picture of the author Cash37
    @Tim

    Nothing happens when I do that.

    I think Im just going to use a old domain and use my webserver for testing. The problem has to be that my server is Linux and running a 1.0 version of Codeigniter and I cannot replicate that enviornment locally at all. Oh well. I cant waste anymore time on this, got to get v2.0 of my site done!

    EDIT

    Got the test server up and running, and now it wont let me log in. This is great! Going on 3 weeks with no production. I f*&^% hate codeigniter and the stupid ass team who programmed in this s%^ty language. I told them PHP, not a s%^tty framework.

    Just terrible. F^&*ing terrible.
    {{ DiscussionBoard.errors[3436924].message }}
    • Profile picture of the author Tim Brownlaw
      Originally Posted by Cash37 View Post

      @Tim

      Nothing happens when I do that.

      I think Im just going to use a old domain and use my webserver for testing. The problem has to be that my server is Linux and running a 1.0 version of Codeigniter and I cannot replicate that enviornment locally at all. Oh well. I cant waste anymore time on this, got to get v2.0 of my site done!

      EDIT

      Got the test server up and running, and now it wont let me log in. This is great! Going on 3 weeks with no production. I f*&^% hate codeigniter and the stupid ass team who programmed in this s%^ty language. I told them PHP, not a s%^tty framework.

      Just terrible. F^&*ing terrible.
      Great to hear you've got it running!

      I wouldn't go blaming CodeIgniter as such for your woes. You can write a mess in plain PHP just as well.

      Are you running WAMP? There isn't anything that special in CI that would make a difference if its running happily on a Linux Server.

      Regarding the Login, you can dive into your local DB and check out the table with your username and password. If the password is encrypted, you can find the code that does the login and check if its MD5 or what not. Then you can create your own Password using the same encryption method in a PHP script you'll write.. Then update the Database...

      Your Plan B to install it on another website is an option but you may have the same issues, but it's definitely worth a shot.

      If you do get it up on another website and it has a password retrieval option, then use that. Grab the code it generates in its DB and modify your local DB.

      It would really be a lot quicker to have your local version of the script running if you are doing changes.

      We could have had this nutted out in an hour, but seems you are reluctant for any help outside of here, and that's fair as you don't know me from a bar of soap! The offer still stands though.

      Cheers
      Tim
      {{ DiscussionBoard.errors[3438344].message }}
      • Profile picture of the author Tim Brownlaw
        I don't think I asked this so I will now!

        Did you setup you WAMP Server to take an URL instead of just localhost?

        ie www.somewebsitename.com so you can use that on your local server?

        Might just be easier to configure it for the actual website name in case the URL is hardcoded.

        Oh and mod_rewrite is disabled by default, you have to turn that on in the httpd.conf file by uncommenting it and restarting WAMP.
        Cheers
        Tim
        {{ DiscussionBoard.errors[3443180].message }}
        • Profile picture of the author Cash37
          Originally Posted by Tim Brownlaw View Post

          I don't think I asked this so I will now!

          Did you setup you WAMP Server to take an URL instead of just localhost?

          ie www.somewebsitename.com so you can use that on your local server?

          Might just be easier to configure it for the actual website name in case the URL is hardcoded.

          Oh and mod_rewrite is disabled by default, you have to turn that on in the httpd.conf file by uncommenting it and restarting WAMP.
          Cheers
          Tim
          Maybe the mod_rewrite is what I need to look at. I ended up deleting the test server I had on a throwaway domain.com.

          This is still driving me nuts. Now Im trying just to hack and slash code on the live site and what does codeigniter do? Redirect me to the login page! (EDIT: figured out a fix) Awesome! Just a terrible framework and a mess.

          Tim I really could use your help but the thing is I am in the USA EST Timezone.. I will look you up on Skype from time to time and see if you pop online.
          {{ DiscussionBoard.errors[3443650].message }}
  • Profile picture of the author phpbbxpert
    When you have WampServer installed (the latest) you can left click on the tray icon.
    A menu pops up, Services > Apache > Apache Modules > scroll down the list toe Rewrite_module and click it. The server should reboot automatically, if not click restart all services.
    Then check to be sure that the rewrite module has a check by it.

    CodeIgniter has a setting for URL, usually in the application/config/config.php
    config['base_url'] =

    This is depending on how the app was setup, but generally pretty standard in CI.
    {{ DiscussionBoard.errors[3443921].message }}

Trending Topics