2

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:

  1. Install the Software Collections tools:

    yum install scl-utils
    
  2. 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
    
  3. Install the repo package:

    yum install rhscl-httpd24-epel-6-x86_64.noarch.rpm
    
  4. Install the collection:

    yum install httpd24
    
  5. Start using software collections:

    scl enable httpd24 bash
    
  6. Start httpd24 service (default option)

    service httpd24-httpd start
    
  7. 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
    
  8. Start PHP56-FPM:

    service php56-php-fpm start
    
  9. 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
    
  10. 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 change DocumentRoot 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?

Remi Collet
  • 2,061
  • 1
  • 11
  • 12
ReynierPM
  • 700
  • 5
  • 14
  • 28

2 Answers2

6

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)

Remi Collet
  • 2,061
  • 1
  • 11
  • 12
  • Thanks 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 the `php-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 to `http://el6php56/info.php` give me a 500 error, going through `http://el6php70/info.php` give me `Service Unavailable The server is temporarily unable to service your request due to maintenance downtime or capacity problems.` – ReynierPM Nov 14 '15 at 13:36
  • btw I did tried to change listen port for PHP56 permanently under `/opt/remi/php56/root/etc/php-fpm.d/www.conf` setting this line as `listen = 127.0.0.1:9056` – ReynierPM Nov 14 '15 at 13:38
  • This 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` – ReynierPM Nov 14 '15 at 13:44
  • Obviously 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. – Remi Collet Nov 14 '15 at 16:59
  • I'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 – ReynierPM Nov 18 '15 at 14:49
0

I just ran into this myself. I see that you are using /opt/rh/httpd24/root/var/www instead of /var/www because you'd like to use httpd24-http. Afaik there is a difference in how SELinux handels /opt/rh/httpd24/root/var/www and /var/www. Try 'setenforce 0' to check if it is a SELinux issue. Use 'setenforce 1' to get back enforcing.

The php70 config is here: /etc/opt/rh/rh-php70