Install PHP Ioncube loader Linux

Howto install PHP Ioncube loader Linux.

Download the ioncube loader to your server.

x86 (32 bit).

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz

x86_64 (64 bit).

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz

Extract the archive.

tar -zxf your-archive.tar.gz

Install the Ioncube loader PHP module.

x86 (32 bit).

cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib/php/modules/

x86_64 (64 bit).

cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib64/php/modules/

Add the Ioncube loader to the PHP configuration.

x86 (32 bit).

echo “zend_extension=/usr/lib/php/modules/ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini

x86_64 (64 bit).

echo “zend_extension=/usr/lib64/php/modules/ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini

Restart Apache.

service httpd restart

The Ioncube loader is now installed.

[root@linserv01 ~]# php -v
PHP 5.3.3 (cli) (built: Feb 2 2012 18:29:52)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies
with the ionCube PHP Loader v4.0.12, Copyright (c) 2002-2011, by ionCube Ltd.

Other versions of the Ioncube loader can be found in the downloads section.

 

Linux, PHP, Virtual & Dedicated Servers , , ,

Recover Plesk password Linux

If you have forgotten your Plesk admin login, heres how to recover Plesk password.

Plesk 9 password recovery.

cat /etc/psa/.psa.shadow

Plesk 10 password recovery.

/usr/local/psa/bin/admin --show-password

 

Linux, Plesk Linux, Virtual & Dedicated Servers , , , ,

Hyper V clock drift Linux

Hyper V clock drift issues Linux fix.

A fix if your Linux virtual machine clock is loosing time sync, using Programmable Interrupt Timer.

Modify the grub boot options.

nano -w /boot/grub/grub.conf

Look for the boot options for the kernel your using.

title CentOS (2.6.18-274.17.1.el5)
root (hd0,0)
kernel /vmlinuz-2.6.18-274.17.1.el5 ro root=/dev/VolGroup00/LogVol00 ide0=noprobe ide1=noprobe noacpi  hda=noprobe hdb=noprobe
initrd /initrd-2.6.18-274.17.1.el5.img

Look for the kernel boot line (will look similar but not exact to the example).

kernel /vmlinuz-2.6.18-274.17.1.el5 ro root=/dev/VolGroup00/LogVol00 ide0=noprobe ide1=noprobe noacpi hda=noprobe hdb=noprobe

add,

notsc divider=10 clock=pit

kernel /vmlinuz-2.6.18-274.17.1.el5 ro root=/dev/VolGroup00/LogVol00 ide0=noprobe ide1=noprobe noacpi hda=noprobe hdb=noprobe notsc divider=10 clock=pit

 

Press ctrl+x to exit and save.

Reboot the machine to boot the kernel with the updated instructions.

Whenever the kernel is updated you will need to modify /boot/grub/grub.conf for the new kernel.

 

Linux, Virtual & Dedicated Servers, Windows , , , , ,

Bash scripting tutorial. Bash scripting introduction Hello World!

Bash scripting tutorial 1.

One of the most powerful tools to have as a Linux administrator is BASH scripting.

Example 1 Simple Hello World!

Create the script using a text editor of your choice, will use nano in this instance.

nano -w hello-world.sh

To execute the script

./hello-world.sh

The numbers in brackets are to denote the explanation but don’t include these in the script.

Code

#!/bin/bash    (01)

echo Hello World    (02)

1. Defines the shell the script is using.

2. Echo outputs what is inputted after it to stdout (standard output/what is outputted to the terminal)

Example 2 Hello you, using hard coded variable.

Code

#!/bin/bash     (01)

name=User    (02)

echo Hi $name Im Bash    (03)

1. Defines the shell the script is using.

2. Sets the variable $name to User

3. Echo displays whats inputted after, in this case the Hi string and the variable we set earlier $name

Example 3 Hello You, using a variable set by input from stdin (standard input/what you type in the terminal)

Code

#!/bin/bash    (01)

echo Hi Im Bash whats your name?    (02)

read name    (03)

echo Hello  $name    (04)

1. Defines the shell the script is using.

2. we know echo by now. If not it displays whats inputted after it wether string or variable

