[WORKAROUND] Mageia 8 & PHP7

Here you'll find a place for solutions and hints.

Please use one of the support subforums below for questions or if you have any issues and need support.

[WORKAROUND] Mageia 8 & PHP7

Postby rtl19 » Mar 30th, '21, 03:49

I made a big mistake. I did a fresh install on my server without realizing mageia 8 only comes with PHP8 until it was too late. I know this is a long shot but is there an easy way to get PHP7 on my Mageia 8 server?

Thanks!
R
Last edited by doktor5000 on Apr 9th, '21, 17:03, edited 1 time in total.
Reason: adjusted thread title
rtl19
 
Posts: 10
Joined: Mar 6th, '21, 22:06

Re: Mageia 8 & Php - I messed up

Postby doktor5000 » Mar 30th, '21, 18:12

Not really, no. Easiest way would probably be to try to rebuild the mga7 src.rpms yourself or try to install them, but I don't think that's a good idea (and overall it's also not easy at all).
Also have a look at https://wiki.mageia.org/en/Mageia_8_Errata#PHP7_dropped
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 16463
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Mageia 8 & Php - I messed up

Postby rtl19 » Mar 31st, '21, 16:48

Thanks for the info. I'll look into what's involved with building PHP7 myself.
rtl19
 
Posts: 10
Joined: Mar 6th, '21, 22:06

Re: Mageia 8 & Php - I messed up

Postby rtl19 » Apr 2nd, '21, 02:02

I'm happy to say I got php7 working on my Mageia 8. It wasn't pretty :) I wouldn't consider the level of effort to be signifcant, however.

Off the top of my head, this is what I did:
    * Download the php 7 tarball off the php site
    * installed apache-devel
    * set the prefix in the php7 configure to /opt/php7 (this makes it easy to remove later)
    * activate php configure modules - I took this list of modules from php8 that comes with Mageia
    * Compiled php7
    * installed to /opt/php7
    * ln -s /opt/php7/lib/php/extensions/libphp7.so /usr/lib64/httpd/modules/mod_php.so
    * put my old php.ini in /etc
    * put /etc/modules.d/70_mod_php.conf out there from my backed up php 7 version. I had to tweak this ever so slightly

I'm sure there are a few more minor tweaks/steps. I'm happy to say the 3 php applications I needed to work are in fact working. If anyone needs more detail, please let me know and I'll dig around in my notes.

By the way, these are the specific ./configure options I used to build php7:
Code: Select all
./configure --prefix /opt/php7 --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


R
rtl19
 
Posts: 10
Joined: Mar 6th, '21, 22:06

Re: Mageia 8 & Php - I messed up

Postby filip » Apr 2nd, '21, 10:40

Hi, R.!
Glad that you make it. And thanks for sharing your procedure! I hope you can soon start to port your php7 apps up to 8.

I can relate to that as I still need to update 2 websites ;). After that (soon I hope) I'll shift my production desktop to mga8 too. I successfully setup RPI4 4G already with mga8 used as a file backup server for Desktop and Sailfish phone, apache server to test my webites, share mga torrents and to browse now and then on TV as it has way obsolete Chrome 22 there (you can imagine easily that almost no website works with that: hint SSL is not supported). It works great but I still need to fix two major functions (sound and pigpio).
filip
 
Posts: 443
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Mageia 8 & Php - I messed up

Postby morgano » Apr 2nd, '21, 12:18

Many thanks :)
I now linked this thread from https://wiki.mageia.org/en/Mageia_8_Errata#PHP7_dropped .
Mandriva since 2006, then Mageia since 2011 at home & work. Thinkpad T43 & T400, Dell M4400, Acer Aspire 7. Workstation using LVM, LUKS, VirtualBox, BOINC
morgano
 
Posts: 745
Joined: Jun 15th, '11, 17:51
Location: Kivik, Sweden

Re: Mageia 8 & Php - I messed up

Postby rtl19 » Apr 2nd, '21, 15:47

@morgano, since this thread is being linked from the wiki, I'll post a more detailed set of steps sometime this weekend.

@filip, that's so cool! We have a few raspberry pi's. They're so much fun to play with. I have 2 pi 3's. One is used as a mythtv frontend and pi-hole, the other is used to display a slideshow of pictures on a wall TV and sometimes run kodi as well. Then I have a pi zero w that we use to open/close the garage door. It never fails that I leave the house and ask myself, did I close the garage door. This gives me peace of mind. :) The two webapps I use that need php7 are mythweb and piwigo photo gallery. I'm fairly certain piwigo will be made compatable with php8 at some point but mythweb probably never will.

R
rtl19
 
Posts: 10
Joined: Mar 6th, '21, 22:06

Re: Mageia 8 & Php - I messed up

Postby morgano » Apr 3rd, '21, 00:15

@rtl19, that would be awsome.
It would be best as a wiki page.
So if you like to try, here is a starting hint: https://wiki.mageia.org/en/How_to_write_a_wiki_page

Also see this thread: https://ml.mageia.org/l/arc/dev/2021-03/msg00018.html
So you may like to join dev mailing list and discuss. Maybe by joint effort package it.
Mandriva since 2006, then Mageia since 2011 at home & work. Thinkpad T43 & T400, Dell M4400, Acer Aspire 7. Workstation using LVM, LUKS, VirtualBox, BOINC
morgano
 
Posts: 745
Joined: Jun 15th, '11, 17:51
Location: Kivik, Sweden

Re: Mageia 8 & Php - I messed up

Postby filip » Apr 3rd, '21, 16:03

@rtl19
Yeah. RPI are really nice. I'll try to create some docs for install and use. Eventually. Soon ;).
I saw https://www.mythtv.org/wiki/Build_from_Source for mythweb. Don't know if it helps.
filip
 
Posts: 443
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Mageia 8 & Php - I messed up

Postby doktor5000 » Apr 3rd, '21, 18:24

Well mythweb will probably be deprecated by upstream according to https://github.com/MythTV/mythweb/issue ... -747379877
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 16463
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Mageia 8 & Php - I messed up

Postby morgano » Apr 4th, '21, 17:27

According to dev list, unofficial PHP7 rpm is being worked on :)
Mandriva since 2006, then Mageia since 2011 at home & work. Thinkpad T43 & T400, Dell M4400, Acer Aspire 7. Workstation using LVM, LUKS, VirtualBox, BOINC
morgano
 
Posts: 745
Joined: Jun 15th, '11, 17:51
Location: Kivik, Sweden

Re: Mageia 8 & Php - I messed up

Postby rtl19 » Apr 9th, '21, 01:59

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.php

Then, 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
rtl19
 
Posts: 10
Joined: Mar 6th, '21, 22:06

Re: [WORKAROUND] Mageia 8 & PHP7

Postby doktor5000 » Apr 9th, '21, 17:04

Thanks for sharing, I've moved this into our tips&tricks section.
Cauldron is not for the faint of heart!
Caution: Hot, bubbling magic inside. May explode or cook your kittens!
----
Disclaimer: Beware of allergic reactions in answer to unconstructive complaint-type posts
User avatar
doktor5000
 
Posts: 16463
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 0 guests

cron