Showing posts with label PHP. Show all posts
Showing posts with label PHP. Show all posts

How to install PHP 7.0,7.1 and 7.2 on CentOS 7 server step by step guide.



In this article we learn how to install PHP 7.0,7.1 and 7.2 on centos 7 server.
PHP 5.4 is available in centos 7 main repository . To install PHP 7.x we need to install remi repository on the centos server. To do this we need to execute the below steps.

Installation Steps of PHP 7.0, 7.1 & 7.2 on CentOS 7 Server

To install remi repo first we need to install EPEL repo and yum-utils .To install these packages we need to execute the below command.
[root@localhost ~]#yum install epel-release yum-utils –y
After doing this we can install remi repo using the below command.
[root@localhost ~]#yum install http://rpms.remirepo.net/enterprise/remi-release-7.rpm
 Base on your requirement, configure the PHP 7.x repository
To configure PHP 7.0 repository, execute below command,
[root@localhost ~]#yum-config-manager --enable remi-php70
To configure PHP 7.1 repository, execute below command,
[root@localhost ~]#yum-config-manager --enable remi-php71
To configure PHP 7.2 repository, execute below command
[root@localhost ~]#yum-config-manager --enable remi-php72
After doing the above tasks we execute the below command to install the php packages.
[root@localhost ~]#yum install php php-common php-opcache php-mcrypt php-cli php-gd php-curl php-mysql -y
To verify which php package is installed to execute the below command.
 [root@localhost ~]#php –v
PHP 7.0.33 (cli) (built: Dec  5 2018 14:22:44) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.33, Copyright (c) 1999-2017, by Zend Technologies
How to install PHP 7.0,7.1 and 7.2 on CentOS 7 server step by step guide.
How to install PHP 7.0,7.1 and 7.2 on CentOS 7 server step by step guide.







How to install and simple setup LAMP stack on CentOS 7 step by step guide


In this article we learn what is LAMP stack and how to install and setup LAMP stack  on centos 7.

What is LAMP stack

LAMP stack is used to host web site as well as web application on server.LAMP stand for Linux,Apache(to host the web site),Mysql (to store the data used as a database server),Php (for php application).

Install Apache web server on centos 7

To install apache server execute the below command.
[root@localhost ~]# yum install httpd

After installing the APACHE server we need to turn on(enable the APACHE service at the startup mode) httpd service to turn on the service we execute the below command.
For linux(5/6)
#chkconfig httpd on
For linux 7
#systemctl enable httpd

 To start,stop and restart the APACHE service we need to execute the below command.
For linux(5/6)
#service httpd start
#service httpd stop
#service httpd restart

For linux 7
#systemctl start httpd
#systemctl stop httpd
#systemctl restart httpd
How to install and simple setup  LAMP stack on CentOS 7  step by step guide

How to install and simple setup  LAMP stack on CentOS 7  step by step guide



Install Mariadb server on centos 7

To install MariaDB on CentOS 7 we need to execute the below command.
#yum install mariadb-server mariadb

To start and enable the MariaDB service on CentOS 7 we need to execute the below command.
#systemctl start mariadb
#systemctl enable mariadb

CentOS 7  uses firewalld as a software firewall instead of iptables. By default MariaDB server is running on 3306 port. We need to allow this port into firewall rule to access it. To allow the incoming connection to the standard MySQL tcp port we need to execute the below command.
#firewall-cmd  - -permanent  - -add-service=mysql
#firewall-cmd  -- reload

To secure MariaDB we use “mysql_secure_installation” .After executing the “mysql_secure_installation” command we need to set root password,remove test database, remove anonymous user login and disable the remote login.

#mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading privilege tables..
 ... Success!


By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

After that restart the service using the below command.

#systemctl restart mariadb


Install PHP on centos 7

To install php on centos server we need to execute the below command.
yum install php php-mysql php-gd
after executing this above command we need to restart the httpd service using the below command.
#systemctl restart httpd

That’s all. We have configured the LAMP stack. If this article is helpful please share it!!!!!


