Monday, August 31, 2015

Install APC (Alternative PHP Cache) in RHEL/CentOS 6/5 & Fedora 20-12

http://www.tecmint.com/install-apc-alternative-php-cache-in-rhel-centos-fedora/

APC (Alternate PHP Cache) is an free and open source cache for PHP code. The main goal of this module is to provide robust framework for caching and optimizing PHP code.
Install PHP APC in Linux
Install and Enable PHP APC in Linux
The instructions provided here shows how to install and enable APC caching for PHP on RHEL 6.5/6.4/6.3/6.2/6.1/6/5.8/5.6CentOS 6.5/6.4/6.3/6.2/6.1/6/5.8/5.6 and Fedora 20,19,18,17,16,15,14,13,12using PECL command to download from the repositories.

Install Dependency Packages for APC

First, we need to install required packages called peclphpize and apxs commands, to install APC using YUMpackage manager tool.
yum install php-pear php-devel httpd-devel pcre-devel gcc make

Install APC Using PECL

Now we have all the needed packages to install APC. Here we use PECL command to install it. Please select default settings when asked.
pecl install apc
Sample Output :
WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update
downloading APC-3.1.9.tgz ...
Starting to download APC-3.1.9.tgz (155,540 bytes)
.................................done: 155,540 bytes
54 source files, building
running: phpize
Configuring for:
PHP Api Version:         20090626
Zend Module Api No:      20090626
Zend Extension Api No:   220090626
config.m4:180: warning: AC_CACHE_VAL(PHP_APC_GCC_ATOMICS, ...): suspicious cache-id, must contain _cv_ to be cached
../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from...
config.m4:180: the top level
config.m4:180: warning: AC_CACHE_VAL(PHP_APC_GCC_ATOMICS, ...): suspicious cache-id, must contain _cv_ to be cached
../../lib/autoconf/general.m4:1974: AC_CACHE_VAL is expanded from...
../../lib/autoconf/general.m4:1994: AC_CACHE_CHECK is expanded from...
config.m4:180: the top level
Enable internal debugging in APC [no] :
Enable per request file info about files used from the APC cache [no] :
Enable spin locks (EXPERIMENTAL) [no] :
Enable memory protection (EXPERIMENTAL) [no] :
Enable pthread mutexes (default) [yes] :
Enable pthread read/write locks (EXPERIMENTAL) [no] :

Enable APC PHP Extension

Run the following command to enable APC extension in Apache configuration.
echo "extension=apc.so" > /etc/php.d/apc.ini

Restart Apache Service for APC

Restart the Apache service to take new changes.
service httpd restart
OR
/etc/init.d/httpd restart

Verify APC Installation

Create a file phpinfo.php in Apache web root directory. For example /var/www/html/phpinfo.php.
# vi /var/www/html/phpinfo.php
Add the following code to it. save and close.

Open any browser and type the following URL. You will see APC enabled configuration similar to below.
http://localhost/phpinfo.php
PHP APC Extension
PHP APC Configuration Screen

Enable PHP APC administration

To enable APC administration panel, copy the following file.
cp /usr/share/pear/apc.php /var/www/html/
Now open the file apc.php with VI editor.
# vi /var/www/html/apc.php
Now set the username and password in the file apc.php as shown below.
defaults('ADMIN_USERNAME','apc');       // Admin Username
defaults('ADMIN_PASSWORD','Set-Password-Here');  // Admin Password - CHANGE THIS TO ENABLE!!!
Type the following URL in the browser. You will get administration panel of APC.
http://localhost/apc.php
Some screenshots of APC Administration panel for your reference.
Vies Host Stats
APC View Host Stats
APC View Host Stats Overview
System Cache Entries
APC System Cache Entries
APC System Cache Entries Overview
User Cache Entries
APC User Cache Entries
APC User Cache Entries Overview
APC Login Screen
APC Admin Login
APC Admin Login Screen
APC Version Check
APC Version Check
APC Version Check Overview

