Welcome Guest, Not a member yet? Register   Sign In
Apache problem?
#1

[eluser]luisfmgoncalves[/eluser]
Hello,

I've been developing an application in my Windows box (localhost) and now I'm trying to put the application in a Linux server. And of course, I'm having problems...

When I started to develop in windows, I did some configurations to make things work, but in the end was all ok. I used XAMPP.

Now something is wrong and I think is something to do with Apache configuration. I followed this steps: http://codeigniter.com/wiki/mod_rewrite/ to take off the index.php and I can open the application. But when I try to do something on it, simple don't work...

When I do:
Code:
a2enmod

and then
Code:
rewrite

I got the message: 'Module rewrite already enabled', which is good...

If I do:
Code:
apache2ctl -l

I got:
Code:
Compiled in modules:
  core.c
  mod_log_config.c
  mod_logio.c
  prefork.c
  http_core.c
  mod_so.c

Which of this is the mod_rewrite?
Oh, and by the way, the file mod_rewrite.so shouldn't be present in /etc/lib/apache2/modules? Because it's not there!

Any of you can help me?
#2

[eluser]n0xie[/eluser]
Code:
apache2ctl -l
This only shows the modules that have been compiled with apache. They don't give you all the loaded modules.

Try:
Code:
apache2ctl -t -D DUMP_MODULES
#3

[eluser]luisfmgoncalves[/eluser]
Hello, and thanks for your reply.
I can see that mod_rewrite is active:

Code:
rewrite_module (shared)

But I'm experience something strange and I'm not sure if is because of the .htaccess file.
For example, when I enter my application, I have this in my main page:

Code:
<a href="main/login"><div style="margin: 10px">&lt;?php echo snappy_image('twitter_button_3_hi.gif', '', ''); ?&gt;</div></a>

So, this is just a call to the controller main and to the function login

I changed the login function code, just for tests and now I have just this:

Code:
function login(){
  $this->load->view('teste_view');
}

So, this is just a call to a view that contains the following code:

Code:
&lt;html&gt;
  &lt;head&gt;
    &lt;title&gt;Test&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    <h1>Hello!</h1>
  &lt;/body&gt;
&lt;/html&gt;

So, just a pretty basic html page. And when I press the link, the browser goes to:

Code:
http://somedomain.co.uk/project/main/login

And this is correct. But, the problem is, when I press the link, the application just open an empty (blank) page!
Any of know what could be the problem?

My .htaccess file is like this:
Code:
<IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /project/

    RewriteCond %{REQUEST_URI} ^system.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    RewriteCond %{REQUEST_URI} ^project.*
    RewriteRule ^(.*)$ /index.php/$1 [L]

    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond $1 !^(index\.php|images|stylesheets|system/application/sources/)
    RewriteRule ^(.*)$ index.php/$1 [L]
</IfModule>

<IfModule !mod_rewrite.c>
    ErrorDocument 404 /index.php
</IfModule>
AddHandler x-httpd-php5 .php .php3 .php4 .phtml # phpvs v5

(My project is in /var/www/project)

I'm using:

Code:
$config['uri_protocol'] = "PATH_INFO";

Because I'm using this library.

This is the .htaccess file I use in my Windows box, and everything is working good and the httpd.conf file in my Apache (with XAMPP) is like:

Code:
<Directory "C:/Program Files/XAMPP/htdocs">
  Options Indexes FollowSymLinks Includes ExecCGI
  AlowOveride All
  Order allow, deny
  Allow from all
</Directory>

In the Linux box I have (in /etc/apache2/sites-enabled/000-default):

Code:
<Directory /var/www/>
  Options Indexes FollowSymLinks Includes ExecCGI
  AllowOverride All
  Order allow,deny
  Allow from all
</Directory>

So, they are the same... Just one more note: I'm using twitter, as you can see. To do this I had to create a twitter application with a URL callback. The thing is, this url is like:

Code:
http://somedomain.co.uk/project/main/login

But I'm running the application localhost, so I added the following lines to my hosts file:

Code:
127.0.0.1       somedomain.co.uk
localhost       somedomain.co.uk

I have the same thing working in the Windows box.

