Install Apache/PHP 7.2.9 on Fedora 28/27, CentOS/RHEL 7.5/6.10 - Comment Page: 2

This guide shows howto install Apache HTTP Server (httpd) with PHP 7.2.9 and following modules on Fedora 28/27/26, CentOS 7.5/6.10 and Red Hat (RHEL) 7.5/6.10 systems. OPcache (php-opcache) - The Zend OPcache provides faster PHP execution through opcode caching and optimization. APCu (php-pecl-apcu) - APCu userland caching CLI (php-cli) - Command-line interface for PHP PEAR (php-pear) - PHP Extension and Application Repository framework PDO (php-pdo) - A database access abstraction module for PHP applications MySQL (php-mysqlnd) - A module for PHP applications that use MySQL databases PostgreSQL (php-pgsql) - A PostgreSQL database module for PHP MongoDB...

268 comments on “Install Apache/PHP 7.2.9 on Fedora 28/27, CentOS/RHEL 7.5/6.10 - Comment Page: 2

1 2 3 4 9
    1. Thanks so much for this tutorial. It worked with one exception. I found the solution in the comments:

      “Sorry, Im a newbie in this… I’m trying to install Apache following your guide but I gotta error message after adding the instruction of

      Adding following line before COMMIT:

      -A RH-Firewall-1-INPUT -m state –state NEW -m tcp -p tcp –dport 80 -j ACCEPT

      After restart the iptables I gotta the following error message

      iptables: Flushing firewall rules: [ OK ]
      iptables: Setting chains to policy ACCEPT: filter [ OK ]
      iptables: Unloading modules: [ OK ]
      iptables: Applying firewall rules: iptables-restore: line 13 failed [FAILED]

      And I’d no access to the file test.php through the browser.
      Some ideas?
      Thanx in advance.

      Reply
      Diederik Veelo
      Posted May 27, 2011 at 2:02 PM
      Adding the folowing line below “:OUTPUT ACCEPT [0:0]” seems to remove the error:

      :RH-Firewall-1-INPUT – [0:0]”

      Again, keep up the good work. It really helps people like me!!

      Reply
      • Hi CentOS_dude,

        Try following iptables rule instead:

        
        -A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
        
        Reply
        • Hye JR, thanks for the update. Your code worked without any problems.

          Reply
    2. Hi, I was wondering how am I supposed to test the remote connection. Is the URL literally http://your.(mydomainnamehere)/test.php ?? or is the your not supposed to be there?? or how exactly do I go about testing the remote connection, BTW everything else worked perfect thank you for helping everyone out.

      Reply
      • Hi Henry,

        You could test it easily from some other machine. Set up Apache and then create test page, open firewall port and just test it… :) URL is that what you have specified on local network server.local.lan or some real domain name, like http://www.if-not-true-then-false.com.

        Reply
    3. Thanks.
      It works so nice.

      Reply
    4. disculpe la pregunta lo que pasa es que quiero instalar el wordpress en centos 5.5 y me piden php5.2.4 i386 y noce donde puedo encontrar
      noce si me puedan enviar un link de los repositorios ok
      gracias

      Reply
    5. thanks, somewhat i was having touble with php-mysql but this seemed to do the trick. Very to the point

      Reply
    6. [[email protected] ~]# /etc/init.d/httpd restart
      Restarting httpd (via systemctl): Job failed. See system logs and ‘systemctl status’ for details.
      [FAILED]

      WHAT SHOULD I DO????

      Reply
      • Hi Laukik,

        Please post first output of following commands:

        
        uname -a
        
        systemctl status httpd.service
        
        grep httpd /var/log/messages
        
        Reply
        • [[email protected] ~]# uname -a
          Linux root 3.1.0-7.fc16.i686.PAE #1 SMP Tue Nov 1 20:53:45 UTC 2011 i686 i686 i386 GNU/Linux

          [[email protected] ~]# systemctl status httpd.service
          httpd.service – The Apache HTTP Server (prefork MPM)
          Loaded: loaded (/lib/systemd/system/httpd.service; enabled)
          Active: failed since Thu, 29 Dec 2011 21:55:48 +0530; 4min 29s ago
          Process: 2575 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=dumped, signal=SEGV)
          CGroup: name=systemd:/system/httpd.service

          Reply
          • [[email protected] ~]# uname -a
            Linux root 3.1.0-7.fc16.i686.PAE #1 SMP Tue Nov 1 20:53:45 UTC 2011 i686 i686 i386 GNU/Linux
            [[email protected] ~]# systemctl status httpd.service
            httpd.service – The Apache HTTP Server (prefork MPM)
            Loaded: loaded (/lib/systemd/system/httpd.service; enabled)
            Active: failed since Thu, 29 Dec 2011 21:55:48 +0530; 4min 29s ago
            Process: 2575 ExecStart=/usr/sbin/httpd $OPTIONS -k start (code=dumped, signal=SEGV)
            CGroup: name=systemd:/system/httpd.service
            [[email protected] ~]# grep httpd /var/log/messages
            Dec 28 21:51:22 root httpd[2682]: httpd: Could not reliably determine the server’s fully qualified domain name, using fe80::227:eff:fe39:3127 for ServerName
            Dec 28 21:51:22 root kernel: [ 1430.410455] httpd[2682]: segfault at d ip 005e59f5 sp bf9bcc10 error 4 in mod_perl.so[5c9000+33000]

            Reply
            • Do you need mod_perl?

              Reply
                • mod_perl is An embedded Perl interpreter for the Apache HTTP Server.

                  You have mod_perl package installed, some reason? And mod_perl have bug on Fedora 16 which prevent your httpd starting and cause segfaults.

                  Actually according to bug report it should be fixed if you update to latest version of mod_perl, so try following (as root):

                  
                  yum update mod_perl*
                  

                  Then try to start httpd again…please let me know if it’s still not working? :)

                  Reply
    7. Hello Plz help me for change port 80 to 8088
      founf below error

      Failed to start apache :
      Starting httpd: httpd: apr_sockaddr_info_get() failed for connect
      httpd: Could not reliably determine the server’s fully qualified domain name, using 127.0.0.1 for ServerName
      (13)Permission denied: make_sock: could not bind to address [::]:8088
      (13)Permission denied: make_sock: could not bind to address 0.0.0.0:8088
      no listening sockets available, shutting down
      Unable to open logs
      [FAILED]

      Reply
      • Hi daven patel,

        Do you run httpd start command as root user?

        Please post output of following command:

        
        grep -i listen /etc/httpd/conf/httpd.conf |grep -v '^#'
        
        Reply
    8. Help me…
      I’m use lampp & Install httpd. What can proceed smoothly without conflicts?

      Reply
      • Hi Nurul,

        Sorry, but I didn’t understand what is problem, if you use lampp (or lamp)? So you already have httpd?

        Reply
    9. I have installed RHEL 6.2 but the php packages that are available from their “@rhel-x86_64-server-6” package does not contain mbstring.

      Mgmt says we should only user rhel packages and not anyone else’s.

      How can we install the php-mbstring then?

      Installed Packages
      php.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-cli.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-common.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-gd.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-ldap.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-mysql.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-odbc.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-pdo.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-pear.noarch 1:1.9.4-4.el6 @rhel-x86_64-server-6
      php-pecl-apc.x86_64 3.1.3p1-1.2.el6.1 @rhel-x86_64-server-6
      php-pecl-memcache.x86_64 3.0.5-3.el6 @rhel-x86_64-server-6
      php-pgsql.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-soap.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-xml.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6
      php-xmlrpc.x86_64 5.3.3-3.el6_1.3 @rhel-x86_64-server-6

      thanks

      Larry

      Reply
      • Hi Larry,

        Could you post output of following command:

        
        yum repolist all
        
        Reply
    10. HI !
      Thanks for the tutorial ! would you please tell me how to enable or install pdo_mysql driver in php 5.3.9 in linux centos 6 64bit.

      Reply
      • Hi jules,

        You are welcome! :)

        To enable/install pdo_mysql following packages should be enough:

        
        yum install httpd php php-common php-pdo php-mysql
        

        Simply check it from phpinfo() or test use pdo_mysql.

        Please let me know, if you have some problems? :)

        Reply
        • Hi JR !
          Thanks. I still have some problem with my php .
          When i run a script with pdo sqlite code ,
          it shows
          “ERROR: Could not connect:could not find driver”

          [[email protected] ~]# php -v
          PHP 5.3.9 (cli) (built: Jan 10 2012 19:59:29)
          Copyright (c) 1997-2012 The PHP Group
          Zend Engine v2.3.0, Copyright (c) 1998-2012 Zend Technologies

          and
          [[email protected] ~]# rpm -qa php\*php-sqlite-5.3.9-1.el6.remi.x86_64
          phpMyAdmin-3.4.9-1.el6.remi.noarch
          php-xml-5.3.9-1.el6.remi.x86_64
          php-cli-5.3.9-1.el6.remi.x86_64
          php-pecl-memcached-1.0.2-9.el6.remi.x86_64
          php-5.3.9-1.el6.remi.x86_64
          php-mcrypt-5.3.9-1.el6.remi.x86_64
          php-pdo-5.3.9-1.el6.remi.x86_64
          php-pecl-igbinary-1.1.1-2.el6.remi.x86_64
          php-pecl-mongo-1.2.7-1.el6.remi.x86_64
          php-pgsql-5.3.9-1.el6.remi.x86_64
          php-pecl-memcache-3.0.6-2.el6.remi.x86_64
          php-mysql-5.3.9-1.el6.remi.x86_64
          php-gd-5.3.9-1.el6.remi.x86_64
          php-common-5.3.9-1.el6.remi.x86_64
          php-pecl-apc-3.1.9-3.el6.remi.x86_64
          php-mbstring-5.3.9-1.el6.remi.x86_64
          php-pear-1.9.4-3.el6.remi.noarch
          php-devel-5.3.9-1.el6.remi.x86_64

          will you please help me !because i would like to do my final project with sqlite .

          Reply
          • Install php-sqlite also with:

            
            yum --enablerepo=remi install php-sqlite
            

            If you have web project then restart web server and try again… :)

            Reply
    11. hi JR!
      ithink php-sqlite is already installed but still asking for the driver

      it still complain
      ERROR: Could not connect:could not find driver
      what can i do ?

      Reply
      • Hi jules,

        Could you post output of following command:

        
        rpm -qa php\* |sort
        

        Did you restart your web server?

        Could you check your phpinfo, is pdo_sqlite enabled?

        Reply
    12. Hello JR !
      this the output of the command
      [[email protected] ~]# rpm -qa php\* |sort
      php-5.3.9-1.el6.remi.x86_64
      php-cli-5.3.9-1.el6.remi.x86_64
      php-common-5.3.9-1.el6.remi.x86_64
      php-devel-5.3.9-1.el6.remi.x86_64
      php-gd-5.3.9-1.el6.remi.x86_64
      php-mbstring-5.3.9-1.el6.remi.x86_64
      php-mcrypt-5.3.9-1.el6.remi.x86_64
      phpMyAdmin-3.4.9-1.el6.remi.noarch
      php-mysql-5.3.9-1.el6.remi.x86_64
      php-pdo-5.3.9-1.el6.remi.x86_64
      php-pear-1.9.4-4.el6.noarch
      php-pecl-apc-3.1.9-3.el6.remi.x86_64
      php-pecl-igbinary-1.1.1-3.el6.x86_64
      php-pecl-memcache-3.0.6-2.el6.remi.x86_64
      php-pecl-memcached-1.0.2-9.el6.remi.x86_64
      php-pecl-mongo-1.2.7-1.el6.remi.x86_64
      php-sqlite-5.3.9-1.el6.remi.x86_64
      php-xml-5.3.9-1.el6.remi.x86_64

      in the phpinfo page, i checked pdo-sqlite is enabled this way

      pdo_sqlite
      PDO Driver for SQLite 3.x enabled
      SQLite Library 3.7.6.3

      but still complain could not find the driver . Please help me .

      Reply
      • Thanks jules!

        Really strange, because everything looks ok, then next thing is check your code…and maybe even try to reproduce your error on another system…

        So could you please post some code snippet, which should work?

        Reply
    13. this my code :

      Project 11-1: Validating Form Input

      div.error{
      color: red;
      font-weight: bolder;
      }
      div.success{
      color: green;
      font-weight: bolder;
      }

      Project 11-1:Validating Form Input
      Enter Book Details
      <?php
      //display input validation error
      function getInputError($key,$errArray) {
      if(in_array($key,$errArray)){
      return "ERROR: Invalid data for field ‘$key'”;
      }else {
      return false;
      }
      }
      $inputErrors=array();
      $submitted=false;
      //if form submitted
      //validate form input
      if(isset($_POST[‘submit’])){
      $submitted=true;
      $valid=array();

      //validate title

      if(!empty($_POST[‘title’])) {
      $valid[‘title’]=htmlentities(trim($_POST[‘title’]));
      } else {
      $inputErrors[]=’author’;
      }
      //validate author name
      if(!empty($_POST[‘author’])&& preg_match(“/^[a-zA-Z\s.\-]+$/”,$_POST[‘author’])){
      $valid[‘author’]=htmlentities(trim($_POST[‘author’]));
      }
      else {
      $inputError[]=’author’;
      }
      //validate ISBN

      if(!empty($_POST[‘isbn’]) && preg_match(‘/^(97(8|9))?\d{9}(\d|X)$/’,$_POST[‘isbn’])){
      $valid[‘isbn’]=htmlentities(trim($POST[‘isbn’]));
      }
      else {
      $inputError[]=’isbn’;
      }
      //validate price
      if(!empty($_POST[‘price’]) && is_numeric($_POST[‘price’]) && $_POST[‘price’] >0){
      $valid[‘price’]=htmlentities(trim($_POST[‘price’]));
      }else {
      $inputErrors[]=’price’;
      }
      }
      //if form not submitted
      //or if validation errors exist
      //redisplay form

      if(($submitted==true && count($inputErrors)>0)|| $submitted==false){

      ?>

      Title :
      <input type="text" size="25" name="title" value="”/>

      Author :
      <input type="text" size="25" name="author" value="”/>

      ISBN :
      <input type="text" size="25" name="isbn" value="”/>

      Price :
      <input type="text" size="25" name="price" value="”/>

      setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      }catch(PDOException $e){
      die(“ERROR: Could not connect:”.$e->getMessage());
      }
      //create and execute INSERT query
      try{
      $title=$pdo->quote($valid[‘title’]);
      $author=$pdo->quote($valid[‘author’]);
      $isbn=$pdo->quote($valid[‘isbn’]);
      $price=$pdo->quote($valid[‘price’]);
      $sql=”INSERT INTO books(title,author,isbn,price) VALUES($title,$author,$isbn,$price)”;
      $ret=$pdo->exec($sql);
      echo’SUCCESS:Record saved !’;
      } catch(Exception $e){
      echo’ERROR:’.$e->getMessage().”;
      }
      unset($pdo);
      }
      ?>

      Reply
      • Hi jules,

        Here is some code missing here:

        
        Price :
        
        ???
        setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
        }catch(PDOException $e){
        die("ERROR: Could not connect:".$e->getMessage());
        }
        
        Reply
    14. Hi JR !
      the whole code is

      Project 11-1: Validating Form Input

      div.error{
      color: red;
      font-weight: bolder;
      }
      div.success{
      color: green;
      font-weight: bolder;
      }

      Project 11-1:Validating Form Input
      Enter Book Details
      <?php
      //display input validation error
      function getInputError($key,$errArray) {
      if(in_array($key,$errArray)){
      return "ERROR: Invalid data for field ‘$key'”;
      }else {
      return false;
      }
      }
      $inputErrors=array();
      $submitted=false;
      //if form submitted
      //validate form input
      if(isset($_POST[‘submit’])){
      $submitted=true;
      $valid=array();

      //validate title

      if(!empty($_POST[‘title’])) {
      $valid[‘title’]=htmlentities(trim($_POST[‘title’]));
      } else {
      $inputErrors[]=’author’;
      }
      //validate author name
      if(!empty($_POST[‘author’])&& preg_match(“/^[a-zA-Z\s.\-]+$/”,$_POST[‘author’])){
      $valid[‘author’]=htmlentities(trim($_POST[‘author’]));
      }
      else {
      $inputError[]=’author’;
      }
      //validate ISBN

      if(!empty($_POST[‘isbn’]) && preg_match(‘/^(97(8|9))?\d{9}(\d|X)$/’,$_POST[‘isbn’])){
      $valid[‘isbn’]=htmlentities(trim($POST[‘isbn’]));
      }
      else {
      $inputError[]=’isbn’;
      }
      //validate price
      if(!empty($_POST[‘price’]) && is_numeric($_POST[‘price’]) && $_POST[‘price’] >0){
      $valid[‘price’]=htmlentities(trim($_POST[‘price’]));
      }else {
      $inputErrors[]=’price’;
      }
      }
      //if form not submitted
      //or if validation errors exist
      //redisplay form

      if(($submitted==true && count($inputErrors)>0)|| $submitted==false){

      ?>

      Title :
      <input type="text" size="25" name="title" value="”/>

      Author :
      <input type="text" size="25" name="author" value="”/>

      ISBN :
      <input type="text" size="25" name="isbn" value="”/>

      Price :
      <input type="text" size="25" name="price" value="”/>

      setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
      }catch(PDOException $e){
      die(“ERROR: Could not connect:”.$e->getMessage());
      }
      //create and execute INSERT query
      try{
      $title=$pdo->quote($valid[‘title’]);
      $author=$pdo->quote($valid[‘author’]);
      $isbn=$pdo->quote($valid[‘isbn’]);
      $price=$pdo->quote($valid[‘price’]);
      $sql=”INSERT INTO books(title,author,isbn,price) VALUES($title,$author,$isbn,$price)”;
      $ret=$pdo->exec($sql);
      echo’SUCCESS:Record saved !’;
      } catch(Exception $e){
      echo’ERROR:’.$e->getMessage().”;
      }
      unset($pdo);
      }
      ?>

      Do you still think the code is missing ?

      Reply
      • Hi jules,

        Your code is still missing end of if block, start of try-catch block and connection to SQLite3 database

        I decide to write PHP / PDO / SQLite3 example code to you… :)

        You can run it command line…it also shows howto to use prepared statements… :)

        Reply
    15. i copied pasted the code on my bluefish then when i run the page , it said

      SQLSTATE[HY000] [14] unable to open database file
      Any idea on how to handle this please ! i am really tired of reinstalling php with no solution

      Reply
      • Sounds permission problem. So if you save this file example with name sqlite-example.php to /tmp directory and run on command line with following command (you need php-cli package):

        
        cd /tmp
        php sqlite-example.php
        

        Is it working then?

        Reply
1 2 3 4 9

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Close