Install httpd24, php56 and php70 as SCL is not working with error "file not found"
I have test the same steps, it works for me :(
Please check you have change all and only /opt/rh/httpd24/root/var/www to /var/www (despite I don't really understand why you want this):
# grep www /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf | grep -v "^#"
DocumentRoot "/var/www/html"
<Directory "/var/www">
<Directory "/var/www/html">
# Redirect permanent /foo http://www.example.com/bar
ScriptAlias /cgi-bin/ "/var/www/cgi-bin/"
<Directory "/var/www/cgi-bin">
Then, missing in above steps: switch php70-php-fpm to listen to another port (9002 for me), and set correct SELInux for it:
# semanage port -a -t http_port_t -p tcp 9002
Then, I create 2 names (el6php56 and el6php70) for vhost management, and add the Apache configuration file to redirect PHP files in each vhost to the correct FPM service:
# cat /opt/rh/httpd24/root/etc/httpd/conf.d/vhost.conf
<VirtualHost *:80>
ServerName el6php56
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9000"
</FilesMatch>
</VirtualHost>
<VirtualHost *:80>
ServerName el6php70
<FilesMatch \.php$>
SetHandler "proxy:fcgi://127.0.0.1:9002"
</FilesMatch>
</VirtualHost>
Then (default/first vhost will use php 5.6)
- http://el6php56/info.php display phpinfo for PHP 5.6
- http://el6php70/info.php display phpinfo for PHP 7.0
Related videos on Youtube
ReynierPM
Updated on September 18, 2022Comments
-
ReynierPM almost 2 years
Let's start saying that I have read this, this and this at Remi Blog since the question it related to those repositories. The blog entries is not helping me at all or I am missing something here but I am not sure what is. I will expose below which steps I have followed and let's see what I am doing wrong. I am planning to install PHP 5.6.x and PHP 7.0 as SCL (because I need to test some applications on both and I need to keep PHP 5.6.x support due to some Wordpress development) and I will use Apache 2.4.x through SetHandler so below are the steps:
-
Install the Software Collections tools:
yum install scl-utils
-
Download a package with repository for your system (in this case for httpd24)
wget http://www.softwarecollections.org/en/scls/rhscl/httpd24/epel-6-x86_64/download/rhscl-httpd24-epel-6-x86_64.noarch.rpm
-
Install the repo package:
yum install rhscl-httpd24-epel-6-x86_64.noarch.rpm
-
Install the collection:
yum install httpd24
-
Start using software collections:
scl enable httpd24 bash
-
Start httpd24 service (default option)
service httpd24-httpd start
-
Install PHP56 as SCL:
yum install php56 php56-php-common php56-php-cli php56-php-fpm php56-php-gd php56-php-intl php56-php-mbstring php56-php-mcrypt php56-php-opcache php56-php-pdo php56-php-pear php56-php-pecl-apcu php56-php-imagick php56-php-pecl-xdebug php56-php-pgsql php56-php-xml php56-php-mysqlnd php56-php-pecl-jsonc php56-php-pecl-zip php56-php-process php56-runtime
-
Start PHP56-FPM:
service php56-php-fpm start
-
Install PHP70 as SCL:
yum install php70 php70-php-common php70-php-cli php70-php-fpm php70-php-gd php70-php-intl php70-php-mbstring php70-php-mcrypt php70-php-opcache php70-php-pdo php70-php-pear php70-php-pecl-apcu php70-php-imagick php70-php-pecl-xdebug php70-php-pgsql php70-php-xml php70-php-mysqlnd php70-php-pecl-jsonc php70-php-pecl-zip php70-php-process php70-runtime
-
Test Apache is installed and running:
http://mylocalip
And success I can see Apache default page for RedHat/CentOS. All good so far. I have created a file under
/var/www/html/info.php
with the following code:<?php phpinfo(); ?>
When I try to reach by running:
http://mylocalip/info.php
It says file not found so Apache is going to the wrong place, that's fine then I edit the file under
/opt/rh/httpd24/root/etc/httpd/conf/httpd.conf
and changeDocumentRoot
from/opt/rh/httpd24/root/var/www/html
to/var/www/html
and I did the same change everywhere I found the same issue, I have restarted Apache and tried again but I got the same error. I have checked permissions for/var/www/html
and this is how they looks like:# ls -l /var/www/ drwxrwsr-x 3 apache root 4096 Nov 13 04:51 html
what I miss here? What I am doing wrong? Can any give me some ideas or help on this?
-
-
ReynierPM over 8 yearsThanks for your answer, I have done exactly what you put in your response and these are the results: the output of
grep www /opt/rh/httpd24/root/etc/httpd/conf/httpd.conf | grep -v "^#"
is exactly the same as yours. Where exactly is thephp-fpm.conf
for PHP7? I did found the PHP56 one under/opt/remi/php56/root/etc
but can't find one for PHP70. Then going tohttp://el6php56/info.php
give me a 500 error, going throughhttp://el6php70/info.php
give meService Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems.
-
ReynierPM over 8 yearsbtw I did tried to change listen port for PHP56 permanently under
/opt/remi/php56/root/etc/php-fpm.d/www.conf
setting this line aslisten = 127.0.0.1:9056
-
ReynierPM over 8 yearsThis is the log when I tried to access
http://el6php70/info.php
-[Sat Nov 14 04:43:36.434441 2015] [proxy:error] [pid 2997:tid 139792647804672] (111)Connection refused: AH00957: FCGI: attempt to connect to 127.0.0.1:9002 (*) failed [Sat Nov 14 04:43:36.434583 2015] [proxy_fcgi:error] [pid 2997:tid 139792647804672] [client 192.168.3.1:63542] AH01079: failed to make connection to backend: 127.0.0.1
-
Remi Collet over 8 yearsObviously FPM listen port must match SetHandler port used in Apache configuration. If the service is correctly configured and is running, If connection fails, this can be related to SELinux, see command in above answer.
-
ReynierPM over 8 yearsI've installed a fresh copy of CentOS and followed every step on this post also the ones you show me and all is working now, thanks for your support