How to , and other stuff about linux, photo, php … Another blog just like others on internet

December 11, 2017

Redis can’t save in background

Filed under: Linux — Tags: , , — admin @ 10:53 am

Well I see something in log

[3765] 30 Jan 11:31:10 * 1 changes in 900 seconds. Saving…
[3765] 30 Jan 11:31:10 # Can’t save in background: fork: Cannot allocate memory

To fix this redis error you need to

echo 1 > /proc/sys/vm/overcommit_memory sysctl vm.overcommit_memory=1

 

December 8, 2017

delete large directory containing thousands of files

Filed under: Linux — Tags: , , , , , — admin @ 11:22 am

Well if you try to remove a directory with multiple files rm will take a long time also some load on that server .

One solution is to rsync a empty directory .

mkdir empty_dir
rsync -a –delete empty_dir/ yourdirectory/

Also a perl can be made but the rsync is easy for me to remeber .

Some more information about this you can find here

https://serverfault.com/questions/183821/rm-on-a-directory-with-millions-of-files/328305#328305

 

August 30, 2017

httpd with multiple ssl and password for every key automatically

Filed under: Linux — Tags: , , , , — admin @ 1:19 pm

Well to use this we must use the SSLPassPhraseDialog functionality of httpd Рapache .

Basically into ssl.conf we put this line or modify the existing one into

SSLPassPhraseDialog exec:/path/script

Where script is read/execute only by root.

And the script is

 

#!/bin/perl
$server = $ARGV[0];
#print $server;
if ($server eq ‘www.example.com:443’ || $server eq ‘www.example2.com:443’ ) {
print ‘password one’;
} elsif ($server eq ‘example3.com’) {
print ‘Password two’;
}

 

June 27, 2017

change root password for mysql 5.7 fresh installed

Filed under: Linux — Tags: , , — admin @ 11:35 am

In order to find out actual password you need to grep log file

grep password /var/log/mysqld.log

This will provide you with root password .

After login on your mysql server with

mysql -u root -p

Then you must change root password with

ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘newpassword’;

 

June 14, 2017

apache 2.2 run php as username with fcgid

Filed under: Linux — Tags: , , , — admin @ 12:25 pm

One of my problem is to secure a little websites at least to run as their user and not as apache . In this way if one wordpress is hacked not all website to be modify by that script .

On internet you will find something like this

<IfModule mod_fcgid.c>
MaxRequestLen 15728640
FcgidConnectTimeout 20
SuexecUserGroup username groupname
<Directory /var/www/vhosts/site.com>

Options +ExecCGI
AllowOverride All
AddHandler fcgid-script .php
FCGIWrapper /var/www/wraper/site.com/php-fcgi-starter .php
Order allow,deny
Allow from all
</Directory>
</IfModule>

All is fine in some situation works . However I notice that if you have the php 5.6 installed this won’t work . I try all loglevel debug and other stuff but it simply didn’t start that wraper with that user in process list.

After some more dig I found out that /etc/httpd/conf.d/php.conf is different then on other php version and in this 5.6 that file have a SetHandler .

So the solution is to overwrite again that SetHandler

So in your vhost before add this IfModule you need to add also

<FilesMatch \.php$>
SetHandler None
</FilesMatch>

 

Older Posts »

Powered by WordPress