Codeignign source page and error 500 in apache log?

Yesterday I spent more than 5 hours trying to figure out what happened to my setup. In the ci213 / application / controllers and views directories, I have a simple site.php and test.php controller. I do not understand why this site is not loading. Anyone have any suggestions on what I could look for next? Maybe it works correctly? If I could improve log errors, with which I could work more.

I decided that this should be something with codeigniter, since I have index.php and index.html in apache root (/ var / www), as well as index2.php on root sites (/ var / www / vhosts / srp-local / htdocs) when I go to localhost / index. (php | html) or srp-local / index2.php, pages load and display correctly, so php and apache work.

Trying to load the site, I get a blank page, so I decided that it should be something with CI. I close all log files, and the only one who receives the update is access.log with the following error.

127.0.0.1 - - [23/Mar/2013:09:00:28 -0600] "GET / HTTP/1.1" 500 381 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:19.0) Gecko/20100101 Firefox/19.0" 

config.php

 $config['base_url'] = 'http://srp-local/'; # My hosts file is configured for this. $config['log_threshold'] = 4; $config['log_path'] = '/var/www/vhosts/srp-local/logs/ci_error.log'; 

Controllers / site.php

 <?php if ( ! defined('BASEPATH')) exit('No direct script access allowed'); class Site extends CI_Controller { public function index() { $this->load->view('test'); } } 

view / test.php

 <html> <head> </head> <body> <?php echo "PHP is working and the 'test' view was loaded"; ?> </body> </html> 

Apache root

 /var/www/vhosts $ ll drwxrwsr-x 6 krizzo www-data 4096 Mar 22 10:45 it355 drwxrwsr-x 6 krizzo www-data 4096 Mar 22 17:45 srp-local 

htdocs is webroot for srp-local, and index.php refers to the ci213 folder.

 /var/www/vhosts $ ll srp-local/ drwxrwsr-x 2 krizzo www-data 4096 Mar 22 17:06 cgi-bin drwxrwsr-x 4 krizzo www-data 4096 Mar 22 17:14 ci213 drwxrwsr-x 2 krizzo www-data 4096 Mar 22 17:19 logs drwxrwsr-x 5 krizzo www-data 4096 Mar 22 17:26 htdocs 

All log locations / permissions

 /var/log/apache2/ -rw-rw-rw- 1 www-data adm 0 Mar 23 08:52 php_errors.log -rw-r----- 1 root adm 12191 Mar 23 09:32 access.log -rw-r----- 1 root adm 4858 Mar 23 09:32 error.log /var/www/vhosts/srp-local/logs/ -rw-r--r-- 1 root www-data 3227 Mar 22 19:42 error.log -rw-rw-r-- 1 krizzo www-data 0 Mar 23 09:37 ci_error.log -rw-r--r-- 1 root www-data 12983 Mar 23 09:38 access.log 

Php.ini file settings

 error_reporting = E_ALL & ~E_DEPRECATED log_errors = On error_log = /var/log/apache2/php_errors.log 
+6
source share
7 answers

I finally found what was pointing me in the right direction. These two posts mentioned how CI uses @ in the database module, which may be the cause of this problem.

php returns 500 errors but no error log
CodeIgniter Project Loads Blank Web Page

I turned off the automatic loading of the database module, and the site is working. Now I just need to find out the database error that I am getting, which could lead to a CI failure. I will update this answer when I find out.

Update: I checked the account / password and access to the database, everything worked. The problem was that the php mysql driver was not installed. This is my first time I really used the Ubuntu system, and I thought that the mysql driver would be installed with the default php package, which I was wrong about.

After installing php5-mysqlnd and turning on the database library in CI startup, everything works correctly. The fact that I did not get any errors really makes me consider changing the frameworks.

+9
source

Doing this, just in case, it will help someone ... If you are on a shared hosting platform and do not have access to directories other than where you should place your files: the trick was to make php throw all errors even if apache failed.

Open "index.php", which is located in the root folder of your codeigniter installation;

 define('ENVIRONMENT', 'development'); if (defined('ENVIRONMENT')) { switch (ENVIRONMENT) { case 'development': error_reporting(E_ALL); /*added line below*/ ini_set('display_errors', '1'); break; ...... 

The implementation of the above change immediately began to show what was wrong with the code, and I was able to fix it and start and run.

Remember to indicate that your codeigniter environment is β€œproduction” as soon as you commit.

+3
source

Here is another reason why errors may not be visible:

I had the same problem. In my case, I copied the source from the production environment. Therefore, the ENVIRONMENT variable defined in index.php was set to 'production' . This made error_reporting set to 0 (no registration). Just set it to 'development' and you should start seeing error messages in the apache log.

It turned out that 500 due to the lack of a colon in the database configuration :-)

+2
source

In my case (basket class) it was a url question, look

 /var/log/apache2/error.log 

if you have something like

 [client 127.0.0.1] File does not exist: ... 

Then you must prefix your class name with '/index.php/' as follows

 http://localhost/codeigniter/index.php/cart 
0
source

I also struggled with this problem.

On my new server, I did not have the php mb_string module php mb_string .

yum install php-mbstring and then service httpd restart

0
source

in my case, the error did not appear because the display errors in the php setup were not set to the active state. After setting it to the active php error, a problem was displayed that caused the 500 error.
Display error

0
source

I checked the php version that was 7.0.xx, so I downgraded to php 5.6.xx and used the following steps to get it working for me.

 sudo a2dismod proxy_fcgi proxy; sudo service apache2 restart sudo add-apt-repository ppa:ondrej/php sudo apt-get update sudo apt-get install php7.0 php5.6 php5.6-mysql php-gettext php5.6-mbstring php-mbstring php7.0-mbstring php-xdebug libapache2-mod-php5.6 libapache2-mod-php7.0 
0
source

All Articles