jueves, 3 de septiembre de 2015

How to Install ImageMagick on CentOS, RHEL and Ubuntu http://tecadmin.net/install-imagemagick-on-linux/

ORIGINAL ARTICLE: http://tecadmin.net/install-imagemagick-on-linux/
ImageMagick is a software suite to create, edit, compose, or convert bitmap images. It can read and write images in a variety of formats like GIFJPEGPNGPostscript, and TIFF. We can also use ImageMagick to resizeflip, mirror, rotate, distort, shear and transform images, adjust image colors, apply various special effects, or draw text, lines, polygons, ellipses and Bézier curves.
ImageMagick is typically used from command line. Also we can use it from any programming language by using its interface like Magick.NET (.Net),IMagick (PHP), PerlMagick (Perl) etc.

Step 1. Install Required Packages

First we need to install required packages in order to install ImageMagic and IMagick PHP extension.
For CentOS,RHEL Users:
# yum install gcc php-devel php-pear
For Ubuntu Users:
$ sudo apt-get install gcc

Step 2. Install ImageMagick

After installing required packages, let’s install ImageMagick using following command.
For CentOS,RHEL Users:
# yum install ImageMagick ImageMagick-devel
For Ubuntu Users:
$ sudo apt-get install imagemagick

Step 3. Install ImageMagick PHP Extension

At this point you have successfully installed ImageMagick package on your system. Now are are going to install ImageMagick php extension, So that we can use it through php code.
For CentOS,RHEL Users:
# pecl install imagick
# echo "extension=imagick.so" > /etc/php.d/imagick.ini
For Ubuntu Users:
$ sudo apt-get install php5-imagick

Step 4. Restart Apache and Check Extension

After completing above steps you need to reload apache service to enable php exension using following command
CentOS,RHEL Users:
# service httpd reload

Ubuntu Users:
# service apache2 reload
Click here to read more details about ImageMagick setup and there uses.

-----------------------------

OTRA FORMA http://linuxhostingsupport.net/blog/howto-install-imagemagick-on-plesk

Howto: Install ImageMagick on Plesk

How to install ImageMagick on Linux/Plesk server? Follow the below steps to install ImageMagick on a Plesk server. Login to your server as root and execute the following commands:
1. Install “ImageMagick” package via YUM.
yum install ImageMagick
2. Now install “ImageMagick-devel”
yum install ImageMagick-devel
3. Install “php-pear” required for “pecl”. It will install and compile ImageMagick with PHP for you.
yum install php-pear
4. Now, you need to install ImageMagick using pecl
pecl install imagick
A imagick.so file will be created under /usr/lib/php/modules/ directory. Now, edit the php configuration file /etc/php.ini and add the following line after the “extension_dir” directive
extension = “imagick.so”
Save the file and restart the httpd service. That is it. You can verify using the command:
php -i | grep imagick

How to globally disable X-Powered-By:PleskLin http://forum.odin.com/threads/how-to-globally-disable-x-powered-by-plesklin.333735/#post-782850

ORIGINAL ARTICLE http://forum.odin.com/threads/how-to-globally-disable-x-powered-by-plesklin.333735/#post-782850

Hi Hayk,

the "correct" usage would be:
  1. Create a folder called "custom" at "/usr/local/psa/admin/conf/templates/", so that you have a custom "custom" directory for your unique modifications ( => /usr/local/psa/admin/conf/templates/custom ).
  2. Create a folder called "domain" at "/usr/local/psa/admin/conf/templates/custom/", so that you have a custom "domain" directory for your unique modifications ( => /usr/local/psa/admin/conf/templates/custom/domain ).
  3. Copy the desired template(s) to the "custom" folder
    1. Command over the command line:
      Code:
      cp /usr/local/psa/admin/conf/templates/default/server.php /usr/local/psa/admin/conf/templates/custom/server.php
    2. Command over the command line:
      Code:
      cp /usr/local/psa/admin/conf/templates/default/domain/nginxDomainVirtualHost.php /usr/local/psa/admin/conf/templates/custom/domain/nginxDomainVirtualHost.php
  4. Delete / edit or modify the part of .../custom/server.php :
    Code:
    <IfModule mod_headers.c>
        Header add X-Powered-By PleskLin
    </IfModule>
  5. Delete / edit or modify the part of .../custom/domain/nginxDomainVirtualHost.php :
    Code:
    <?php if (!$VAR->domain->physicalHosting->proxySettings['nginxTransparentMode'] && !$VAR->domain->physicalHosting->proxySettings['nginxServeStatic']): ?>
        location /internal-nginx-static-location/ {
            alias <?php echo $OPT['documentRoot'] ?>/;
            add_header X-Powered-By PleskLin;
            internal;
        }    
  • Reconfigure your webserver with the command:
    Code:
    /usr/local/psa/admin/sbin/httpdmng --reconfigure-all
  • Smile to the camera and say: Cheeeeeeeeese :D

