Monday, June 4, 2012

Configure NTP to Synchronize the system clock: Centos 6



Login as root. Type the following command
[root@homeserver]# yum install ntp
Type on the ntpd service
[root@homeserver]# chkconfig ntpd on

Synchronize the system clock with 0.pool.ntp.org server:
[root@homeserver]# ntpdate pool.ntp.org

Start daemon process:
[root@homeserver]# /etc/init.d/ntpd restart

Sunday, June 3, 2012

Install GD Library For PHP5 On CentOS 6


Install GD Library For PHP5 On CentOS

Note: this article only applies if your current PHP version has been installed by yum. If you custom compiled it from source, this will not work.



Verify PHP as installed by yum

An easy task, using yum. First step, see if it's already installed.
[root@homeserver]# rpm -qa | grep php
php-common-5.1.6-15.el5
php-cli-5.1.6-15.el5
php-5.1.6-15.el5
php-pdo-5.1.6-15.el5
php-mysql-5.1.6-15.el5

Install the GD library using yum

If the GD Library isn't present in that list, it wasn't installed on the server yet. Install it using yum.
[root@homeserver]# yum install php-gd
Loaded plugins: fastestmirror, presto
Loading mirror speeds from cached hostfile
epel/metalink                                                                                                                 | 5.0 kB     00:00     
 * base: ftp.iij.ad.jp
 * epel: ftp.iij.ad.jp
 * extras: ftp.iij.ad.jp
 * updates: ftp.iij.ad.jp
