Search code examples
phpcodeigniterbitnamiubuntu-serveramazon-lightsail

How to fix Gateway Timeout on AWS Lightsail server?


I have created a codeigniter app on a AWS with Lightsail that queries a large amount of data from an old magento database, converts into a new format, and pushes it to my new database.

The app works well and fine on my local machine under localhost, but when deploying to a AWS, I encounter a Gateway Timeout error. I believe this is because my local server is willing to wait longer for a response from another server than my AWS.

Is there any way to solve this error? Or rather, is there any way I can increase the amount of time my AWS is willing to wait for a response from my server database?

I tried this, but no dice:

set_time_limit(0);
error_reporting(E_ALL);
ob_implicit_flush(TRUE);
ob_end_flush();

I also tried this to no avail:

ini_set('max_execution_time', 0);

Both were placed in the constructor for my model. If either of these solutions do work, was that the wrong place to put the code?

EDIT: I should also mention that this is a Bitnami server running in Ubuntu.


Solution

  • For future generations, you need to edit timeout in the php-fpm-apache.conf. This is on the line

    <Proxy "unix:/opt/bitnami/php/var/run/www.sock|fcgi://www-fpm" timeout=900>
    

    If you don't know where that is, just use

    sudo find / -iname php-fpm-apache.conf
    

    in the console. Mine happened to be located at /opt/bitnami/apache2/conf/

    Be sure to restart apache and php-fpm with

    sudo /opt/bitnami/ctlscript.sh restart php-fpm
    sudo /opt/bitnami/ctlscript.sh restart apache
    

    And you'll be good to go!