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,216
ReynierPM
  • 742

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,216
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