base                                                                                                                          | 3.7 kB     00:00     
extras                                                                                                                        | 3.5 kB     00:00     
updates                                                                                                                       | 3.5 kB     00:00     
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php-gd.x86_64 0:5.3.3-3.el6_2.8 will be installed
--> Processing Dependency: libpng12.so.0(PNG12_0)(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Processing Dependency: libpng12.so.0()(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Processing Dependency: libjpeg.so.62()(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Processing Dependency: libfreetype.so.6()(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Processing Dependency: libXpm.so.4()(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Processing Dependency: libX11.so.6()(64bit) for package: php-gd-5.3.3-3.el6_2.8.x86_64
--> Running transaction check
---> Package freetype.x86_64 0:2.3.11-6.el6_2.9 will be installed
---> Package libX11.x86_64 0:1.3-2.el6 will be installed
--> Processing Dependency: libX11-common = 1.3-2.el6 for package: libX11-1.3-2.el6.x86_64
--> Processing Dependency: libxcb.so.1()(64bit) for package: libX11-1.3-2.el6.x86_64
---> Package libXpm.x86_64 0:3.5.8-2.el6 will be installed
---> Package libjpeg.x86_64 0:6b-46.el6 will be installed
---> Package libpng.x86_64 2:1.2.49-1.el6_2 will be installed
--> Running transaction check
---> Package libX11-common.noarch 0:1.3-2.el6 will be installed
---> Package libxcb.x86_64 0:1.5-1.el6 will be installed
--> Processing Dependency: libXau.so.6()(64bit) for package: libxcb-1.5-1.el6.x86_64
--> Running transaction check
---> Package libXau.x86_64 0:1.0.5-1.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

=====================================================================================================================================================
 Package                               Arch                           Version                                  Repository                       Size
=====================================================================================================================================================
Installing:
 php-gd                                x86_64                         5.3.3-3.el6_2.8                          updates                         104 k
Installing for dependencies:
 freetype                              x86_64                         2.3.11-6.el6_2.9                         updates                         359 k
 libX11                                x86_64                         1.3-2.el6                                base                            582 k
 libX11-common                         noarch                         1.3-2.el6                                base                            188 k
 libXau                                x86_64                         1.0.5-1.el6                              base                             22 k
 libXpm                                x86_64                         3.5.8-2.el6                              base                             59 k
 libjpeg                               x86_64                         6b-46.el6                                base                            134 k
 libpng                                x86_64                         2:1.2.49-1.el6_2                         updates                         182 k
 libxcb                                x86_64                         1.5-1.el6                                base                            100 k

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

Total download size: 1.7 M
Installed size: 5.9 M
Is this ok [y/N]: y
Downloading Packages:
Setting up and reading Presto delta metadata
Processing delta metadata
Package(s) data still to download: 1.7 M
(1/9): freetype-2.3.11-6.el6_2.9.x86_64.rpm  | 359 kB     00:00     
(2/9): libX11-1.3-2.el6.x86_64.rpm           | 582 kB     00:00     
(3/9): libX11-common-1.3-2.el6.noarch.rpm    | 188 kB     00:00     
(4/9): libXau-1.0.5-1.el6.x86_64.rpm         |  22 kB     00:00     
(5/9): libXpm-3.5.8-2.el6.x86_64.rpm         |  59 kB     00:00     
(6/9): libjpeg-6b-46.el6.x86_64.rpm          | 134 kB     00:00     
(7/9): libpng-1.2.49-1.el6_2.x86_64.rpm      | 182 kB     00:00     
(8/9): libxcb-1.5-1.el6.x86_64.rpm           | 100 kB     00:00     
(9/9): php-gd-5.3.3-3.el6_2.8.x86_64.rpm     | 104 kB     00:00     
--------------------------------------------------------------------
Total                                                                                                                736 kB/s | 1.7 MB     00:02     
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : 2:libpng-1.2.49-1.el6_2.x86_64    1/9 
  Installing : libX11-common-1.3-2.el6.noarch    2/9 
  Installing : libXau-1.0.5-1.el6.x86_64         3/9 
  Installing : libxcb-1.5-1.el6.x86_64           4/9 
  Installing : libX11-1.3-2.el6.x86_64           5/9 
  Installing : libXpm-3.5.8-2.el6.x86_64         6/9 
  Installing : libjpeg-6b-46.el6.x86_64          7/9 
  Installing : freetype-2.3.11-6.el6_2.9.x86_64  8/9 
  Installing : php-gd-5.3.3-3.el6_2.8.x86_64     9/9 
Installed:
  php-gd.x86_64 0:5.3.3-3.el6_2.8                                                                                                                    

Dependency Installed:
  freetype.x86_64 0:2.3.11-6.el6_2.9       
  libX11.x86_64 0:1.3-2.el6
  libX11-common.noarch 0:1.3-2.el6
  libXau.x86_64 0:1.0.5-1.el6      
  libXpm.x86_64 0:3.5.8-2.el6 
  libjpeg.x86_64 0:6b-46.el6
  libpng.x86_64 2:1.2.49-1.el6_2  
  libxcb.x86_64 0:1.5-1.el6        

Complete!

Easy going, isn't it?

Restart Lighttpd

Restart your lighted, and you're ready to rock.
[root@srv]# service httpd restart
Stopping lighttpd:                                            [  OK ]
Starting lighttpd:                                            [  OK ]

Saturday, June 2, 2012

Installing SSH2 extension for PHP on Centos 6


Installing the SSH2 PHP extension on CentOS is actually pretty simple. 


Although it isn’t available as a straight yum install, it boils down to a few short steps.


Firstly, we’re going to install the dependencies:
yum install gcc php-devel php-pear libssh2 libssh2-devel

These will allow us to build the SSH2 extension using pecl.
pecl install -f ssh2

After running that command, it should stop at a line like:
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading ssh2-0.11.3.tgz ...
Starting to download ssh2-0.11.3.tgz (23,062 bytes)
........done: 23,062 bytes
5 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
libssh2 prefix? [autodetect] : 

All you have to do is hit Enter and it should detect the proper path. 


Once the install is completed, you just have to tell PHP to load the extension when it boots.
touch /etc/php.d/ssh2.ini
echo extension=ssh2.so > /etc/php.d/ssh2.ini

Now restart your webserver and test to see if the changes took effect.
/etc/init.d/lighttpd restart
php -m | grep ssh2

You should get a line returned with ‘ssh2′.

lighttpd doesn't start - selinux

Lighttpd doesn't start due to a conflict with file descriptors:

Issue
# /etc/init.d/lighttpd restart
Stopping lighttpd:                                         [FAILED]
Starting lighttpd: 2012-06-03 00:57:12: (server.c.722) couldn't set 'max filedescriptors' Permission denied
                                                           [FAILED]

Solution:

Install SE utils

yum install policycoreutils-python
Create SELinux module to allow lighttpd to set its own open file descriptors limit
/usr/sbin/semodule -DB
# /etc/init.d/auditd restart
Stopping auditd:                                           [  OK  ]
Starting auditd:                                           [  OK  ]
#grep lighttpd /var/log/audit/audit.log | audit2allow -M lighttpdmaxfds
#/usr/sbin/semodule -i lighttpdmaxfds.pp 
 # /etc/init.d/lighttpd restart
Stopping lighttpd:                                         [FAILED]
Starting lighttpd:                                         [  OK  ]
# /usr/sbin/semodule -B