Upgrade APC using PECL

To upgrade, just execute following command it will download and upgrade APC.
pecl upgrade apc

Uninstall APC using PECL

If you like to remove it, then simple type the following command to uninstall APC completely from the system.
pecl uninstall apc

Setting Up High-Performance ‘HHVM’ and Nginx/Apache with MariaDB on Debian/Ubuntu

http://www.tecmint.com/install-hhvm-and-nginx-apache-with-mariadb-on-debian-ubuntu

HHVM stands for HipHop Virtual Machine, is an open source virtual machine created for running Hack (it’s a programming language for HHVM) and PHP written applications. HHVM uses a last minute compilation path to achieve remarkable performance while keeping the flexibility that PHP programmers are addicted to. Till date, HHVM has achieved over a 9x increase in http request throughput and more than 5x cut in memory utilization (when running on low system memory) for Facebook compared with the PHP engine + APC (Alternative PHP Cache).
HHVM can also be used along with a FastCGI-based web-server like Nginx or Apache.
Install HHVM, Nginx and Apache with MariaDB
Install HHVM, Nginx and Apache with MariaDB
In this tutorial we shall look at steps for setting up Nginx/Apache web server, MariaDB database server andHHVM. For this setup, we will use Ubuntu 15.04 (64-bit) as HHVM runs on 64-bit system only, although Debian and Linux Mint distributions are also supported.

Step 1: Installing Nginx and Apache Web Server

1. First do a system upgrade to update repository list with the help of following commands.
# apt-get update && apt-get upgrade
System Upgrade
System Upgrade
2. As I said HHVM can be used with both Nginx and Apache web server. So, it’s your choice which web server you will going to use, but here we will show you both web servers installation and how to use them with HHVM.

Installing Nginx

In this step, we will install Nginx/Apache web server from the packages repository using following command.
# apt-get install nginx
Install Nginx Web Server
Install Nginx Web Server

Installing Apache

# apt-get install apache2
Install Apache Web Server
Install Apache Web Server
At this point, you should be able to navigate to following URL and you will able to see Nginx or Apache default page.
http://localhost
OR
http://IP-Address
Nginx Default Page
Nginx Welcome Page
Nginx Welcome Page
Apache Default Page
Apache Default Page
Apache Default Page

Step 2: Install and Configure MariaDB

3. In this step, we will install MariaDB, as it providers better performance as compared to MySQL.
# apt-get install mariadb-client mariadb-server
Install MariaDB Database
Install MariaDB Database
4. After MariaDB successful installation, you can start MariaDB and set root password to secure the database:
# systemctl start mysql
# mysql_secure_installation
Answer the following questions by typing y or n and press enter. Make sure you read the instructions carefully before answering the questions.
Enter current password for root (enter for none) = press enter
Set root password? [Y/n] = y
Remove anonymous users[y/n] = y
Disallow root login remotely[y/n] = y
Remove test database and access to it [y/n] = y
Reload privileges tables now[y/n] = y 
5. After setting root password for MariaDB, you can connect to MariaDB prompt with the new root password.
# mysql -u root -p

Step 3: Installation of HHVM

6. At this stage we shall install and configure HHVM. You need to add the HHVM repository to yoursources.list file and then you have to update your repository list using following series of commands.
# wget -O - http://dl.hhvm.com/conf/hhvm.gpg.key | apt-key add -
# echo deb http://dl.hhvm.com/ubuntu DISTRIBUTION_VERSION main | sudo tee /etc/apt/sources.list.d/hhvm.list
# apt-get update
Important: Don’t forget to replace DISTRIBUTION_VERSION with your Ubuntu distribution version (i.e. lucid, precise, or trusty.) and also on Debian replace with jessie or wheezy. On Linux Mint installation instructions are same, but petra is the only currently supported distribution.
After adding HHVM repository, you can easily install it as shown.
# apt-get install -y hhvm
Installing HHVM will start it up now, but it not configured to auto start at next system boot. To set auto start at next boot use the following command.
# update-rc.d hhvm defaults