How to find PHP version on linux system step by step guide


How to find PHP version on linux system step by step guide


In this article we learn how to check PHP version on linux system.To check the PHP version we execute below commands .

[root@localhost ~]# php -v
PHP 5.3.3 (cli) (built: Jan 10 2017 22:26:04)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

And also we execute the below command to know the php version.

[root@localhost ~]# php --version
PHP 5.3.3 (cli) (built: Jan 10 2017 22:26:04)
Copyright (c) 1997-2010 The PHP Group
Zend Engine v2.3.0, Copyright (c) 1998-2010 Zend Technologies

If the above command is not work you should install php package in you linux system.

[root@localhost ~]# yum install php
Loaded plugins: ulninfo
Setting up Install Process
Resolving Dependencies
--> Running transaction check
---> Package php.x86_64 0:5.3.3-49.el6 will be installed
--> Processing Dependency: php-cli(x86-64) = 5.3.3-49.el6 for package: php-5.3.3-49.el6.x86_64
--> Processing Dependency: php-common(x86-64) = 5.3.3-49.el6 for package: php-5.3.3-49.el6.x86_64
--> Processing Dependency: httpd-mmn = 20051115 for package: php-5.3.3-49.el6.x86_64
--> Processing Dependency: httpd for package: php-5.3.3-49.el6.x86_64
--> Running transaction check
---> Package httpd.x86_64 0:2.2.15-69.0.1.el6 will be installed
--> Processing Dependency: httpd-tools = 2.2.15-69.0.1.el6 for package: httpd-2.2.15-69.0.1.el6.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.2.15-69.0.1.el6.x86_64
--> Processing Dependency: apr-util-ldap for package: httpd-2.2.15-69.0.1.el6.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.2.15-69.0.1.el6.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.2.15-69.0.1.el6.x86_64
---> Package php-cli.x86_64 0:5.3.3-49.el6 will be installed
--> Processing Dependency: libedit.so.0()(64bit) for package: php-cli-5.3.3-49.el6.x86_64
---> Package php-common.x86_64 0:5.3.3-49.el6 will be installed
--> Running transaction check
---> Package apr.x86_64 0:1.3.9-5.el6_9.1 will be installed
---> Package apr-util.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1 will be installed
---> Package httpd-tools.x86_64 0:2.2.15-69.0.1.el6 will be installed
---> Package libedit.x86_64 0:2.11-4.20080712cvs.1.el6 will be installed
---> Package mailcap.noarch 0:2.1.31-2.el6 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================
 Package         Arch     Version                     Repository           Size
================================================================================
Installing:
 php             x86_64   5.3.3-49.el6                public_ol6_latest   1.1 M
Installing for dependencies:
 apr             x86_64   1.3.9-5.el6_9.1             public_ol6_latest   123 k
 apr-util        x86_64   1.3.9-3.el6_0.1             public_ol6_latest    87 k
 apr-util-ldap   x86_64   1.3.9-3.el6_0.1             public_ol6_latest    15 k
 httpd           x86_64   2.2.15-69.0.1.el6           public_ol6_latest   835 k
 httpd-tools     x86_64   2.2.15-69.0.1.el6           public_ol6_latest    80 k
 libedit         x86_64   2.11-4.20080712cvs.1.el6    public_ol6_latest    74 k
 mailcap         noarch   2.1.31-2.el6                public_ol6_latest    26 k
 php-cli         x86_64   5.3.3-49.el6                public_ol6_latest   2.2 M
 php-common      x86_64   5.3.3-49.el6                public_ol6_latest   529 k

Transaction Summary
================================================================================
Install      10 Package(s)