Apache log:
Code:
Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined function view() in /var/www/project/system/application/controllers/main.php on line 28, referer: http://somedomain.co.uk/project/index.php
[Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP Stack trace:, referer: http://somedomain.co.uk/text2tweet/index.php
[Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP   1. {main}() /var/www/project/index.php:0, referer: http://somedomain.co.uk/project/index.php
[Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP   2. require_once() /var/www/project/index.php:115, referer: http://somedomain.co.uk/project/index.php
[Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP   3. call_user_func_array() /var/www/project/system/codeigniter/CodeIgniter.php:236, referer: http://somedomain.co.uk/project/index.php
[Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP   4. main->login() /var/www/project/system/codeigniter/CodeIgniter.php:0, referer: http://somedomain.co.uk/project/index.php

You know what is going on?

Thanks,

Luis Gonçalves
#4

[eluser]n0xie[/eluser]
Code:
Mon Jun 14 10:26:48 2010] [error] [client 127.0.0.1] PHP Fatal error:  Call to undefined function view()
It seems like it doesn't show the view because it the view function doesn't exist. Seems to me like Apache is working fine: the blank page is because of this error. If you turn error reporting on it should display this message instead of giving a blank page. Maybe you should turn on error logging in CI and see what's going on. Seems like something isn't setup right. Are you sure the permissions are set correctly?
#5

[eluser]luisfmgoncalves[/eluser]
Hey man, thanks again.

I figured out what is the problem, but looking for a way to solve it.

Basically I have a desktop computer with windows and a laptop with ubuntu Linux. In both the application is running ok, but when I move the application to the main server (with Linux too) the application have a strange behavior.

And that happens because I'm using Haughins library to get info from twitter and this info comes in json format. In my both computers I get a json response, but in the server, I get the full page (html) as response, and this makes the application with that behavior.

This means that the server donw access to my index.php file? Actually I did this in my application: http://codeigniter.com/wiki/mod_rewrite/

Any suggestions?
#6

[eluser]luisfmgoncalves[/eluser]
Hello again,

I spent the last 5 days trying to make this shit work, and till now nothing... This is the first time such thing happen to me and I'm really desperate...

When I put the files in the server, and after configure all the paths, the application runs. But when I try to do something, nothing works, cause instead of json I'm getting html and I don't know why. And, as I told you before, in my laptop (with linux) and in my desktop (with windows) everything is ok.

One example I have is like:

Code:
&lt;input type="submit" value="" class="search" id="search" name="search" /&gt;
(in a view)

and I'm doing some stuff in jquery:

Code:
(document).ready(function(){
    $('#search').click(function(){
       alert('test');
    });
});
(in .js file)

If I press the button I get the window with 'test', so this means that jquery and my .js file are being loaded (as firebug say).

But if I have the code:

Code:
(document).ready(function(){
    $('#search').click(function(){
       $.post("home/search", {"search": item},
            function(data){
              alert(data);  
            },"json");
    });
});

I'm just trying to call the function search inside home controller.

Im my controller I have just:

Code:
function search(){
   $array = array('result' => 'teste');
   $this->firephp->info($array);
}

But this is never executed.
In Firebug I can see that I'm having a response, but is not what should and the response is in HTML and should be in JSON...

None of you know wtf is going one? I kinds new to CI and I'm tired to try things and till now nothing...

Please help,

Thanks

Luis
#7

[eluser]danmontgomery[/eluser]
It's possible that the "home/search" path is being seen as relative to the current url... I would try changing it to an absolute path to see if the code executes
#8

[eluser]luisfmgoncalves[/eluser]
Hello and thanks for your reply...

I tried that already and the result is exactly the same. I went to folder system/application/controllers, I did a pwd and I got:

Code:
/home/user/domains/somedomain.co.uk/public_html/system/application/controllers

and in the .js file I changed the code to:

Code:
(document).ready(function(){
    $('#search').click(function(){
       $.post("/home/user/domains/somedomain.co.uk/public_html/system/application/controllers/home/search", {"search": item},
            function(data){
              alert(data);  
            },"json");
    });
});

But the result is exactly the same. Sad

Any other suggestions?

Luis
#9

[eluser]danmontgomery[/eluser]
Well, the fact that you're getting exactly the same result with the relative path and an obviously invalid path like the server path just confirms what I was thinking, the problem is an invalid path.

Use the absolute web path, eg. /home/search, or http://www.somedomain.co.uk/home/search

There is a $ before the (document) in your jquery, right?
#10

[eluser]luisfmgoncalves[/eluser]
Hey again, and thanks for your reply.

I was so desperate that what I did was starting to just copy and past the code to the server and see where will fail, and now I know what is wrong.

The problem is with this line:

Code:
$config['uri_protocol']    = "AUTO";

The thing is, to use the Elliot Haughin twitter API, I had to change:

Code:
$config['uri_protocol']    = "AUTO";
$config['permitted_uri_chars'] = 'a-z 0-9~%.:_\-';

to

Code:
$config['uri_protocol']    = "PATH_INFO";
$config['permitted_uri_chars'] = 'a-z? 0-9~%.:_\-';

And when I do that, the application stops working.
So, I suppose this is because some misconfiguration (or something missed) in the apache server, right? Can I change my .htaccess to make this work?

Thanks,

Luis Gonçalves




Theme © iAndrew 2016 - Forum software by © MyBB