Step 4: Configuring Nginx/Apache to Talk to HHVM

7. Now, nginx/apache and HHVM are installed and running as independent, so we need to configure both web servers to talk to each other. The crucial part is that we have to tell nginx/apache to forward all PHP files to HHVM to execute.
If you are using Nginx, follow this instructions as explained..
By default, the nginx configuration lives under /etc/nginx/sites-available/default and these config looks in/usr/share/nginx/html for files to execute, but it don’t know what to do with PHP.
To make Nginx to talk with HHVM, we need to run the following include script that will configure nginx correctly by placing a hhvm.conf at the beginning of the nginx config as mentioned above.
This script makes the nginx to talk to any file that ends with .hh or .php and send it to HHVM via fastcgi.
# /usr/share/hhvm/install_fastcgi.sh
Configure Nginx for HHVM
Configure Nginx for HHVM
Important: If you are using Apache, there isn’t any configuration is needed now.
8. Next, you need to use /usr/bin/hhvm to provide /usr/bin/php (php) by running this command below.
# /usr/bin/update-alternatives --install /usr/bin/php php /usr/bin/hhvm 60
After all the above steps are done, you can now start HHVM and test it.
# systemctl start hhvm

Step 5: Testing HHVM with Nginx/Apache

9. To verify that hhvm working, you need to create a hello.php file under nginx/apache document root directory.
# nano /usr/share/nginx/html/hello.php       [For Nginx]
OR
# nano /var/www/html/hello.php               [For Nginx and Apache]
Add the following snippet to this file.

and then navigate to the following URL and verify to see “hello world“.
http://localhost/info.php
OR
http://IP-Address/info.php
HHVM Page
HHVM Page
If “HHVM” page appears, then it means you’re all set!

Conclusion

These steps are very easy to follow and hope your find this tutorial useful and if you get any error during installation of any packages

Saturday, August 29, 2015

How to Convert From RPM to DEB and DEB to RPM Package Using Alien

http://www.tecmint.com/convert-from-rpm-to-deb-and-deb-to-rpm-package-using-alien

As I’m sure you already know, there are plenty of ways to install software in Linux: using the package management system provided by your distribution (aptitude, yum, or zypper, to name a few examples), compiling from source (though somewhat rare these days, it was the only method available during the early days of Linux), or utilizing a low level tool such as dpkg or rpm with .deb and .rpm standalone, precompiled packages, respectively.
Convert RPM to DEB and DEB to RPM
Convert RPM to DEB and DEB to RPM Package Using Alien
In this article we will introduce you to alien, a tool that converts between different Linux package formats, with.rpm to .deb (and vice versa) being the most common usage.
This tool, even when its author is no longer maintaining it and states in his website that alien will always probably remain in experimental status, can come in handy if you need a certain type of package but can only find that program in another package format.
For example, alien saved my day once when I was looking for a .deb driver for a inkjet printer and couldn’t find any – the manufacturer only provided a .rpm package. I installed alien, converted the package, and before long I was able to use my printer without issues.
That said, we must clarify that this utility should not be used to replace important system files and libraries since they are set up differently across distributions. Only use alien as a last resort if the suggested installation methods at the beginning of this article are out of the question for the required program.
Last but not least, we must note that even though we will use CentOS and Debian in this article, alien is also known to work in Slackware and even in Solaris, besides the first two distributions and their respective families.

Step 1: Installing Alien and Dependencies

