Kamis, 24 Agustus 2017

How To Configure/Run Multiple Php Version On Unmarried Linux Machine.

PHP: -
PHP (recursive acronym for PHP: Hypertext Preprocessor) is a widely-used opened upwards source general-purpose scripting linguistic communication that is peculiarly suited for spider web evolution in addition to tin hold out embedded into HTML.

PHP is mainly focused on server-side scripting, in addition to therefore y'all tin practise anything whatever other CGI programme tin do, such equally collect shape data, generate dynamic page content, or post in addition to have cookies. But PHP tin practise much more.


There are iii original areas where PHP scripts are used:
  • Server-side scripting. This is the almost traditional in addition to original target champaign for PHP. You demand iii things to brand this work: the PHP parser (CGI or server module), a spider web server in addition to a spider web browser. You demand to run the spider web server, alongside a connected PHP installation. You tin access the PHP programme output alongside a spider web browser, viewing the PHP page through the server. All these tin run on your abode machine if y'all are only experimenting alongside PHP programming.
  • Command business scripting. You tin brand a PHP script to run it without whatever server or browser. You solely demand the PHP parser to work it this way. This type of usage is ideal for scripts regularly executed using cron (on *nix or Linux) or Task Scheduler (on Windows). These scripts tin besides hold out used for unproblematic text processing tasks.
  • Writing desktop applications. PHP is likely non the really best linguistic communication to practise a desktop application alongside a graphical user interface, but if y'all know PHP really well, in addition to would similar to work closed to advanced PHP features inward your client-side applications y'all tin besides work PHP-GTK to write such programs. You besides convey the might to write cross-platform applications this way. PHP-GTK is an extension for PHP, non available inward the original distribution.




























Prerequisites:- We demand next earlier rootage configuring multiple PHP. 
  • Linux Machine
  • One user alongside Sudoers privileges.
  • Working Internet on that machine.
Step 1-  Check Linux release
Before, We rootage configuring PHP nosotros demand to depository fiscal establishment fit our Linux Machine version. Use the dominance below to check.
[root@cent  ]# cat /etc/redhat-release CentOS unloose 6.8 (Final) 
In my electrical flow scenario, I am using CentOS 6.8 Final release. 
Step 2- Install Webserver (HTTPD).
We demand to install Web server httpd. allow work yum dominance to rootage the installation.
[root@cent  ]# yum install httpd
Start httpd service
[root@cent  ]# service httpd start
Step 3- Enable Name Virtual Host
In companionship to setup multiple Virtual Host, nosotros demand to enable NameVirtualHost inward the httpd.conf file.
[root@cent  ]# vi /etc/httpd/conf/httpd.conf
Let's uncomment next line.
# Use name-based virtual hosting. # NameVirtualHost *:80 # # NOTE: NameVirtualHost cannot hold out used without a port specifier 
Save in addition to Exit from the File.
Restart httpd service to apply changes.
[root@cent  ]# service httpd restart
Step 4- Enable port lxxx to allow access from outside.
In companionship to access the Web server from exterior nosotros demand to enable Port 80, let's work the dominance below.
[root@cent  ]# vi /etc/sysconfig/iptables 
Append this business to this file in addition to salve it.
-A INPUT -m field --state NEW -m tcp -p tcp --dport lxxx -j ACCEPT 
Restart iptables service to apply changes.
[root@cent  ]# service iptables restart iptables: Setting chains to policy ACCEPT: filter          [  OK  ] iptables: Flushing firewall rules:                         [  OK  ] iptables: Unloading modules:                               [  OK  ] iptables: Applying firewall rules:                         [  OK  ] 
Step 5- Install PHP5.3
I am going to install PHP version 5.3 in addition to PHP 5.6. let's follow the steps below to install both the version.
5A- Install PHP5.3 Version.
[root@cent  ]# yum install php php-cli php-common php-gd php-curl  =============================================================================================================================================================================================  Package                                        Arch                                       Version                                            Repository                                Size ============================================================================================================================================================================================= Installing:  php                                            x86_64                                     5.3.3-49.el6                                       base of operations                                     1.1 M  php-cli                                        x86_64                                     5.3.3-49.el6                                       base of operations                                     2.2 M  php-common                                     x86_64                                     5.3.3-49.el6                                       base of operations                                     530 k  php-gd                                         x86_64                                     5.3.3-49.el6                                       base of operations                                     111 k  Transaction Summary ============================================================================================================================================================================================= Install       four Package(s)  Total download size: 3.9 M Installed size: thirteen M Is this ok [y/N]: Y 
5B- Check PHP Version
[root@cent  ]# php -v PHP 5.3.3 (cli) (built: Mar 22 2017 12:27:09) Copyright (c) 1997-2010 The PHP Group Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies 
PHP Version 5.3 has been installed alongside default repo.
Step 6- Install PHP5.6
PHP5.6 is non available inward default repo, For this, nosotros demand to add together an additional repository, Let's work the dominance below to install repo.
6A- Install additional repo:
you tin teach required repo equally per your OS from the next link.
[root@cent  ]# yum install http://rpms.remirepo.net/enterprise/remi-release-6.rpm  Dependencies Resolved  =============================================================================================================================================================================================  Package                                      Arch                                   Version                                           Repository                                       Size ============================================================================================================================================================================================= Installing:  remi-release                                 noarch                                 6.9-1.el6.remi                                    /remi-release-6                                  12 k  Transaction Summary ============================================================================================================================================================================================= Install       i Package(s)  Total size: 12 k Installed size: 12 k Is this ok [y/N]: y 
6B- Install PHP56 Version
[root@cent  ]# yum install php56  php56-php-cli php56-php-common php56-php-pear  php56-php-process  php56-php-xml  php56-php-gd
5C- Check PHP Version
[root@cent  ]# php56 -v PHP 5.6.31 (cli) (built: Jul  six 2017 07:38:45) Copyright (c) 1997-2016 The PHP Group Zend Engine v2.6.0, Copyright (c) 1998-2016 Zend Technologies 
Both the PHP Versions has installed successfully.
Step 7- Configure  Virtual Host for  PHP version 5.3
We are going to work PHP-CGI to execute both the PHP version simultaneously.
7A-  First, rename php.conf file if exist. 