In some rare cases, you have to restart apache and nginx manually, even that the reconfigure-command includes the restarts of the two services.

How to install Apache mod_pagespeed on CentOS with Plesk http://wpguru.co.uk/2014/03/how-to-install-apache-mod_pagespeed-on-centos-with-plesk/

ORIGINAL ARTICLE: http://wpguru.co.uk/2014/03/how-to-install-apache-mod_pagespeed-on-centos-with-plesk/

I bumped into Kristian Markroft from Simplyroot in New Orleans last week, and he told me about an interesting speed-up module for the Apache Webserver.
mod_pagespeed is an open source project which speeds up page loads without having to change the code of the actual page. mod_pagespeed does this by adding filters before pages are served. For example it will resize images and minify CSS/JS files, which can speed up page load considerably. The project is hosted on Google Code:
Let’s see how we can install it on CentOS, test to see if it works and how to manage it in Plesk.

Installing mod_pagespeed

The easiest way to install the module is by pulling the pre-built packages via yum from Google. For this we need to add a new source for yum to access. This source only contains the mod_pagespeed module, none of your other packages will be affected (even when you casually yum update your server).
Let’s add it by creating the following file:
vi /etc/yum.repos.d/google-mod-pagespeed.repo
Add the following code block to it:
[google-mod-pagespeed]
name=google-mod-pagespeed
baseurl=http://dl.google.com/linux/mod-pagespeed/rpm/stable/$basearch
enabled=1
gpgcheck=0
In case you’re not familiar with vi: hit a to enter edit mode, paste your code, hit escape followed by shift-Z-Z to save and exit.
Now we can install the module:
yum install mod-pagespeed

================================================================================
 Package              Arch     Version             Repository              Size
================================================================================
Installing:
 mod-pagespeed-beta   x86_64   1.7.30.3-3721       google-mod-pagespeed   5.0 M
Installing for dependencies:
 at                   x86_64   3.1.10-43.el6_2.1   base                    60 k

Transaction Summary
================================================================================
Install       2 Package(s)

Total download size: 5.0 M
Installed size: 13 M
Is this ok [y/N]: y
Downloading Packages:
(1/2): at-3.1.10-43.el6_2.1.x86_64.rpm                   |  60 kB     00:00     
(2/2): mod-pagespeed-beta-1.7.30.3-3721.x86_64.rpm       | 5.0 MB     00:01     
--------------------------------------------------------------------------------
Total                                           2.4 MB/s | 5.0 MB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : at-3.1.10-43.el6_2.1.x86_64                                  1/2 
  Installing : mod-pagespeed-beta-1.7.30.3-3721.x86_64                      2/2 
Starting atd: [  OK  ]
job 1 at 2014-03-04 10:16
  Verifying  : at-3.1.10-43.el6_2.1.x86_64                                  1/2 
  Verifying  : mod-pagespeed-beta-1.7.30.3-3721.x86_64                      2/2 

Installed:
  mod-pagespeed-beta.x86_64 0:1.7.30.3-3721                                     

Dependency Installed:
  at.x86_64 0:3.1.10-43.el6_2.1                                                 

