0

I have installed my ci4 app in /var/www/html/app directory. Then created codeigniter.conf file in /etc/apache2/sites-available directory and wrote below code

 ***

<VirtualHost *:80>
         ServerAdmin admin@myciapp.local
         DocumentRoot /var/www/html/app/public
         ServerName myciapp.local
         <Directory /var/www/html/app/public>
             Options +FollowSymLinks
             AllowOverride All
             Order allow,deny
             allow from all
        </Directory>
        ErrorLog /var/log/apache2/codeigniter-error_log
        CustomLog /var/log/apache2/codeigniter-access_log common
    </VirtualHost>

Next added host 127.0.0.1 myciapp.local run below commands

sudo a2ensite codeigniter
sudo a2enmod rewrite
sudo systemctl restart apache2

Next I set up app.baseurl in .env file as 'http://myciapp.local' and opened same url in browser. It has given error 'SYSTEMPATH/Cache/Handlers/FileHandler.php at line 69' so i given rewrite permission to html and writeable/cache directory with chmod command

before these permission browser was showing error message but now it is showing jus a blank white page. If i remove public from DocumentRoot and Directory directives in config file, it is exposing my folder structure. Now what is next to run my application?

codeigniter-error_log has generated below error log

[Sun Mar 07 00:06:19.268444 2021] [php7:error] [pid 14965] [client 127.0.0.1:33750] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes) in /var/www/html/app/vendor/codeigniter4/framework/system/View/View.php on line 255, referer: http://myciapp.local/

[Sun Mar 07 00:06:19.268840 2021] [php7:error] [pid 14965] [client 127.0.0.1:33750] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 32768 bytes) in /var/www/html/app/vendor/codeigniter4/framework/system/Log/Handlers/FileHandler.php on line 1, referer: http://myciapp.local/

[Sun Mar 07 00:06:19.269053 2021] [php7:error] [pid 14965] [client 127.0.0.1:33750] PHP Fatal error:  Allowed memory size of 134217728 bytes exhausted (tried to allocate 49152 bytes) in Unknown on line 0, referer: http://myciapp.local/
0
1

Your app is trying to use more memory than is available:

Allowed memory size of 134217728 bytes exhausted (tried to allocate 20480 bytes)

134,217,728 bytes is more than 128 MB, which is quite a lot for a PHP page. You'll want to slim down your app. With MVC frameworks like CodeIgniter, the problem often lies with loading data from the database. Don't load everything all the time, just load what you actually need. You'll also want to keep the N+1 problem in mind.

Additionally, you'll want to check all places where your app is handling significant amounts of data - processing images, for example.

4
  • This is accurate. You're exhausting the memory available to PHP on your system. NORMALLY things shouldn't need more than 128MB of space for your average PHP program. – Thomas Ward Mar 6 at 21:32
  • @ThomasWard More accurately, they're exhausting the memory assigned to PHP to use. Technically, they could assign more (if the machine running the app has more available), but 128 MB is quite a lot, as I said. A typical limit might be 32 MB or 64 MB. So it's probably better to track down the "memory hogs" in the app than just throw more memory at it. – Henning Kockerbeck Mar 6 at 21:46
  • Agreed, updated my comment (my diamond helps that). Problem here is various platforms tend to be memory hogs with DB anyways, sometimes even at core programs, and PHP is not exactly the most memory friendly application dev platform out there, depending on what the application is doing. Just my 2 cents. – Thomas Ward Mar 6 at 21:57
  • Thank you all for your comments. Problem was not in database as this codeigniter was fresh install and i had not configured database yet. I just started splitted a big html template into small components and including them in a single view with include function. Problem was in a compenent where I have extended a layout whereas in layout component was not rendered. So once I have removed code for extending layout and start/end sections, problem was solved. – Owais Akber Mar 7 at 21:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.