[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: 16560
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: 451
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: 757
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: 757
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: 451
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: 16560
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: 757
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: 16560
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: Mageia 8 & Php - I messed up

Postby Cled » Apr 22nd, '21, 05:47

Thanks a lot rtl19 for this detailed procedure.

I passed all the first steps, untar php7 in a folder of my "home", then doing successfully in this folder the "configure" step, and the "make" step.

But I get stuck at the "make install" stage, with this message:

Code: Select all
$ make install
Installing PHP SAPI module:       apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp7.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install install libphp7.la /usr/lib64/httpd/modules/
libtool: install: install .libs/libphp7.so /usr/lib64/httpd/modules/libphp7.so
libtool: install: install .libs/libphp7.lai /usr/lib64/httpd/modules/libphp7.la
libtool: warning: remember to run 'libtool --finish /home/moi/MPI/PHP-7/php-7.4.16/libs'
chmod 755 /usr/lib64/httpd/modules/libphp7.so
apxs:Error: Activation failed for custom /etc/httpd/conf/httpd.conf file..
apxs:Error: At least one `LoadModule' directive already has to exist..
make: *** [Makefile:156 : install-sapi] Erreur 1


Unfortunately, I can't solve this problem by myself.
Cled
 
Posts: 3
Joined: Apr 22nd, '21, 05:36

Re: [WORKAROUND] Mageia 8 & PHP7

Postby doktor5000 » Apr 22nd, '21, 16:46

And what does your /etc/httpd/conf/httpd.conf currently look like ?
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: 16560
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [WORKAROUND] Mageia 8 & PHP7

Postby Cled » Apr 24th, '21, 06:27

Thanks doctor500 for your answer. I was able to solve this first problem, and go through all the following steps, except that... PHP still doesn't work.

1) For the "make install" step, I was missing a line to add in my /etc/httpd/conf/httpd.conf file

Just after the line "Include conf/modules.d/*.conf", I had to add this line:

Code: Select all
LoadModule php7_module modules/mod_php.so

(Solution found here : https://itroger.wordpress.com/2016/10/22/installing-php7-in-mageia-5/
I just added the "7" in "php7_module", as advised by rtl19).

2) Then I followed all the steps indicated by rtl19, including all the tweaks.

3) Unfortunately, PHP still doesn't work:

Code: Select all
# php -v
bash: php : commande introuvable
# php7 -v
bash: php7 : commande introuvable

I redid a "make install" to get the log (I didn't keep the log of the first successful "make install"), and this is what I get:

Code: Select all
# make install
/bin/sh /home/moi/MPI/PHP-7/php-7.4.16/libtool --silent --preserve-dup-deps --mode=install cp ext/opcache/opcache.la /home/moi/MPI/PHP-7/php-7.4.16/modules
Installing PHP SAPI module:       apache2handler
/usr/lib64/httpd/build/instdso.sh SH_LIBTOOL='/usr/lib64/apr-1/build/libtool' libphp7.la /usr/lib64/httpd/modules
/usr/lib64/apr-1/build/libtool --mode=install install libphp7.la /usr/lib64/httpd/modules/
libtool: install: install .libs/libphp7.so /usr/lib64/httpd/modules/libphp7.so
libtool: install: install .libs/libphp7.lai /usr/lib64/httpd/modules/libphp7.la
libtool: warning: remember to run 'libtool --finish /home/moi/MPI/PHP-7/php-7.4.16/libs'
chmod 755 /usr/lib64/httpd/modules/libphp7.so
[activating module `php7' in /etc/httpd/conf/httpd.conf]
Installing shared extensions:     /opt/php7/lib/php/extensions/no-debug-non-zts-20190902/
Installing PHP CLI binary:        /opt/php7/bin/
Installing PHP CLI man page:      /opt/php7/php/man/man1/
Installing phpdbg binary:         /opt/php7/bin/
Installing phpdbg man page:       /opt/php7/php/man/man1/
Installing PHP CGI binary:        /opt/php7/bin/
Installing PHP CGI man page:      /opt/php7/php/man/man1/
Installing build environment:     /opt/php7/lib/php/build/
Installing header files:          /opt/php7/include/php/
Installing helper programs:       /opt/php7/bin/
  program: phpize
  program: php-config
Installing man pages:             /opt/php7/php/man/man1/
  page: phpize.1
  page: php-config.1
Installing PEAR environment:      /opt/php7/lib/php/
[PEAR] Archive_Tar    - already installed: 1.4.9
[PEAR] Console_Getopt - already installed: 1.4.3
[PEAR] Structures_Graph- already installed: 1.1.1
[PEAR] XML_Util       - already installed: 1.4.5
[PEAR] PEAR           - already installed: 1.10.12
Warning! a PEAR user config file already exists from a previous PEAR installation at '/root/.pearrc'. You may probably want to remove it.
Wrote PEAR system config file at: /opt/php7/etc/pear.conf
You may want to add: /opt/php7/lib/php to your php.ini include_path
/home/moi/MPI/PHP-7/php-7.4.16/build/shtool install -c ext/phar/phar.phar /opt/php7/bin/phar.phar
ln -s -f phar.phar /opt/php7/bin/phar
Installing PDO headers:           /opt/php7/include/php/ext/pdo/

I'm stuck again. I don't know what's wrong, and I would welcome any help. :?
Cled
 
Posts: 3
Joined: Apr 22nd, '21, 05:36

Re: [WORKAROUND] Mageia 8 & PHP7

Postby doktor5000 » Apr 24th, '21, 18:03

Cled wrote:3) Unfortunately, PHP still doesn't work:

Code: Select all
# php -v
bash: php : commande introuvable
# php7 -v
bash: php7 : commande introuvable


Well, if you want to run it interactively and don't supply the full path, then /opt/php7/bin/ should be added to your PATH - you can add this e.g. in your ~/.bashrc.
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: 16560
Joined: Jun 4th, '11, 10:10
Location: Leipzig, Germany

Re: [WORKAROUND] Mageia 8 & PHP7

Postby Cled » Apr 25th, '21, 14:12

Thanks a lot doktor5000.
(This is the first time I need to compile a program directly. :lol: )

Now PHP-7 is working, and Apache (httpd) too, after restarting it.

But not the site I have to work on, unfortunately. The purpose of this whole operation is to be able to continue my work (front-end, not back-end in PHP that I don't master) on this site: I load it locally on " http://127.0.0.1/ ".
On Mageia 7 (with PHP 7), it worked perfectly. But on Mageia 8, even after uninstalling PHP-8 and installing PHP-7 as seen above, I get this error message when I load my site in the browser (http://127.0.0.1/my-website/public/):

Code: Select all
could not find driver
Fatal error: Uncaught Error: Call to a member function setAttribute() on null in /var/www/html/my-website/public/index.php:43 Stack trace: #0 /var/www/html/my-website/vendor/pimple/pimple/src/Pimple/Container.php(118): {closure}() #1 /var/www/html/my-website/public/controllers/PageController.php(6): Pimple\Container->offsetGet() #2 /var/www/html/my-website/public/index.php(107): require_once('/var/www/html/m...') #3 {main} thrown in /var/www/html/my-website/public/index.php on line 43

Since the site works fine under Mageia 7, is there anything I should have added, or done differently, in the PHP-7 installation under Mageia 8?
Cled
 
Posts: 3
Joined: Apr 22nd, '21, 05:36

Re: [WORKAROUND] Mageia 8 & PHP7

Postby filip » Apr 25th, '21, 19:13

Are you sure that Apache runs php7?

In php 8 error handling is different and more strict.
filip
 
Posts: 451
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia

Re: Mageia 8 & Php - I messed up

Postby filip » Apr 25th, '21, 19:25

filip wrote:@rtl19
Yeah. RPI are really nice. I'll try to create some docs for install and use.

Finally something. ;)
filip
 
Posts: 451
Joined: May 4th, '11, 22:10
Location: Kranj, Slovenia


Return to The magician suggests...

Who is online

Users browsing this forum: No registered users and 1 guest