I intended to throw my steps out there in more detail but life got in the way. YMMV but this is what worked for me.
First, I download the latest stable of php7 from
https://www.php.net/downloads.phpThen, I removed all rpm packages that were php8 based. This included things like apache-mod_php. If you have settings in the php.ini, save that file off before you remove all the rpm's for php8.
Then I installed apache-devel package. This is needed in preparation for compiling php7.
- Code: Select all
urpmi apache-devel
I then untarred the php7 package I downloaded. This temporary location can be anywhere you want. You can also do this as the non-root user if you want to.
- Code: Select all
tar xfz php-7.4.16.tar.gz
Also, don't forget to create the destination directory if you're not going with defaults. For me, I wanted my destination to be /opt/php7
- Code: Select all
As root: $ mkdir -m 755 /opt/php7
Now that you have the source code untarred, you'll want to run configure. These are the flags and options I used:
- Code: Select all
./configure --prefix /opt/php7 --with-config-file-scan-dir=/etc/php.d --with-curl --enable-exif --enable-ftp --enable-gd --with-gettext --enable-mbstring --with-mysqli --enable-mysqlnd --with-openssl --enable-phpdbg-webhelper --enable-sockets --enable-sysvsem --enable-sysvshm -with-zlib --with-apxs2 --with-mysql-sock --with-pear
Don't be alarmed if configure errors out with missing packages. Take a look at what package is missing and install them one by one until you get a clean configure run. You'll want to install the '-devel' versions of any packages. For example configure errored out with libxml2 missing:
- Code: Select all
$ urpmq --list | grep -i xml2 | grep -i devel
lib64tinyxml2-devel
lib64tinyxml2-devel
lib64xml2-devel
lib64xml2-devel
$ urpmi lib64xml2-devel
Once configure comes back clean. Compile it. For this step you may want to be root so that installation will be smooth.
- Code: Select all
make
Once the compile is done, feel free to install it.
- Code: Select all
make install
After this I do an extra step of manually putting the libs/libphp7.so in the same directory as the other php7 files. ie:
- Code: Select all
cp libs/libphp7.so /opt/php7/lib/php/extensions/libphp7.so
Now that it's all compiled and installed, I still had a few tweaks to ensure apache found it and such. My goal here was to make it as self contained as possible so that if an official Mageia 8 rpm for php7 came around, it would be relatively easy to "dereference" the /opt/php7 I built.
Tweak 1: Make sure there is a /var/lib/php directory and it's writable by apache
- Code: Select all
mkdir -m 775 /var/lib/php; chown apache:apache /var/lib/php
Tweak 2: link /opt/php7/php.ini to /etc/php.ini
- Code: Select all
cd /opt/php7/lib; ln -s /etc/php.ini .
Tweak 3: link mod_php.so into the apache mod location
- Code: Select all
ln -s /opt/php7/lib/php/extensions/libphp7.so /usr/lib64/httpd/modules/mod_php.so
Tweak 4: Add /opt/php7 to /etc/php.ini in key spots. These are from my /etc/php.ini file:
- Code: Select all
include_path = ".:/usr/lib64/php/:/usr/share/pear/:/usr/share/php/:/opt/php7:/opt/php7/lib/php:/opt/php7/include/php"
extension_dir = "/usr/lib64/php/extensions:/opt/php7/lib/php/extensions"
Tweak 5: If you have /etc/httpd/conf/modules.d/70_mod_php.conf or anything in your modules config directory that references php, make sure it says php7.
Here's my content of 70_mod_php.conf. The only real change was 'LoadModule php_module' was changed to 'LoadModule php7_module'
- Code: Select all
LoadModule php7_module modules/mod_php.so
AddType application/x-httpd-php .php
AddType application/x-httpd-php .phtml
AddType application/x-httpd-php-source .phps
DirectoryIndex index.php index.phtml
Tweak 6: Make a slight change to /etc/httpd/conf.d/security.conf if you have it. I changed the line:
- Code: Select all
<IfModule !mod_php.c>
to
<IfModule !mod_php7.c>
I think that's it. Good luck!
R