Member Avatar for iamthwee

So guys I have a vanilla install of code igniter and the thing returns a internal server error 500.

This is only on my linux box. It works in windows xp on a virtual machine but I'd love to have it work on my linux box.

So what do you guys needs to know to help me out?

Hi, check the Apache log files, 5xx errors are related to the server, so it can be a misconfiguration of .htaccess or something related to write permissions.

Member Avatar for iamthwee

Thanks which file do you need?

x@x-Calistoga-ICH7M-Chipset:/var/log/apache2$ ls
access.log    access.log.2.gz  error.log.1     other_vhosts_access.log
access.log.1  error.log        error.log.2.gz

Try with error.log and access.log, the others with the numbers are old logs.

Run:

tail -n 20 error.log

This will display the last 20 lines of that file, if you don't see anything particular, reload the page in the browser. If you need to all the file type:

less error.log

If needed do the same with access.log. Then if you don't find anything browse to /etc/apache2/sites-available/ and open the file configuration of your virtual host, from there you can see if your configuration is saving the errors into another path, the line should look like:

ErrorLog ${APACHE_LOG_DIR}/error.log

You can also try to find if CodeIgniter is generating an error log.

Member Avatar for iamthwee

Thank you sir.

The dump of the error log is as follows:

x@x-Calistoga-ICH7M-Chipset:/var/log/apache2$ tail -n 20 error.log
[Mon Sep 09 23:46:45 2013] [notice] caught SIGTERM, shutting down
[Tue Sep 10 08:05:52 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal operations
[Tue Sep 10 14:54:06 2013] [notice] caught SIGTERM, shutting down
[Tue Sep 10 18:26:42 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal operations
[Tue Sep 10 21:52:51 2013] [notice] caught SIGTERM, shutting down
[Wed Sep 11 22:11:45 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal operations
[Thu Sep 12 00:10:26 2013] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico
[Thu Sep 12 00:10:28 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/var/www/code/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:10:28 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/var/www/code/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:13:51 2013] [error] [client 127.0.0.1] File does not exist: /var/www/favicon.ico, referer: http://localhost/
[Thu Sep 12 00:13:56 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/var/www/code/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:13:56 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/var/www/code/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:14:17 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/var/www/code/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:14:17 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/var/www/code/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/code/index.php on line 202, referer: http://localhost/
[Thu Sep 12 00:18:33 2013] [notice] caught SIGTERM, shutting down
[Thu Sep 12 06:49:57 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal operations
[Thu Sep 12 07:02:52 2013] [notice] caught SIGTERM, shutting down
[Thu Sep 12 17:23:18 2013] [notice] Apache/2.2.22 (Ubuntu) PHP/5.3.10-1ubuntu3.7 with Suhosin-Patch configured -- resuming normal operations
[Thu Sep 12 19:19:30 2013] [error] [client 127.0.0.1] PHP Warning:  require_once(/var/www/code/system/core/CodeIgniter.php): failed to open stream: Permission denied in /var/www/code/index.php on line 202
[Thu Sep 12 19:19:30 2013] [error] [client 127.0.0.1] PHP Fatal error:  require_once(): Failed opening required '/var/www/code/system/core/CodeIgniter.php' (include_path='.:/usr/share/php:/usr/share/pear') in /var/www/code/index.php on line 202
Member Avatar for iamthwee

I have placed my codeigniter file under

/var/www/code

The www folder has full write permissions.

Thanks in advance.

Ok, it seems related to permissions. You should check the user running Apache (usually www-data) and switch the ownership of the files and subdirectories of /var/www/code to it, run this:

ps -aux |grep apache2

to see the user, the parent is root, all the child processes should be owned by www-data or another defined user in /etc/apache2/apache2.conf, and then change the ownership:

sudo chown www-data:www-data -R /var/www/code

If this still does not work, then change the write permissions:

sudo chmod 755 -R /var/www/code

Note that 755 works if the owner of the files is the same user used by Apache, otherwise you need to use 777, which can be fine in a development box, but it is not good in a production server. Hope this helps to solve the problem.

commented: Excellent +14
Member Avatar for iamthwee

Thanks so much :)

sudo chown www-data:www-data -R /var/www/code

Did the trick where 'code' is the name of my codeigniter folder!

You're welcome! :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.