To install alien in CentOS/RHEL 7, you will need to enable the EPEL and the Nux Dextop (yes, it’s Dextop – not Desktop) repositories, in that order:
# yum install epel-release
# rpm --import http://li.nux.ro/download/nux/RPM-GPG-KEY-nux.ro
The latest version of the package that enables this repository is currently 0.5 (published on Aug. 10, 2015). You should check http://li.nux.ro/download/nux/dextop/el7/x86_64/ to see whether there’s a newer version before proceeding further:
# rpm -Uvh http://li.nux.ro/download/nux/dextop/el7/x86_64/nux-dextop-release-0-5.el7.nux.noarch.rpm
then do,
# yum update && yum install alien
In Fedora, you will only need to run the last command.
In Debian and derivatives, simply do:
# aptitude install alien

Step 2: Converting from .deb to .rpm Package

For this test we have chosen dateutils, which provides a set of date and time utilities to deal with large amounts of financial data. We will download the .deb package to our CentOS 7 box, convert it to .rpm and install it:
Check CentOS Version
Check CentOS Version
# cat /etc/centos-release
# wget http://ftp.us.debian.org/debian/pool/main/d/dateutils/dateutils_0.3.1-1.1_amd64.deb
# alien --to-rpm --scripts dateutils_0.3.1-1.1_amd64.deb
Convert .deb to .rpm package in Linux
Convert .deb to .rpm package in Linux
Important: (Please note how, by default, alien increases the version minor number of the target package. If you want to override this behavior, add the –keep-version flag).
If we try to install the package right away, we will run into a slight issue:
# rpm -Uvh dateutils-0.3.1-2.1.x86_64.rpm 
Install RPM Package
Install RPM Package
To solve this issue, we will enable the epel-testing repository and install the rpmrebuild utility to edit the settings of the package to be rebuilt:
# yum --enablerepo=epel-testing install rpmrebuild
Then run,
# rpmrebuild -pe dateutils-0.3.1-2.1.x86_64.rpm
Which will open up your default text editor. Go to the %files section and delete the lines that refer to the directories mentioned in the error message, then save the file and exit:
Convert .deb to Alien Version
Convert .deb to Alien Version
When you exit the file you will be prompted to continue with the rebuild. If you choose Y, the file will be rebuilt into the specified directory (different than the current working directory):
# rpmrebuild –pe dateutils-0.3.1-2.1.x86_64.rpm
Build RPM Package
Build RPM Package
Now you can proceed to install the package and verify as usual:
# rpm -Uvh /root/rpmbuild/RPMS/x86_64/dateutils-0.3.1-2.1.x86_64.rpm
# rpm -qa | grep dateutils
Install Build RPM Package
Install Build RPM Package
Finally, you can list the individual tools that were included with dateutils and alternatively check their respective man pages:
# ls -l /usr/bin | grep dateutils
Verify Installed RPM Package
Verify Installed RPM Package

Step 3: Converting from .rpm to .deb Package

In this section we will illustrate how to convert from .rpm to .deb. In a 32-bit Debian Wheezy box, let’s download the .rpm package for the zsh shell from the CentOS 6 OS repository. Note that this shell is not available by default in Debian and derivatives.
# cat /etc/shells
# lsb_release -a | tail -n 4
Check Shell and Debian OS Version
Check Shell and Debian OS Version
# wget http://mirror.centos.org/centos/6/os/i386/Packages/zsh-4.3.11-4.el6.centos.i686.rpm
# alien --to-deb --scripts zsh-4.3.11-4.el6.centos.i686.rpm
You can safely disregard the messages about a missing signature:
Convert .rpm to .deb Package
Convert .rpm to .deb Package
After a few moments, the .deb file should have been generated and be ready to install:
# dpkg -i zsh_4.3.11-5_i386.deb
Install RPM Converted Deb Package
Install RPM Converted Deb Package
After the installation, you can verify that zsh is added to the list of valid shells:
# cat /etc/shells
Confirm Installed Zsh Package
Confirm Installed Zsh Package

Summary

In this article we have explained how to convert from .rpm to .deb and vice versa to install packages as a last resort when such programs are not available in the repositories or as distributable source code.