Complete!
Nice. Now restart Apache for the changes to take effect:
service httpd restart
Thanks to Rahul Kumar for explaining this procedure here: http://tecadmin.net/installing-mod_pagespeed-module-apache/

Verify that mod_pagewrite is working

The easiest way to do this is not from a web browser but from the command line. We’ll load a website and inspect the header information:
curl -D- http://example.com | head -10

TP/1.1 200 OK
Server: nginx
Date: Tue, 04 Mar 2014 14:20:41 GMT
Content-Type: text/html; charset=UTF-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Cookie,Accept-Encoding
X-Pingback: http://example.com/xmlrpc.php
X-Mod-Pagespeed: 1.7.30.3-3721
The last line tells us that mod_pagespeed was indeed involved and is working fine. Needless to say, please replace example.com with the website you’d like to test.

Managing mod_pagespeed

If yo’d like to turn the module off or on again, and you’re using Plesk, it’s as simple as (un-)ticking a box: head over to Tools and Settings (or Server if you’re using Power User View), click Apache Modules and find two new modules in the large list:
  • pagespeed (ticked after installation)
  • pagespeed_ap24
Screen Shot 2014-03-04 at 09.37.58
The latter is for Apache 2.4 which will only start if you actually have Apache 2.4 installed. If you’re running Apache 2.2 then the first module is for you and you’ll receive an error message should you try to start the other one.
If you are not using Plesk, or you prefer a more “bare bones command line” approach you can tweak the mod_pagespeed configuration file which lives in /etc/httpd/conf.d/pagespeed.conf:
vi /etc/httpd/conf.d/pagespeed.conf

<IfModule pagespeed_module>
    # Turn on mod_pagespeed. To completely disable mod_pagespeed, you
    # can set this to "off".
    ModPagespeed on

...
Simply change that line to ModPagespeed off, save the file and restart Apache.

Removing mod_pagespeed

To remove the module completely, erase the package and remove the extra yum source:
yum erase mod-pagespeed
rm /etc/yum.repos.d/google-mode-pagespeed.repo
It’s like it never happened 😉
A small caveat to using mod_pagespeed is that changes to your website’s CSS do not show up immediately due to internal caching. Therefore I don’t recommend it on development sites as it gets in the way of actual results.

Further Reading

INSTALL NGINX PAGESPEED Build ngx_pagespeed From Source https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source

ORIGINAL ARTICLE https://developers.google.com/speed/pagespeed/module/build_ngx_pagespeed_from_source

To install our dependencies, run:
RedHat, CentOS, or Fedora
sudo yum install gcc-c++ pcre-devel zlib-devel make unzip
Ubuntu or Debian
sudo apt-get install build-essential zlib1g-dev libpcre3 libpcre3-dev unzip
Then download ngx_pagespeed:
cd NPS_VERSION=1.9.32.6 wget https://github.com/pagespeed/ngx_pagespeed/archive/release-${NPS_VERSION}-beta.zip unzip release-${NPS_VERSION}-beta.zip cd ngx_pagespeed-release-${NPS_VERSION}-beta/ wget https://dl.google.com/dl/page-speed/psol/${NPS_VERSION}.tar.gz tar -xzvf ${NPS_VERSION}.tar.gz  # extracts to psol/
Download and build nginx with support for pagespeed:
cd# check http://nginx.org/en/download.html for the latest version NGINX_VERSION=1.8.0 wget http://nginx.org/download/nginx-${NGINX_VERSION}.tar.gz tar -xvzf nginx-${NGINX_VERSION}.tar.gz cd nginx-${NGINX_VERSION}/ ./configure --add-module=$HOME/ngx_pagespeed-release-${NPS_VERSION}-beta make sudo make install
VERY IMPORTANT: To compile Nginx with the same “modules” that the Nginx plesk, execute “nginx -V” to see what parameters put.

How to make Linux automatically reboot after a kernel panic? http://ask.systutorials.com/1436/how-to-make-linux-automatically-reboot-after-a-kernel-panic

ORIGINAL ARTICLE http://ask.systutorials.com/1436/how-to-make-linux-automatically-reboot-after-a-kernel-panic

