If Not True Then False

Install Apache/PHP 7.1.0 on Fedora 25/24, CentOS/RHEL 7.3/6.8 - Comment Page: 2

This guide shows howto install Apache HTTP Server (httpd) with PHP 7.1.0 and following modules on Fedora 25/24/23, CentOS 7.3/6.8 and Red Hat (RHEL) 7.3/6.8 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...
Categories:

256 Comments

Leave a Comment

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

Input your comment.
help

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

Input your name.

Henry

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 Reply
JR

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 Reply
socrates

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 Reply
Brennero

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

reply Reply
Laukik

[root@root ~]# /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 Reply
JR

Hi Laukik,

Please post first output of following commands:


uname -a

systemctl status httpd.service

grep httpd /var/log/messages
reply Reply
Laukik

[root@root ~]# 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

[root@root ~]# 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 Reply
Laukik

[root@root ~]# 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
[root@root ~]# 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
[root@root ~]# 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 Reply
JR

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 Reply
deven patel

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 Reply
JR

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 Reply
Nurul Imam

Help me…
I’m use lampp & Install httpd. What can proceed smoothly without conflicts?

reply Reply
JR

Hi Nurul,

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

reply Reply
Larry

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 Reply
JR

Hi Larry,

Could you post output of following command:


yum repolist all
reply Reply
jules

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 Reply
JR

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 Reply
jules

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”

[root@localhost ~]# 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
[root@localhost ~]# 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 Reply
JR

Install php-sqlite also with:


yum --enablerepo=remi install php-sqlite

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

reply Reply
jules

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 Reply
JR

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 Reply
jules

Hello JR !
this the output of the command
[root@aca800a0 ~]# 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 Reply
JR

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 Reply
jules

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 Reply
JR

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 Reply
jules

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 Reply
JR

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 Reply
jules

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 Reply
JR

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 Reply
jules

Yeah ! thanks JR ! it s working , but would u mind to help me if possible so as it can work in /var/www/html/sqlite-example.php?

reply Reply
JR

Okay so code is working normally and your PHP / PDO / SQLite is working normally. It sounds definitely permission problem. Do php file with following content:


< ?php
  $fp = fopen('test.txt', 'w');
  fwrite($fp, 'test');
  fwrite($fp, ' test 2');
  fclose($fp);
?>

Run it…do you get any errors? Or do you get test.txt file, with “test test 2” content?

reply Reply