Welcome Guest, Not a member yet? Register   Sign In
CodeIgniter setup and PHP require errors
#1

[eluser]dilettante[/eluser]
Hi everyone,

I'm going through my first CodeIgniter installation and setting up my first application. My application page comes up, but as soon as I try to hit a button, this comes up:

Code:
Warning: require_once(/var/www/system/codeigniter/CodeIgniter.php) [function.require-once]: failed to open stream:
No such file or directory in /var/www/index.php on line 115

Fatal error: require_once() [function.require]: Failed opening required
'/var/www/system/codeigniter/CodeIgniter.php'
(include_path='.:/usr/share/php:/usr/share/pear') in /var/www/index.php on line 115

I installed index.php, system, and application all at /var/www/search. I've tried putting application within system, but that doesn't seem to change anything. For some reason the correct path doesn't seem to work here (the last line is 115 in index.php). It looks like it expects application to be inside system, but in that case I don't understand why moving application there doesn't help.

Code:
define('BASEPATH', $system_folder.'/');

if (is_dir($application_folder))
{
    define('APPPATH', $application_folder.'/');
}
else
{
    if ($application_folder == '')
    {
        $application_folder = 'application';
    }
    define('APPPATH', BASEPATH.$application_folder.'/');
}
require_once BASEPATH.'codeigniter/CodeIgniter'.EXT;

My config.php has the following:

Code:
$config['base_url'] = "http://www.domain.com/search/";
$config['index_page'] = "";//index.php
$config['uri_protocol']    = "AUTO";

In index.php, I've left system at "system" and application at "application". I've tried the "../system" mentioned on other posts, which just makes the entire application page go away.

Finally, for good measure, here's my directory stuff in Apache.

Code:
<Directory /var/www/search>
Options -Indexes
Options +FollowSymLinks
DirectoryIndex index.php
<IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /search/
        ErrorDocument 403 /index.php/403/
        ErrorDocument 404 /index.php/404/
        ErrorDocument 500 /index.php/500/
</IfModule>
<IfModule !mod_rewrite.c>
        ErrorDocument 404 index.php
</IfModule>

I'm really stumped. Obviously, index.php isn't using the right path to codeigniter.php, but I can't figure out why. Any help much appreciated!
#2

[eluser]stuffradio[/eluser]
What button are you trying to hit when that happens?
#3

[eluser]dilettante[/eluser]
It's for an HTML form using a get method. JavaScript elements on the page appear to work (e.g., JGrowl windows), but nothing that would go to another HTML page functions.
#4

[eluser]erik.brannstrom[/eluser]
Are you sure your .htaccess file is working correctly? I personally have trouble with these every now and then.. But anyway, you have set your index page to empty in the configuration, yet I can't spot any redirects for requests to that file?

Try one of these:
http://gist.github.com/385220
http://jamieonsoftware.com/blog/entry/th...-.htaccess
http://codeigniter.com/wiki/mod_rewrite/
#5

[eluser]dilettante[/eluser]
I'm definitely not sure that my rewrites are working correctly. However, I tried a bunch of variations on the .htaccess examples you mentioned (although I'm doing all these as directory initiatives in httpd.conf, by the way), and none of them quite worked.

For some reason, they all resulted in an error where CI told me it was unable to load one of the library classes. I tried including a /search/ rewritebase, including AllowOverride All, and so on, and the behavior was always the same.

Any thoughts?
#6

[eluser]WanWizard[/eluser]
This is the one that I include in every project I do:
Code:
<IfModule mod_rewrite.c>

    # ATTENTION: if this .htaccess doesn't work, check if rewrites
    # are allowed in httpd.conf. You need to specify:
    # <Directory "my-website-directory-here">
    #     Options +FollowSymLinks
    #     AllowOverride FileInfo
    # </Directory>
    # or have these options defined globally in your httpd.conf file
    # to allow a .htaccess with rewrite rules to work!

    # activate URL rewriting
    RewriteEngine On

    # if ExiteCMS is installed in a sub-directory of the document
    # root, modify the path below accordingly
    RewriteBase /

    # nasty hack to capture ruined URI's by a mod_rewrite bug.
    #
    # You need these two lines when you use mod_vhost_alias, and this
    # .htaccess file generates a "500 internal server error".
    # In the rule below, replace --DOCROOT-- by your full docroot path,
    # without a leading slash, but with a trailing slash!
    # (i.e 'path/to/my/docroot/', without quotes offcourse)
    #
#    RewriteCond $1 index\.php/$
#    RewriteRule ^--DOCROOT--(.*)$ /$1 [S=1]

    # do not rewrite links to development stuff (not needed when live!)
    RewriteCond $1 !^!dev

    # do not rewrite links to website assets
    RewriteCond $1 !^assets

    # do not rewrite for php files in the document root or robots.txt
    RewriteCond $1 !^([^\..]+\.php|robot\.txt)

    # do not rewrite requests for the standard asset files
    RewriteCond $1 !\.(css|js|png|jpg|gif|zip|gz|htc)$

    # but rewrite everything else
    RewriteRule ^(.*)$ index.php/$1 [L]

</IfModule>

Hasn't failed me up till now...
#7

[eluser]dilettante[/eluser]
Hmm, ok, turns out that library class just didn't copy over when I uploaded the files to the server. God, I hate bugs like that. Thanks for bearing with me.
#8

[eluser]dilettante[/eluser]
The latest twist in my CI/mod_rewrite saga: My site is now up, but all the images break unless they explicitly use the base url:

Code:
img src="&lt;?php echo base_url();?&gt;/img/..."


I'm assuming this means that my URL rewriting still doesn't work correctly, and that I'm essentially using a workaround. Is that right?

Here's the current httpd.conf stuff I'm using:

Code:
<Directory /var/www/search>
Options -Indexes
Options +FollowSymLinks
#DirectoryIndex index.php
<IfModule mod_rewrite.c>
        AllowOverride All
    RewriteBase /search/
        RewriteEngine On
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !\.(css|img|js|)$
    RewriteRule (.*) index.php/$1 [L]
    ErrorDocument 403 /index.php/403/
    ErrorDocument 404 /index.php/404/
    ErrorDocument 500 /index.php/500/
</IfModule>
<IfModule !mod_rewrite.c>
    ErrorDocument 404 index.php
</IfModule>

I must admit that I'm not very familiar with the regexp stuff in the rewrite conditions and rules. If you have any thoughts on a good introduction to those, I'd appreciate it. Everything I find online seems to be more in the mode of "here's what worked for me, try it out." Why are so many people defaulting to trial and error on this, anyway?[/quote]




Theme © iAndrew 2016 - Forum software by © MyBB