How to , and other stuff about linux, photo, php … A linux, photography blog. To remember some linux situation, and fix them quickly.

December 8, 2017

centos 7 systemctl restart httpd or other service take long time

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

Well on centos 7 I notice that when I run systemctl restart httpd sometime take a lot of time  to restart it .

After some search I found out that there is a TimeoutStopSec variable that do something like this

“Configures the time to wait for stop. If a service is asked to stop, but does not terminate in the specified time, it will be terminated forcibly via SIGTERM, and after another timeout of equal duration with SIGKILL (see KillMode= in systemd.kill(5)). Takes a unit-less value in seconds, or a time span value such as “5min 20s”. Pass “infinity” to disable the timeout logic. Defaults to DefaultTimeoutStopSec= from the manager configuration file”

So I modify the

/usr/lib/systemd/system/httpd.service and added the

TimeoutStopSec=5

Into it

You need to run systemctl daemon-reload after modify that file

[Service]

TimeoutStopSec=5

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

 

November 2, 2017

Modify .htaccess on wordpress site to move to new domain

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

In order to move the wordpress to new domain you must modify the .htaccess with

 

#Options +FollowSymLinks
RewriteEngine on
RewriteRule ^(.*)$ http://www.newdomain.com$1 [R=301,L]

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’;
}

 

July 5, 2017

Adding trusted root certificates to the server

Filed under: Linux — admin @ 2:11 pm

Linux (Ubuntu, Debian)

Function Method
Add
Copy your CA to dir /usr/local/share/ca-certificates/
Use command: sudo cp foo.crt /usr/local/share/ca-certificates/foo.crt
Update the CA store: sudo update-ca-certificates
Remove
Remove your CA.
Update the CA store: sudo update-ca-certificates –fresh

 

Linux (CentOs 6)

Function Method
Add
Install the ca-certificates package: yum install ca-certificates
Enable the dynamic CA configuration feature: update-ca-trust force-enable
Add it as a new file to /etc/pki/ca-trust/source/anchors/: cp foo.crt /etc/pki/ca-trust/source/anchors/
Use command: update-ca-trust extract

 

Linux (Centos 5)

Add
Append your trusted certificate to file /etc/pki/tls/certs/ca-bundle.crt
cat foo.crt >>/etc/pki/tls/certs/ca-bundle.crt

« Newer PostsOlder Posts »

Powered by WordPress