Hello, I have a problem on my CentOS 6.5 server related to phpmyadmin.
If I click on Export (not for a particular database, but for all the databases) I get a 500 error, which translated into this error in the Apache log:
PHP Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 256 bytes) in /var/www/html/phpmyadmin/libraries/dbi/DBIMysqli.class.php on line 299
I have tried increasing memory limit up to 512MB in php.ini, but I keep getting this error after restarting apache.
I have also updated phpmyadmin to the latest version my php version allows, but I still get the error.
There are no errors listed in phpmyadmin home page, the configuration should be ok.
Versions: phpmyadmin 4.4.15.10, php 5.4.45, mysql 5.5.48
I managed to export the databases from the command line, so that's no problem, but I'd like to get rid of this error.
There is a ton of php scripts running on the server, but the only memory error I get is this one.
Does anyone have any suggestion?
LinuxPHP* CentOSMySQL ServerApache Web Server
Last Comment
arnold
8/22/2022 - Mon
arnold
The issue is a restriction by Apache not php. Apache or the OS is preventing or unable to allocate the additional memory phpmyadmin needs or needed by MySQL to respond to the query you have.
Yes, it's the correct php.ini, I've edited it many times before actually.
About the resources, I don't see anything wrong.
top shows very few resources being used, and this is vmstat's output:
Daniele Brunengo
ASKER
About the <?php ini_set("memory_limit", "512M"); ?>, I could do that but I'd have to modify a phpmyadmin core file. I'd rather understand the reason behind this error.
arnold
How much memory does your system have? What is the swap set to? Looks like 16GB
Lets try a different way to achieve what you want without the use of export from phpmyadmin which you already have done.
Either export a db at a time using phpmyadmin . I suspect the issue is a combination that includes MySQL db and that might be the cause of the .........
I.e. If you choose two DBS presuming you have more than two,
If this is the case it may be overriding your php.ini.
Daniele Brunengo
ASKER
Swap and memory are 16GB.
I have already exported via command line, my aim here is not to export databases but to understand the reason for the error and, most of all, if I should be worried or not.
Let's remember that the error comes up as soon as I click on the export tab. I don't even get to the export button, because I can't load the page.
I will try to export each database anyway, to see if there's a particular database causing problems. I have A TON of them.
Also consider adjusting the max_execution_time variable?
Daniele Brunengo
ASKER
Yeah, I have another server and I can also replicate it on local.
I'll try out your new suggestions as soon as I get respite from work.
I had thought about the .htaccess, but wouldn't that need a full url pointing to phpmyadmin? Right now I only access it using my server's IP, for security reasons mostly.
Chris Jones
.htaccess shouldn't be dependant on URL in the sense that you're suggesting unless you are specifying domains.
But to make .htaccess work I usually create a file in /etc/httpd/sites-available (and then link it in sites-enabled) where I tell Apache to let that particular folder, associated with an url, override stuff with .htaccess.
Can I do this with a folder that's not associated with an url, too? Never tried that.
Chris Jones
At the moment you're just running off 000-default?
I think it should still work, but honestly I haven't tried. If I understand correctly the topology you have I think it should function by default.
I can't offer any guarantees though :)
Daniele Brunengo
ASKER
This is a sample virtual host I'm using:
<VirtualHost *:80> ServerName www.example.it ServerAlias example.it DocumentRoot /var/www/html/example/ <Directory /> Options FollowSymLinks AllowOverride None Order Deny,Allow Deny from All </Directory> <Directory /var/www/html/example/> Options -Indexes FollowSymLinks MultiViews AllowOverride All Order allow,deny allow from all </Directory></VirtualHost>
You can have the entry and it will gave no impact.
The htaccess tells Apache how to behave in regards to php meaning Apache which is the overseer of all items running under it, Apache httpd child processes are the ones that spawn php they are the ones that restrict the amount of space ...
Let's try it this way, you ave an office manager (Apache httpd)
Comes tenant one and asks for an office with a space of 600k. The office is allocated
Comes tenant 2 (php) asking for 135MB, there are no offices of that size, so the request is declined.
tenant 2 goes to office owner, (the asker) , saying they need the space. Office owner tells the office manager whenever tenant 2 or anyone like tenant 2 was larger space office, make appropriate adjustments to provide the office space"
After this directive the office manager makes the requisite adjustment to provide the space requested.
With this directive, if you have a php page with a runaway query, as much memory upto 512MB will ve allocated to the process while before as phpmyadmin that page would have been terminated once the memory resources it needed reached 128MB or there a about.
Chris Jones
So what solution would you have implemented? Perhaps the user would be better off with an apache based answer.
I'm assuming we're not talking about recompilation of apache pre-fork/worker type low level solution?
arnold
The solution you provided with the link, combines the various settings.
the htaccess directive is processed by apache and passed to php it launches to handle the page.
since the asker made an attempt to update the php.ini
memory_limit=512MB from the default 128MB (original crash reference) that is usually set and it did not resolve the issue, but the .htaccess with a memory allocation adjustment did. .......
not clear why the change did not take effect, while the .htaccess change whicih is passed on access when a php process is started ......
Yes, that last thing remains unclear. I'll check out some other configuration files to see if I can understand it, but I'll need to have time. The original problem is fixed though. I'll post here any new information I get about this.
arnold
The .htaccess php_value overrides php.ini set parameters, this suggests that Apache may have a default restriction somewhere within its configuration
One option to test
Create a single page
<?php
Phpinfo();
?>
place this file anywhere and see what info it includes on memory_limits compared to this file located within the phpmyadmin location.
I.e. Since Apache passes arguments/parameters/environment variables to the PHP that it starts when needed which overrides the php.ini set parameter.
Daniele Brunengo
ASKER
Actually, I found out that the php.ini being used has been different since I installed a web application in april.
In my original post, I suggested you did "php --ini", but you indicated when you did that the ini file was normal. Had this value changed since then, or was this an oversight?
Daniele Brunengo
ASKER
No, actually this is php --ini output, which is different from the above:
Great, hopefully that will give you some insight :)
If you want to only check the directories you have concern with right now then you can just run the find command again but with /var/www/html changed to the base directory of your issue :)
arnold
when hosting multiple le sites, what is your setup consist of?
do you have a general standard httpd.conf with each site has its own domain.conf in the /etc/httpd/conf.d/ folder
usually, you would not place hosted sites in the /var/www/html which is the default site.
often to make the option available to access a site while the domain is registered transfer, part of your individual site conf file by including an <alias definition thast would use something akin to a customer ID under the root ...
This type of setup might prevent issues down the road where an app installed for one client, impacts all others if it makes changes to the main httpd.conf file.
Daniele Brunengo
ASKER
I have a single conf file for each website. I'm using the sites available and sites enabled folders to store each website configuration.
Each file points to a different subfolder under the /var/www/html folder. I've been working like this for years, actually.
Though I have not seen an install of a web app i.e. CMS wordpress, jango, joomla, etc. that or a client app as you have...
I would make sure that the source of the redirect of the php.ini to a control by a client or within the web path as it can be abused...
Daniele Brunengo
ASKER
No, actually you create a file for each domain and have each domain point to a different folder.
You can find a summary of the setup here. It's for Centos 7, but it's basically the same for Centos 6.5.
Since you mentioned that the php.ini was running via an application you installed, it might be worth either sharing the name of the application with us, or doing your own quick Google search to see if you can bring up any results indicating others being presented with the same issue?
It was in the app virtualhost file. I was positive this would have worked for the application only, looks like I was dead wrong.
But really, shouldn't this work just for that application? Shouldn't all the others be using /etc/php.ini?
arnold
Where was it it defined as part of the virtualHost S its own somesite.conf in /etc/httpd/conf.d or it is ...
Httpd.conf includes /etc/httpd/conf.d/*.conf
Where the PHPINIDir is within the
<virtualHost>
PHPINIDIr
</virtualHost>
If it is outside that block I think it applies to all no matter in which .conf file it is.
Since the .htaccess add the directive to use that phpconfig should be within the location where the app is.
As .htaccess proved, settings applied to Apache override system settings.
I've not gone through the site/info, I based on your experience, it does not seem that they expect that their web based app will be installed on a server that has multiple sites.
Chris Jones
Always satisfying to hear something like that being identified! :)
It is inside the virtualhost file which connects the domain name for the application with the folder containing the app itself (which is the same folder with the rogue php.ini). The file itself is in the sites-enabled folder, like every other virtualhost in use on the server.
I will try to remove that voice from the virtualhost file and put it in an htaccess file inside the folder where the app resides.
Daniele Brunengo
ASKER
Sorry, sites-available. The sites-enabled folder contains only links.
arnold
The distinction deals with whether the entry is
#exposed and is set on the Apache top level
PHPINDir
<virtualHost >
ServerName somesite
</virtualHost>
Or
Confined to the virtual host parameter
<virtualHost >
ServerName somesite
PHPINDir
</virtualHost>
You can make the change above, and run apachectl configtest
It will report if there are syntax error in the config versus restarting Apache and discovering the conflict.
What are the resources on your system?
Top -n 1
Vmstat
.