3. Reads the input of stdin (standard input/what is inputted to the terminal) and sets the $name variable to what was inputted by the user

4. Echo ouputs to stdout the string Hello and the variable $name

 

 

Bash Scripting, Linux , ,

PHP info. Checking your PHP install

How to check your current PHP install using PHP info.

Need to find details of the PHP installed on your server?

Create a php script using the text editor of your choice and call it what you want as long as its extension is .php.

Insert the following.

<?php

phpinfo();

?>

Make the script executable (providing your in that directory).

chmod +x phpinfo.php

You will also need to set the ownership permissions on the file to what Apache is running them as so its executable in a browser.

chown user:group phpinfo.php

So if the site is running as an Apache module for example.

chown apache:apache phpinfo.php

Now load the page in your browser to get details of your PHP install.

 

Linux, PHP, Virtual & Dedicated Servers, Windows , ,

Linux package manager commands cheat sheet

Linux package manager commands cheat sheet.

Yum package manager Linux (Yellowdog updater modified).

Install package.

yum install packagename

Update a package.

yum update packagename

Check for updates.

yum check-update

Update a system.

yum update

Search for packages.

yum search packagename

Remove a package (Caution check what your confirming of removing as this will include dependencies sometimes that you dont want to remove).

yum remove packagename

APT-GET  package manager Linux (Advanced packaging tool).

Install package.

apt-get install packagename

Upgrade a package, this is the same as installing.

apt-get install packagename

Check for updates.

apt-get update

Update a system.

apt-get update && apt-get upgrade

Search for packages.

apt-cache search packagename

Removing a package (Not as risky as yum regarding removing dependencies you still need, but still always check what your removing).

apt-get remove packagename

Aptitude package manager Linux (Advanced package tool front end).

Install package.

aptitude install packagename

Update a package.

aptitude install packagename

Check for updates.

aptitude update

Update a system.

aptitude update && aptitude safe-upgrade

Search for a package.

aptitude search packagename

Removing a package (Not as risky as yum regarding removing dependencies you still need, but still always check what your removing).

aptitude remove packagename

To launch Aptitude’s text user interface.

aptitude

RPM package manager Linux (RPM package manager formerly known as Red Hat package manager).

Installing a package.

rpm -i package.rpm

Upgrading a package.

rpm -U packagename

Remove a package excluding dependencies.

rpm -e --nodeps packagename

Search for installed packages  (not piping to grep will list all installed packages).

rpm -qa | grep searchterm

Show package information.

rpm -qi packagename

DPKG package manager Linux (Debian package manager system).

Install or upgrade a package.

dpkg -i packagename.deb

Remove a package.

dpkg -r packagename

Search for installed packages (not piping to grep will list all installed packages).

dpkg -l | grep searchterm

slapt-get package manager Linux (A version of apt-get for Slackware).

Install package.

slapt-get --install packagename

Upgrade a package, this is the same as installing.

slapt-get --install packagename

Check for updates.

slapt-get --update

Update a system.

slapt-get --update && slapt-get --upgrade

Removing a package (Always check what your removing).

slapt-get --remove packagename

 

Portage (The package manager used by Gentoo, I think this is a fork/Linux version of ports used by BSD if it isn’t it works in a similar way) .

Install something.

emerge usbutils

Be prompted first.

emerge --ask usbutils

Simulate an Install.

emerge -pv usbutils

Rebuild kernel modules.

emerge --ask @module-rebuild

Install from a binary.  This needs a lot more in depth (but good for cheat sheet).

emerge -k usbutils

local binaries, if not available will install from source.

emerge -K usbutils

Will only use local binaries, no source.

emerge -g usbutils

Will install local or remote binaries(PORTAGE_BINHOST), or from source

emerge -G usbutils

(Same as the above but will only install from local or remote binary)

Upgrade.

As portage is a ‘package manager’ for a rolling release there isn’t a straight update feature. You have to sync with the Portage tree and then upgrade so will probably cover this in a later post.

There is alot more you can do with these for more info read the man pages (very useful).

i.e

man yum

Or type for more info on what a man page does (man is the manual).

man man

Linux , , , , , , ,

