Skip to content

Enjoy Kaizen

Installing a PHP Extension Outside Home

FEATURING: mf2 for PHP by cj.w6k.ca!

Have you seen similar?

cjw@buster201908:~$ []

You may recognize tilde hanging out there in the prompt:

... :~$ []

The tilde ~ is where the current directory name is written.

When you first login to your server, you’ll be chillin’ at home in $HOME circa ~. Change your current directory to /usr/local:

... :~$ cd /usr/local
... :/usr/local$

Make an empty folder here with the name phpext-mf2:

# don't forget sudo or you get pneughed ...
... :/usr/local$ mkdir phpext-mf2
mkdir: cannot create directory ‘phpext-mf2’: Permission denied

# with sudo
... :/usr/local$ sudo mkdir phpext-mf2

Now is a good time to take ownership with your login handle and default group, so you don’t get pneuged again. Use the chown command on /usr/local/phpext-mf2/.

From here, it’s time to clone the mf2 repo from code.cjwillcock.ca (or wherever):

... :/usr/local$ git clone https://code.cjwillcock.ca/php-extensions/mf2.git phpext-mf2
... :/usr/local$ cd phpext-mf2
... :/usr/local/phpext-mf2$ []

phpize is required next. It’s with the php-dev package:

... :/usr/local/phpext-mf2$ sudo apt-get install php-dev

Now the instructions from the mf2 README.md, but not in a rush like that. Run the 153 tests and decide if it will probably work for your server.

... :/usr/local/phpext-mf2$ phpize
... :/usr/local/phpext-mf2$ ./configure
... :/usr/local/phpext-mf2$ make
... :/usr/local/phpext-mf2$ make test

If everything passes, then install it!

... :/usr/local/phpext-mf2$ sudo make install
Installing shared extensions:     /usr/lib/php/20180731/

From here, installation is equivalent for any destination. Our prompt for the purpose of demonstration simplifies to $.

Make available for activation, your new extension:

$ echo "extension=/usr/lib/php/20180731/mf2.so" | sudo tee -a /etc/php/7.3/mods-available/mf2.ini

Activate it:

$ sudo ln -s /etc/php/7.3/mods-available/mf2.ini /etc/php/7.3/cli/conf.d/mf2.ini

Did it work?

$ php --ri mf2

mf2

Microformats2 support => enabled
cjw@buster201908:/usr/local/phpext-mf2$

Leave a Reply

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