Showing posts with label php. Show all posts
Showing posts with label php. Show all posts

Tuesday, December 31, 2024

Install Oracle Instant Client (oci8) for PHP5.6 on Ubuntu 22.04

*make sure php5.6 is already install

1. Install Basic and the SDK Instant Client packages. Download from OTN

Download version 12.1.0.2.0. This file is required:

  • instantclient-basic-linux.x64-12.1.0.2.0.zip
  • instantclient-sdk-linux.x64-12.1.0.2.0.zip

2. Install OCI8 version oci8-2.0.10. Download from pecl.php.net

3. Manual install OCI8 

#tar -xzf oci8-2.0.10.tgz
#cd oci8-2.0.10
#phpize
#./configure -with-oci8=share,instantclient,/usr/lib/oracle/12.1/client64/lib
#make install

4. Enable the ORACLE global variables

#export LD_LIBRARY_PATH=/usr/lib/oracle/12.1/client64/lib
#export ORACLE_HOME=/usr/lib/oracle/12.1/client64 

5. Enable oci8 in php5.6

  • create file oci.ini in /etc/php/5.6/mods-available/
  • add the extension=oci8.so to the oci.ini

6. Create symlink in php5.6 folder

#ln -s /etc/php/5.6/mods-available/oci.ini 20-oci.ini in folder /etc/php/5.6/cli/conf.d
#ln -s /etc/php/5.6/mods-available/oci.ini 20-oci.ini in folder /etc/php/5.6/fpm/conf.d

7. Validate that it was successfully installed.

#php -i | grep oci8 

Monday, June 28, 2021

PHP : PHP7.4 Install ZIP extension

1. #yum install pcre-devel gcc zlib zlib-devel libzip-devel make

2. #pecl install zip 


If this issue happen 


Issuechecking for libzip... configure: error: system libzip must be upgraded to version >= 0.11


Solutions:

#yum  -y remove libzip-devel

#wget https://libzip.org/download/libzip-1.3.2.tar.gz

#tar xvf libzip-1.3.2.tar.gz

#cd libzip-1.3.2

#./configure

#make && make install


3. Run again #pecl install zip 

4. Then enable the zip extension in php.ini 

extension=zip.so

Tuesday, May 25, 2021

Laravel : Install Laravel on Centos 7 and MSSQL connector

Install Composer
----------------
#curl -sS https://getcomposer.org/installer | php
#mv composer.phar /usr/bin/composer
#chmod +x /usr/bin/composer

Install Laravel
---------------
#git clone https://github.com/laravel/laravel.git
#cd /var/www/laravel
#composer install
#cp .env.example .env
#php artisan key:generate
#php artisan migrate
#chown -R apache.apache /var/www/laravel - if in hosting no to change
#chmod -R 755 /<path>/laravel
#chmod -R 777 /<path>/laravel/storage

Install node.js and npm
-----------------------
#yum install -y gcc-c++ make
#curl -sL https://rpm.nodesource.com/setup_15.x | sudo -E bash -
#yum install nodejs


Step to install MSSQL connector Centos 7
-----------------------------------------
# yum -y groups install "Development Tools"
# pecl install sqlsrv pdo_sqlsrv
# echo 'extension=pdo_sqlsrv.so' > /etc/opt/remi/php70/php.d/30-pdo_sqlsrv.ini
# echo 'extension=sqlsrv.so' > /etc/opt/remi/php70/php.d/30-sqlsrv.ini 

OR

Install the Microsoft ODBC driver for SQL Server (Linux) - https://docs.microsoft.com/en-us/sql/connect/odbc/linux-mac/installing-the-microsoft-odbc-driver-for-sql-server?view=sql-server-ver15#redhat17 

To check version ODBC Driver
-----------------------------------------

# odbcinst -q -d
# odbcinst -q -d -n "ODBC Driver 17 for SQL Server"

Microsoft Drivers for PHP for SQL Server - https://docs.microsoft.com/en-us/sql/connect/php/installation-tutorial-linux-mac?view=sql-server-ver15

