0
votes

I have searched for hosting codeigniter app on AWS but i didn't find any solution. So I have tried uploading it on AWS using elastic beanstalk. but I'm getting error 404:- the page you requested not found when i try to access it.

Elastic beanstalk comfiguration:- 64bit Amazon Linux 2017.03 v2.4.1 running PHP 7.0

document root under software configuration:- /cieg (name of my codeigniter app is cieg)

here is my config.php

$config['base_url'] = 'http://ciegforum-env.p5fjm8jgtw.ap-south-1.elasticbeanstalk.com/';
$config['index_page'] = '';
$config['uri_protocol'] = 'REQUEST_URI';

here is my routes.php

$route['default_controller'] = 'dashboardC';
$route['404_override'] = '';
$route['translate_uri_dashes'] = FALSE;

here is my .htaccess

RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php/$1 [L]

Things i have tried are following;

changing base_url to blank , removing slash present at end, adding app name at the end (that is http://ciegxxxxx.com/cieg)

changing uri_protocol to auto,

removing .htaccess and trying to access normally through index.php

I'm deploying application on server for first time and this application works fine on localhost.

Sorry for my english

2
have you enabled incoming and outgoing request on to the public IP from AWS console? You also need to configure Security Groups for the instance. - Himanshu Upadhyay
@HimanshuUpadhyay I solved this problem. The error is because of first letter of name of controller file is in small case. It should be in capital. thank you for your reply. But now I'm facing problem as follows SQLSTATE[HY000] [2002] php_network_getaddresses: getaddrinfo failed: Name or service not known Do you know the reason behind this? - Scorpionk
Your database connection configuration is not proper. Check database.php file or if you are using .env file for environment variables, check the values in it. - Himanshu Upadhyay
@HimanshuUpadhyay I'm using PDO for php query. I haven't used any .env file. Environment ariables are configured in elastic beanstalk software configuration. In this comment i'm unable to post my database file i will post dsn part of it. 'dsn' => 'mysql:host="'.$_SERVER['RDS_HOSTNAME'].'"; dbname="'.$_SERVER['RDS_DBNAME'].'"; port="'.$_SERVER['RDS_PORT'].'";charset=utf8;', - Scorpionk

2 Answers

0
votes

Finally, I found the solution to this problem. The only mistake was controller's name starting with a small letter. On AWS the rules are strict. You should name your every controller starting with a capital letter only.

$route['default_controller'] = 'dashboardC';

the above statement was giving problem. it should be like this

$route['default_controller'] = 'DashboardC';

also you should rename your all controller's file by capitalizing first letter.

0
votes

I had the same problem. My problem was that there were unnecessary files in deployment my zip therefore after I deleted every file and folder except index.php application and system. Then zip them again and uploaded. Now it is working. B