Tuesday 28 January 2020

Run multiple PHP versions on the same server






You would have faced the trouble of keep swapping the PHP version depending on the task in hand you need to use. With this solution, you can install multiple PHP versions in the system and make them work simultaneously.
To run two or more PHP versions for different sites on the same LAMP stack by using mod_fcgid to create a .fcgi wrapper script.  The script forwards all the PHP requests which were made from php-cgi binary.
Considering a server running on PHP 7.2  where a specific site requires an older PHP version (eg PHP 5.6)

Required Installation Packages

The php56-php packages are in the Remi repos and they install to /opt/remi/
In order to create the PHP wrapper script, mod_fcgid Apache module needs to be installed.
[root@server ~]#yum install php56-php php56-php-pear mod_fcgid

Remove alternate PHP configuration(s)

A configuration file to load PHP 5.6 would be created  into Apache at /etc/httpd/conf.d/php56-php.conf, which has to be DELETED else it would conflict with the existing PHP version and would fail Apache  to start.
[root@server ~]#rm -f /etc/httpd/conf.d/php56-php.conf

PHP wrapper script creation

This script will set the environment for the specific PHP versions. (here PHP 5.6)
Example path of a specified site '/var/www/www.actsupport.com/cgi-bin/php56.fcgi'
(name the script depending on the PHP version)

[root@server ~]#cd /var/www/www/actsupport.com/cgi-bin
[root@server ~]#vim php56.fcgi
#!/bin/sh
PHPRC=/opt/remi/php56/root/etc/
export PHPRC
export PHP_FCGI_MAX_REQUESTS=5000
export PHP_FCGI_CHILDREN=16
exec /opt/remi/php56/root/usr/bin/php-cgi

[root@server ~]#chmod +x /var/www/www.actsupport.com/cgi-bin/php56.fcgi
PHPRC is the path of the folder for php.ini and the exec is the full path to the php-cgi binary of the enabling PHP version, Update the values on your environment accordingly.

Update Apache Configuration

Append the Virtual Host for the specific domain on the question.
[root@server ~]#/etc/httpd/sites-available/actsupport.com.conf (Generic/Custom path based on the environment)
<IfModule mod_fcgid.c>
    RemoveHandler .php
    RemoveType application/x-httpd-php
    Action application/x-httpd-php5 /cgi-bin/php56.fcgi
    AddType application/x-httpd-php5 .php
    AddHandler application/x-httpd-php5 .php
</IfModule>

HTTPS config to be updated, if applicable
EDIT PHP config

Modify by commenting out the <FilesMatch> and SetHandler block because it can't be overridden by the RemoveHandler directive we added to the site's virtualhost entry.
It is being replaced with an AddHandler directive that performs the same purpose but will respect being overridden.

[root@server ~]#/etc/httpd/conf.d/php.conf
#    <FilesMatch \.php$>
#        SetHandler application/x-httpd-php
#    </FilesMatch>
       AddHandler application/x-httpd-php .php

PHP Modules Installation

The required PHP modules vary based on the site and if we restart Apache now, the alternate PHP version would run without the necessary modules and be incompatible accordingly. Though very few modules being installed by default the below list works in many setups. However, install other PHP modules that are needed as necessary and make sure to install the phpXX-php-* versions from the Remi Repo for any PHP versions used to avoid accidental module installation for the wrong PHP versions of human error prefix.
php56-php-gd
php56-php-mbstring
php56-php-xml
php56-php-mysqlnd
php56-php-mssql
php56-php-ioncube-loader

To install the above use
[root@server ~]#yum install php56-php-gd php56-php-mbstring php56-php-xml php56-php-mysqlnd php56-php-mssql php56-php-ioncube-loader

Also make sure the php.ini for the specific PHP version is probably located at /opt/remi/phpXX/root/etc/php.ini.

Finally restart Apache

Finally, you need to restart Apache
[root@server ~]#service httpd restart

Verify PHP changes

Create a info.php page and verify changes.
[root@server ~]#vim info.php
<?php
phpinfo:();
?>

I hope you have resolved the issue related to multiple PHP versions. If you need any assistance Contact Us.

For more tips follow us on Facebook, Twitter

Wednesday 8 January 2020

Steps to Install Jira on Centos7



The bug-tracking tool Jira will track issues and bugs related to your software and Mobile apps. It is developed by an Australian Company Atlassian. You can manage your project easily, as Jira dashboard consists of many useful functions and features which make handling of the issue easily.

Now let’s see how to install and configure latest version of Jira on centos7


Steps to Install & Configure:

Install JIRA on Centos7
To establish Jira, you must require JAVA software package. So, First you need to check the Java package and its version by “JAVA – version” Command.
# yum install
java-1.8.0-openjdk java-1.8.0-openjdk-devel
# java -version
openjdk version "1.8.0_212"

Let's Install MySQL Database

Install and configure MySQL to start on system boot & set password.
# wget https://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm
# rpm -ivh mysql57-community-release-el7-11.noarch.rpm
# yum install mysql-server
# systemctl start mysqld
# systemctl status mysqld
# grep 'temporary password' /var/log/mysqld.log  ## to get default password ##
# mysql_secure_installation    ## use default password and change new password ##

Note: You have to set a strong password with uppercase, lowercase letters, numbers and special characters etc.

Now create MySQL Database and user for Jira with following commands:

# mysql -u root -p
CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;
grant all privileges on jiradb.* to 'jira'@'%' identified by 'password';
flush privileges

You should maintain a strong password otherwise you will get below error:

ERROR 1819 (HY000): This shows that your password does not satisfy the current policy requirements
For a simple password use below command in mysql prompt
SET GLOBAL validate_password_policy=LOW;
Now it allows to keep simple password.

Next exit from MySQL and then restart MySQL service as shown below
# systemctl restart mysqld

Installation of JIRA
To install Jira on centos7. Download the latest version of JIRA installer from: https://www.atlassian.com/software/jira/download

# cd /opt
# wget https://www.atlassian.com/software/jira/downloads/binary/atlassian-jira-software-8.6.0.zip
Then, Execute the .zip file and install JIRA.
# unzip atlassian-jira-software-8.2.0.zip 
# mv atlassian-jira-software-8.2.0-standalone atlasian
# mkdir /opt/jira
# mkdir /opt/jira/home
# vi /opt/atlassian/atlassian-jira/WEB-INF/classes/jira-application.properties
### set jira.home as jira.home = /opt/jira/home ###
# cd /opt/atlassian/bin
# ./startup.sh

Once after completing the Jira
Installation. You can now access Jira as http://ip_address:8080

To Copy the MySQL JDBC Driver
Download jdbc drivers from http://dev.mysql.com/downloads/connector/j/

You can either download .tar.gz or .zip file and copy the MySQL JDBC driver to application server file as shown:

# cd mysql-connector-java-5.1.47
# mv mysql-connector-java-5.1.47.jar /opt/atlassian/lib/
To Restart Jira service
# cd /opt/atlassian/bin/
# ./stop-jira.sh
# ./start-jira.sh

Hope it helps. If you need any assistance Contact Us

Read our existing blog post : Steps to install PhantomJS On CentOS7

Follow us on Facebook & Twitter for more updates