[root@cent  ]# mv /etc/httpd/conf.d/php.conf /etc/httpd/conf.d/php.conf.bak
7B- Setup FastCGI for PHP version 5.3
 First, practise a folder nether Virtual host document root directory.
[root@cent  ]#  mkdir -p /home/php53/public/cgi-bin/
7C- Create FastCGI configuration file.

Let's discovery your php.ini for PHP version 5.3 in addition to PHP-CGI using discovery command.
To discovery php.ini
[root@cent  ]# find / -name php.ini /etc/php.ini /opt/remi/php56/root/etc/php.ini
To discovery php-cgi
[root@cent  ]# find / -name php-cgi /opt/remi/php56/root/usr/bin/php-cgi /usr/bin/php-cgi 
7C- Create FastCGI configuration file.
[root@cent  ]#  vi /home/php53/public/cgi-bin/php.fastcgi
Append next business equally per inward a higher identify finding. In my example for PHP 5.3 is the deault path.

#!/bin/bash PHPRC="/etc/php.ini" PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=1000 export PHPRC export PHP_FCGI_CHILDREN export PHP_FCGI_MAX_REQUESTS exec /usr/bin/php-cgi 
Save in addition to Exit from the File.
7D- Make the script executable.
[root@cent  ]#  chmod +x /home/php53/public/cgi-bin/php.fastcgi
7E- Setup Virtual Host 
[root@cent  ]#  vi /etc/httpd/conf.d/php53.conf
Add next lines 

<VirtualHost *:80>     ServerAdmin asingh@ishir.com     DocumentRoot /home/php53/public/     ServerName php53.local     ErrorLog /home/php53/logs/error.log     CustomLog /home/php53/logs/access_log mutual         ScriptAlias /cgi-bin/ "/home/php53/public/cgi-bin/"     <Directory "/home/php53/public/">             Options +Indexes FollowSymLinks +ExecCGI             AddHandler php5-fastcgi .php             Action php5-fastcgi /cgi-bin/php.fastcgi             AllowOverride All             Order allow,deny             Allow from All     </Directory> </VirtualHost>  
Save in addition to Exit from the file.
7F- restart httpd.

[root@cent  ]#  service httpd restart
7G- Check PHP version.

[root@cent  ]# vi /home/php53/public/info.php
Append the next content.

<?php phpinfo(); ?> 
Save in addition to teach out from the file.
7H- Test PHP page. Hit the below URL to depository fiscal establishment fit php info.
http://php53.local/info.php
Step 8- Configure  Virtual Host for  PHP version 5.6:
Follow the steps below to configure FastCGI in addition to Virtual Host.
8A- Setup FastCGI for PHP version 5.6
First, practise a folder nether Virtual host document root directory.

[root@cent  ]#  mkdir -p /home/php56/public/cgi-bin/
8B- Create FastCGI configuration file.

[root@cent  ]#  vi /home/php56/public/cgi-bin/php.fastcgi
Append next line

#!/bin/bash PHPRC="/opt/remi/php56/root/etc/php.ini" PHP_FCGI_CHILDREN=4 PHP_FCGI_MAX_REQUESTS=1000 export PHPRC export PHP_FCGI_CHILDREN export PHP_FCGI_MAX_REQUESTS exec /opt/remi/php56/root/usr/bin/php-cgi  
Save in addition to Exit from the file.
8C- Make the script executable.

[root@cent  ]#  chmod +x /home/php56/public/cgi-bin/php.fastcgi
8d- Setup Virtual Host 

[root@cent  ]#  vi /etc/httpd/conf.d/php56.conf
Add next lines 

<VirtualHost *:80>     ServerAdmin asingh@ishir.com     DocumentRoot /home/php56/public/     ServerName php56.local     ErrorLog /home/php56/logs/error.log     CustomLog /home/php56/logs/access_log mutual         ScriptAlias /cgi-bin/ "/home/php56/public/cgi-bin/"     <Directory "/home/php56/public/">             Options +Indexes FollowSymLinks +ExecCGI             AddHandler php5-fastcgi .php             Action php5-fastcgi /cgi-bin/php.fastcgi             AllowOverride All             Order allow,deny             Allow from All     </Directory> </VirtualHost>  
Save in addition to Exit from the file.

8E- restart httpd.

[root@cent  ]#  service httpd restart
8F- Check PHP version.

[root@cent  ]# vi /home/php56/public/info.php
Append the next content.

<?php phpinfo(); ?> 

Save in addition to teach out from the file.
8G- Test PHP page- Hit the below URL to depository fiscal establishment fit php info.
http://php56.local/info.php

Both the PHP Version Configured successfully in addition to working equally expected.


Thank y'all for Reading this blog!!!

Sumber https://linuxhowtoguide.blogspot.com/

Tidak ada komentar:

Posting Komentar