Linux kernel has a nice feature that reboots itself after a timeout when a kernel panic happened.
Usually, it is disabled by default. To turn it on, you can set thekernel.panic kernel parameter.
For a running system:
# echo 20 >/proc/sys/kernel/panic
Here, 20 is the number of seconds before the kernel reboots. 0 means the feature is disabled.
To make the configuration persistent, you have 2 choices:
  1. add the kernel parameter panic=20 to your bootloader (grub or grub2).
  2. add kernel.panic = 20 to /etc/sysctl.conf .
After you enabled the auto reboot after kernel panic, you may need to check the uptime and logs or create a @reboot cron jobs to send emails or use some other mechanisms to know that there was a auto reboot caused by a kernel panic.

Linux x86_64: Detecting Hardware Errors http://www.cyberciti.biz/tips/linux-server-predicting-hardware-failure.html

ORIGINAL ARTICLE: http://www.cyberciti.biz/tips/linux-server-predicting-hardware-failure.html

I copy the article on the link below to spread the word in case of dissapear.

The Blue Screen of Death (BSoD) is used by Microsoft Windows, after encountering a critical system error. Linux / UNIX like operating system may get a kernel panic. It is just like BSoD. The BSoD and a kernel panic generated using a Machine Check Exception (MCE). MCE is nothing but feature of AMD / Intel 64 bit systems which is used to detect an unrecoverable hardware problem. MCE can detect:
  • Communication error between CPU and motherboard.
  • Memory error - ECC problems.
  • CPU cache errors and so on.

Program such mcelog decodes machine check events (hardware errors) on x86-64 machines running a 64-bit Linux kernel. It should be run regularly as a cron job on any x86-64 Linux system. This is useful for predicting server hardware failure before actual server crash.

Install mcelog

Type the following command under RHEL / CentOS / Fedora Linux, 64 bit kernel:
yum install mcelog
Type the following command under Debian / Ubuntu Linux, 64 bit kernel:
apt-get update && apt-get install mcelog

Default Cronjob

mcelog should be run regularly as a cron job on any x86-64 Linux system. By default followingcron settings are used on Debian / Ubuntu Linux - /etc/cron.d/mcelog:
# /etc/cron.d/mcelog: crontab entry for the mcelog package
SHELL=/bin/sh
PATH=/sbin:/bin:/usr/sbin:/usr/bin
 
*/5 * * * * root test -x /usr/sbin/mcelog -a ! -e /etc/mcelog-disabled && /usr/sbin/mcelog --ignorenodev --filter >> /var/log/mcelog
CentOS / RHEL / Fedora Linux runs hourly cron job via /etc/cron.hourly/mcelog.cron:
#!/bin/bash
/usr/sbin/mcelog --ignorenodev --filter >> /var/log/mcelog

How do I view error logs?

Use tail or grep command:
# tail -f /var/log/mcelog
OR
# grep -i "hardware error" /var/log/mcelog
OR
# grep -c "hardware error" /var/log/mcelog
Alternatively, you can send an email alert when hardware error found on the system (write a shell script and call it via cron job):
# [ $(grep -c "hardware error" /var/log/mcelog) -gt 0 ] && echo "Hardware Error Found $(hostname) @ $(date)" | mail -s 'H/w Error' pager@example.com
With this tool I was able to pick up couple of hardware problem before a kernel panic i.e. server crash.

A Note About mcelog

  • You need to use 64 bit Linux kernel and operating system to run mcelog. Machine checks can indicate failing hardware, system overheats, bad DIMMs or other problems. Some MCEs are fatal and can not generally be survived without reboot and h/w replacement, but I was able to catch lots of bad h/w before crash with this tool.
  • mcat - A Windows command-line program from AMD to decode MCEs from AMD K8, Family 0x10 and 0x11 processors.
  • mcelog project home page.
  • mcedaemon - a daemonthat can get MCE notifications as soon as the kernel finds them. It does not try to interpret the MCE data, just alert other apps.
  • Linux Kernel panic source code.
  • man mcelog
  • Machine check exception support information for MS-Windows server 2003 and XP operating systems.