Tuesday, December 24, 2019

Centos 7 : Install Multiple PHP Version (php5.6 and php7.3, php7.4, php8.1)

The guide (refer www.tecmint.com)

1. Installing and enabling the EPEL and Remi repository - offers the latest versions of the PHP stack on CentOS
# yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
# yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
2. Install the yum-utils package - which is used to enable or disable Yum repositories on the system
# yum install yum-utils

3. Install different versions of PHP, use yum-config-manager command to install multiple versions of PHP:

Install PHP 8.1 Version

# yum install php81 php-common 
# yum install php81-php-mysql php81-php-fpm php81-php-pecl-memcache php81-php-pecl-memcached php81-php-gd php81-php-mbstring php81-php-mcrypt php81-php-xml php81-php-pecl-apc php81php-cli php81-php-pear php81-php-pdo

Install PHP 7.4 Version

# yum install php74 php-common 
# yum install php74-php-mysql php74-php-fpm php74-php-pecl-memcache php74-php-pecl-memcached php74-php-gd php74-php-mbstring php74-php-mcrypt php74-php-xml php74-php-pecl-apc php74-php-cli php74-php-pear php74-php-pdo

Install PHP 7.3 Version

# yum-config-manager --enable remi-php73  [Default]
# yum install php php-common 
# yum install php-mysql php-fpm php-pecl-memcache php-pecl-memcached php-gd php-mbstring php-mcrypt php-xml php-pecl-apc php-cli php-pear php-pdo
Install PHP 5.6 Version
# yum install php56 php56-php-common 
# yum install php56-php-mysql php56-php-fpm php56-php-pecl-memcache php56-php-pecl-memcached php56-php-gd php56-php-mbstring php56-php-mcrypt php56-php-xml php56-php-pecl-apc php56-php-cli php56-php-pear php56-php-pdo
4. Command to check the default version of PHP
# php -v 
# yum list installed | grep php - list installed

5. The PHP configuration path location :
  • /etc/php.d/ for PHP7.3
  • /opt/remi/php56/ for PHP5.6

Repository :
  • https://rpms.remirepo.net
  • https://fedoraproject.org/wiki/EPEL

Thursday, August 8, 2019

PHP : Install Composer on Centos

1.First install the PHP CLI (command line interface) package and all other dependencies with:
#sudo yum install php-cli php-zip wget unzip
2.Once PHP CLI is installed, download the Composer installer script with:
#php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
3.To verify the data integrity of the script
#HASH="$(wget -q -O - https://composer.github.io/installer.sig)"
4.To verify that the installation script is not corrupted run the following command:
#php -r "if (hash_file('SHA384', 'composer-setup.php') === '$HASH') { echo 'Installer verified'; } else { echo 'Installer corrupt'; unlink('composer-setup.php'); } echo PHP_EOL;"
5.Run the following command to install Composer in the /usr/local/bin directory:
#sudo php composer-setup.php --install-dir=/usr/local/bin --filename=composer
6.The last step is to verify the installation:
#composer 
______
/ ____/___  ____ ___  ____  ____  ________  _____
/ /   / __ \/ __ `__ \/ __ \/ __ \/ ___/ _ \/ ___/
/ /___/ /_/ / / / / / / /_/ / /_/ (__  )  __/ /
\____/\____/_/ /_/ /_/ .___/\____/____/\___/_/
                    /_/
Composer version 1.8.5 2019-04-09 17:46:47

source : https://linuxize.com/post/how-to-install-and-use-composer-on-centos-7/

Thursday, September 17, 2015

Wednesday, July 29, 2015

Install Oracle Instant Client (oci8) for CentOS

Solutions

Development packages
 
# yum install php-pear php-devel zlib zlib-devel bc libaio glibc
# yum groupinstall "Development Tools"

Instant Client
1. Download the Basic and the SDK Instant Client packages from the OTN Instant Client page.
Install the RPMs as the root user, for example:

  • Latest Client 21.5.0.0.0 with Oracle 12c and PHP 8.1.
  • Before that Instant Client 21.3.0.0.0 with Oracle 12c and compiled with PHP 8.0, 7.4 and 7.3 fine.
  • Before that Instant Client 10.1.0.5.0 with Oracle 10g, 11g and 12c and PHP 5.6, 7.1, 7.2, 7.3 and 7.4.

2. Install Basic and the SDK Instant Client packages

#rpm -Uvh oracle-instantclient-XXX.rpm
#rpm -Uvhoracle-instantclient-devel-XXX.rpm

3.Check you have php-pear and php-devel packages installed by this command
# rpm -qa | grep -i php
    .....
    php-5.3.3-3.el6_1.3.x86_64
    php-cli-5.3.3-3.el6_1.3.x86_64
    .....

OCI8
4.Install oci8 extension by manual or auto

Manual
# pear download pecl/oci8
# tar -xvf oci8-version.tgz
# cd oci8-version

Build and install the extension.

# phpize
# ./configure --with-oci8=shared,instantclient,/usr/lib/oracle/<exact path>
# make
# make install

* If got an error when to make
    compilation terminated.
    make: *** [oci8.lo] Error 1
    ERROR: `make' failed

 It seems that your PHP was built with DTrace support enabled.  
    # export PHP_DTRACE=yes
    # pecl install oci8

