How to Install PHP 8 on Slackware Linux

291
Share:
how-to-install-php-8-on-slackware-linux

This article is a part of my Slackware article series. Previous article:

How Package Management Works in Slackware

Like another Linux distributions out there, Slackware has its own package manager, namely pkgtool, installpkg, upgradepkg and removepkg for installing, upgrading and removing software packages. makepkg can be used to create packages. For more details about slackpkg you can check here and here.

Basically, here's how to install a package in Slackware:

Update Package Repository

In Ubuntu or Debian based distribution, before we install anything we must update our package repository first using apt or apt-get command. In Slackware, we'll use slackpkg command below:

$ slackpkg update

Search the Package

First, we need to figure whether the software we'd like to install is available. For example, if we're about to install PHP, we can search it using this slackpkg command:

$ slackpkg search php

It will respond with something like this:

Looking for php in package list. Please wait... DONE

The list below shows all packages with name matching "php".

[ Status           ] [ Repository               ] [ Package                                  ]
  uninstalled              slackware64                  kdev-php-5.6.1-x86_64-1                   
  uninstalled              slackware64                  php-7.4.14-x86_64-1                       
  uninstalled(masked)      pasture                      php-5.6.40-x86_64-1                       

You can search specific files using "slackpkg file-search file".

From the result, we can figure out that PHP package is available and its version is 7.4.14. This is interesting because by the time of this writing (January 17, 2021), Slackware already has the latest PHP version. PHP 7.4.14 itself was released at January 7, 2021.

Package Installation

To continue with PHP 7.4.14 installation, we'll just need to enter this command:

$ slackpkg install php-7.4

It will respond with a screen like this:

Slackpkg installation

In this screen dialog we can navigate using arrows and select item using "Space". Just press "Enter" on your keyboard to continue with PHP 7.4 installation.

Slackpkg will download the package file and the installation process will run automatically.

Once you have your shell back, the installation process is done.

Confirm Installation

To confirm whether we've successfully installed PHP 7.4.14 into our system, we can check it using this command:

$ php -v

It should respond with something like this:

PHP 7.4.14 (cli) (built: Jan  5 2021 21:30:31) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies

Congratulations, we've successfully installed PHP 7.4.14 into our Slackware Current.

Uninstall/Remove Package

To remove package, we'll use this command:

$ slackpkg remove php
Slackpkg remove

Just like slackpkg installation screen, we can navigate using arrows and using "Space" to select/de-select items. Just press "Enter" to continue with package removal.

Create Package using SlackBuild

Next, we'll try to install package which hasn't already available in any Slackware repository, but we already have the source code.

Let's use PHP 8 for example. On our previous slackpkg search command, we figured out that PHP 8 hasn't available just yet, but we can download the source code on PHP's download page.

Slackbuild Script

Luckily, we're able to create our own package by using SlackBuild script. I've made a PHP 8 SlackBuild Script github repository  for this purpose. You can also use this repository as a template if you like.

To use this repository, I've included a README too. Basically here's what you have to do:

  1. Clone the repository
    $ git clone https://github.com/r00t4bl3/php8-SlackBuild.git 
  2. Enter working directory
    $ cd php8-SlackBuild
  3. Run the script
    $ ./php8build.sh

When the script finished, it should output line like below:

Slackware package /tmp/php-8.0.1-x86_64-1.txz created.

Next, we'll just run this command to install our newly created package.

$ installpkg /tmp/php-8.0.1-x86_64-1.txz

System will respond with:

Verifying package php-8.0.1-x86_64-1.txz.
Installing package php-8.0.1-x86_64-1.txz:
PACKAGE DESCRIPTION:
# php (HTML-embedded scripting language)
#
# PHP is an HTML-embedded scripting language. It shares syntax
# characteristics with C, Java, and Perl. The primary objective behind
# this language is to make a fast and easy-to-use scripting language
# for dynamic web sites.
#
# More information can be found online at http://www.php.net/
#
Executing install script for php-8.0.1-x86_64-1.txz.
Package php-8.0.1-x86_64-1.txz installed.

Verify Installation

To verify our PHP 8.0.1 installation, we'll use this command:

$ php -v
PHP 8.0.1 (cli) (built: Jan 17 2021 13:11:13) ( ZTS )
Copyright (c) The PHP Group
Zend Engine v4.0.1, Copyright (c) Zend Technologies

Congratulations, we've successfully created PHP 8.0.1 package in our Slackware and install it.

Conclusion

I hope that you now know how package management works in Slackware. If you run into any issues or have any feedback feel free to drop a comment below.

Tags PHP Linux
Share:

1 comment

  1. [email protected]:/home/unu#
    [email protected]:/home/unu# installpkg /tmp/php-8.0.1-x86_64-1.txz
    Verifying package php-8.0.1-x86_64-1.txz.
    Installing package php-8.0.1-x86_64-1.txz:
    PACKAGE DESCRIPTION:
    # php (HTML-embedded scripting language)
    #
    # PHP is an HTML-embedded scripting language. It shares syntax
    # characteristics with C, Java, and Perl. The primary objective behind
    # this language is to make a fast and easy-to-use scripting language
    # for dynamic web sites.
    #
    # More information can be found online at http://www.php.net/
    #
    Executing install script for php-8.0.1-x86_64-1.txz.
    Package php-8.0.1-x86_64-1.txz installed.
    [email protected]:/home/unu# php -v
    PHP Warning: PHP Startup: Unable to load dynamic library 'xmlrpc' (tried: /usr/lib64/php/extensions/xmlrpc (/usr/lib64/php/extensions/xmlrpc: cannot open shared object file: No such file or directory), /usr/lib64/php/extensions/xmlrpc.so (/usr/lib64/php/extensions/xmlrpc.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
    php: symbol lookup error: /usr/lib64/php/extensions/tidy.so: undefined symbol: tidySetMallocCall
    [email protected]:/home/unu#

    • Well, it seems that there are still xmlrpc extension enabled somewhere on your build script. You can try to examine these locations:
      - php directory under your build environment directory
      - /etc/php.ini

      Try to find any xmlrpc related configuration and comment it. Your warning message is related with XMLRPC extension being moved to PECL in PHP 8.

Leave a reply

Your email address will not be published. Required fields are marked *