Very high ram use in Ubuntu compare to debian

August 11, 2013 7k views
hi. I had a Debian 7x64 server that had some security issues and because I'm more familiar with Ubuntu turned to Ubuntu 12.04x64. both my droplets was 512 and served one WordPress site with apache/mysql In Debian my ram use was basically between 130 and 350 mb and never passed 400mb In Ubuntu my rame use is between 179 and 470 and even swap use more ram is this normal? because the website is new and only have 100 500 visitor/view a day.
14 Answers
I believe Ubuntu uses more RAM than Debian by default. Try switching to nginx instead of apache:
by Etel Sverdlov
This tutorial explains how to install nginx, how to start nginx, and how to confirm that nginx is running on your server. nginx is a high performance web server software. This tutorial is written for Ubuntu 12.04
tnx for your fast response
that's the third year that I uses apache and I'm really familiar with it's security options. nginx will be a new world for me specially with the site is being more popular I can't risk a change.

I checked with Webmin and as u said apache is using 300mb of ram. It's strange because apache is the same in both debian and ubuntu a I think of course
Try switching to and php5-fpm instead of mod_php:
sorry to bother you again and again. you mean to change mpm. and you prefer worker to prefork.
I have two questions. I uses mod_security mod_evasive and headers. are new mpm compatible with this modules?
and second question. what is the difference between event and worker? because as I read event was even faster

sorry again
Event is available only if you're running Apache2.4 which is unlikely. I don't know about mod_evasive but try switching to mpm_worker. If it's not compatible with it, simply revert back to mpm_prefork.
I switched to worker and when I want to visit website it download a php file (as I think index). also before swiching I deactivate mod_security and evasive. the only not default module is headers that I dont think it is a problem,
when I wantet to install worker ubuntu removed 2 packages. one of them was prefork and another one was libapache2-mod-php5 and I think maybe it's the problem.
that's what I did

sudo apt-get install apache2-mpm-worker
sudo a2enmod actions fastcgi alias
sudo service apache2 restart

and I add this to site defaults

AddHandler php5-fcgi .php
Action php5-fcgi /php5-fcgi
Alias /php5-fcgi /usr/lib/cgi-bin/php5-fcgi
FastCgiExternalServer /usr/lib/cgi-bin/php5-fcgi -socket /var/run/php5-fpm.sock -pass-header Authorization
Did you install php5-fpm?

sudo apt-get install php5-fpm

sudo service apache2 restart
yes. I get apache error
error log shows this

[error] [client] (2)No such file or directory: FastCGI: failed to connect to server "/usr/lib/cgi-bin/php5-fcgi": connect() failed
[error] [client] FastCGI: incomplete headers (0 bytes) received from server "/usr/lib/cgi-bin/php5-fcgi"
[error] [client] File does not exist: /var/www/favicon.ico
Make sure php5-fpm is listening on a socket:

nano /etc/php5/fpm/pool.d/www.conf

Look for the listen= directive and make sure it's set to /var/run/php5-fpm.sock

Restart php5-fpm:
sudo service php5-fpm restart
I already did that
and again the apache error
It's strange because I have 2 similar server and one of them is working fine in new settings
:) somehow I'm losing my mind
What's the reason fpm needs to listen on a unix socket not a tcp port?
@forestmars+docker: It does not need to listen on a socket however it is recommended to bind it to a socker instead of a TCP port to avoid TCP overhead and accidentally allowing outer access to php5-fpm.
Thanks, I was getting 500s using tcp that went away after switching to a socket connection.
Have another answer? Share your knowledge.