Auto

# pecl search oci8
# pecl install oci8

  • Use pecl install oci8 to install for PHP 8.2.
  • Use pecl install oci8-3.2.1 to install for PHP 8.1.
  • Use pecl install oci8-3.0.1 to install for PHP 8.0.
  • Use pecl install oci8-2.2.0 to install for PHP 7


OR     
# yum install php56-php-oci8-5.6.40-25.el7.remi.x86_64 - PHP56
# yum install php-oci8-7.3.27-1.el7.remi.x86_64 - PHP7

5. Enable oci8 extension

To enable the extension, add a file named oci8.ini in /etc/php.d/ with this content:
# extension=oci8.so

6. Restart http server

#/etc/init.d/httpd restart

7. Validate that it was successfully installed.

# php -i | grep oci8

You can check that the extension is installed with:

# php --ri oci8

8. Uninstall

# pecl uninstall oci8

Source :
 

https://github.com/php/pecl-database-oci8
http://www.techinfobest.com/connect-oracle-database-from-php-in-redhatcentos
http://www.oracle.com/technetwork/articles/dsl/technote-php-instant-084410.html
http://itvomit.com/2013/10/25/getting-oracle-instant-client-php-and-oci8-all-working/

Thursday, April 7, 2011

Apache Modsecurity : Request body (Content-Length) is larger than theconfigured limit

Error Log:

  • ModSecurity: Request body (Content-Length) is larger than the configured limit (131072). [hostname "x.x.x.x"] [uri "/templates_import.php"] [unique_id "QzoPUttdJF4AABSQMQsAAAAB"]

Resolved solutions:

Edit this command to /etc/http/conf.d/modsecurity.conf-minimal

# Basic configuration options

SecRuleEngine On

SecRequestBodyAccess On

SecResponseBodyAccess On


          ...............



# Maximum request body size we will accept for buffering

SecRequestBodyLimit 1124288 

# Store up to 1MB in memory

SecRequestBodyInMemoryLimit 1124288

# Buffer response bodies of up to

SecResponseBodyLimit 1124288 


Refer :

Wednesday, January 26, 2011

Quick PHP code

Quick PHP code to test ldap connection
$ldap = ldap_connect(“domain.com”);
$username=”username@domain.com”;
$password=”password”;

if($bind = ldap_bind($ldap, $username,$password ))
echo “logged in”;
else
echo “fail”;
echo “
done”;
?>

Quick PHP code to test mysql database connection
echo “trying
”;
$link = mysql_connect(’123.123.123.123′, ‘username’, ‘password’);
if (!$link) {
die(‘Could not connect: ‘ . mysql_error());
}
else
{echo “connected”;}
?>