Total download size: 5.0 M
Installed size: 17 M
Is this ok [y/N]: y
Downloading Packages:
(1/10): apr-1.3.9-5.el6_9.1.x86_64.rpm                   | 123 kB     00:01
(2/10): apr-util-1.3.9-3.el6_0.1.x86_64.rpm              |  87 kB     00:00
(3/10): apr-util-ldap-1.3.9-3.el6_0.1.x86_64.rpm         |  15 kB     00:00
(4/10): httpd-2.2.15-69.0.1.el6.x86_64.rpm               | 835 kB     00:04
(5/10): httpd-tools-2.2.15-69.0.1.el6.x86_64.rpm         |  80 kB     00:00
(6/10): libedit-2.11-4.20080712cvs.1.el6.x86_64.rpm      |  74 kB     00:00
(7/10): mailcap-2.1.31-2.el6.noarch.rpm                  |  26 kB     00:00
(8/10): php-5.3.3-49.el6.x86_64.rpm                      | 1.1 MB     00:02
(9/10): php-cli-5.3.3-49.el6.x86_64.rpm                  | 2.2 MB     00:05
(10/10): php-common-5.3.3-49.el6.x86_64.rpm              | 529 kB     00:01
--------------------------------------------------------------------------------
Total                                           196 kB/s | 5.0 MB     00:26
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
  Installing : apr-1.3.9-5.el6_9.1.x86_64                                  1/10
  Installing : apr-util-1.3.9-3.el6_0.1.x86_64                             2/10
  Installing : php-common-5.3.3-49.el6.x86_64                              3/10
  Installing : httpd-tools-2.2.15-69.0.1.el6.x86_64                        4/10
  Installing : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                        5/10
  Installing : mailcap-2.1.31-2.el6.noarch                                 6/10
  Installing : httpd-2.2.15-69.0.1.el6.x86_64                              7/10
  Installing : libedit-2.11-4.20080712cvs.1.el6.x86_64                     8/10
  Installing : php-cli-5.3.3-49.el6.x86_64                                 9/10
  Installing : php-5.3.3-49.el6.x86_64                                    10/10
  Verifying  : libedit-2.11-4.20080712cvs.1.el6.x86_64                     1/10
  Verifying  : httpd-tools-2.2.15-69.0.1.el6.x86_64                        2/10
  Verifying  : apr-util-ldap-1.3.9-3.el6_0.1.x86_64                        3/10
  Verifying  : httpd-2.2.15-69.0.1.el6.x86_64                              4/10
  Verifying  : php-5.3.3-49.el6.x86_64                                     5/10
  Verifying  : apr-1.3.9-5.el6_9.1.x86_64                                  6/10
  Verifying  : mailcap-2.1.31-2.el6.noarch                                 7/10
  Verifying  : php-common-5.3.3-49.el6.x86_64                              8/10
  Verifying  : apr-util-1.3.9-3.el6_0.1.x86_64                             9/10
  Verifying  : php-cli-5.3.3-49.el6.x86_64                                10/10

Installed:
  php.x86_64 0:5.3.3-49.el6

Dependency Installed:
  apr.x86_64 0:1.3.9-5.el6_9.1
  apr-util.x86_64 0:1.3.9-3.el6_0.1
  apr-util-ldap.x86_64 0:1.3.9-3.el6_0.1
  httpd.x86_64 0:2.2.15-69.0.1.el6
  httpd-tools.x86_64 0:2.2.15-69.0.1.el6
  libedit.x86_64 0:2.11-4.20080712cvs.1.el6
  mailcap.noarch 0:2.1.31-2.el6
  php-cli.x86_64 0:5.3.3-49.el6
  php-common.x86_64 0:5.3.3-49.el6

Complete!

To check php package is installed or not


To check the php package installed or not on your linux system you should execute the below command.

[root@localhost ~]# rpm -qa php*
php-5.3.3-49.el6.x86_64
php-common-5.3.3-49.el6.x86_64
php-cli-5.3.3-49.el6.x86_64

check the PHP version using web browser


To check the PHP version and more information about PHP using web browser we should follow the below steps.
#edit the file   /var/www/html/infophp.php  and the below lines.

[root@localhost html]# cat infophp.php
<?php
phpinfo();
?>
Type  http://serverip/infophp.php  and find the output in below format

How to find PHP version on linux system step by step guide

                                           How to find PHP version on linux system step by step guide