Changing SSH port on Red Hat based servers

If your running a Linux web server one advisable security step is changing SSH port on your server, from the default of port 22.

This is to help prevent the many script kiddies out there gaining root to your server.

This guide will work for Red Hat based distros, CentOS and Fedora for example but not on Debian based i,e Ubuntu. Although it should all work bar the firewall config.

1. Modify the SSH daemon configuration

nano -w /etc/ssh/sshd_config

Now modify the Port (use one that’s available obviously)

look for #Port

remove the # and change the port number in this example 1023

Tip 

If you don’t use the service using a port that is used by a known service  can fool some crackers on what is actually running on your server.

Press ctrl+x to exit the nano text editor, you will prompted to save.

2. Now open port 1023 in your servers firewall

nano -w /etc/sysconfig/iptables

And include the following

-A INPUT -m state –state NEW -m tcp -p tcp –dport 1023 -j Accept

This will need to be added before protocol or more sucure lockdowns in your firewall.

If your firewall is pre-configured or unsure add the entry to the beginning of the file.

Save the file.

3. Now restart the services

IpTables

service iptables restart

SSHD

service sshd restart

Now connecting to SSH via the new port

ssh root@ipaddress -p 1023

And remember to use secure passwords, mixed case and including numbers and special chars, at least 8 characters long. Although the speed increase’s in cpus now a days I would advise 12.

I will also advise in a future post on disabling root login for SSH, but until then cya later.

Update the post has now been added http://box-admin.com/2012/01/disabling-root-login-for-ssh/

Linux, Virtual & Dedicated Servers , , , ,

Upgrade PHP Linux PHP 5.3.3 with ioncube loader CentOS 5 and Red Hat 5 with Plesk control panel

Guide to upgrade PHP Linux. PHP 5.3.3 Red Hat, CentOS.

1. Remove currently installed PHP.

Without Plesk.

rpm -qa | grep php | xargs rpm -e --nodeps

With Plesk. This is required as the output of rpm -qa | grep php would also pass some Plesk packages to xargs rpm -e --nodeps and Plesk would be broken!

Using the grep -v psa will remove any output containing psa.

rpm -qa | grep php | grep -v psa | xargs rpm -e --nodeps

Personally I advise you check the output of.

rpm -qa | grep php

and,

rpm -qa | grep php | grep -v psa  

before piping to xargs.

2. Install PHP 5.3.3.

yum install php53* php53-*

3. Install the ioncube loader.

Download and extract the ioncube loader and install the ioncube loader module.

x86,

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86.tar.gz && cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib/php/modules/

Now update the PHP config.

echo “zend_extension=/usr/lib/php/modules//ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini

x86_64.

wget http://downloads2.ioncube.com/loader_downloads/ioncube_loaders_lin_x86-64.tar.gz && tar -zxf ioncube_loaders_lin_x86-64.tar.gz && cd ioncube && cp ioncube_loader_lin_5.3.so /usr/lib64/php/modules/

Now update the PHP config.

echo “zend_extension=/usr/lib64/php/modules//ioncube_loader_lin_5.3.so” > /etc/php.d/ioncube-loader.ini

4. Create dummy PHP package (Optional only required for Plesk  as it does not look for PHP53 packages only PHP.

Install rpmbuild.

yum install rpm-build

Create the php.spec.

nano -w php.spec

Include the following in the file.

Summary: Empty PHP required as Plesk doesent recognise the PHP53 packages.
Name: php
Version: 5
Release: 3.3
License: Public
Group: Applications/System
%description
Empty PHP RPM
%files

press ctrl+x to exit and save the file.

Now build the RPM.

rpmbuild -bb php.spec

This will then output a path to the created RPM.

Install the package

rpm -i /path/to/rpm

Exclude PHP from the main repos.

open the yum config.

nano -w /etc/yum.conf

add the following entry.

exclude=php

The exclude php is to prevent issues with php packages conflicting with php53. It wont stop php53 packages from updating.

5. Restart Apache

service httpd restart

Now check the version of PHP

php -v

Job done.

 

Linux, PHP, Plesk Linux, Virtual & Dedicated Servers , , , , , ,