DEV Community

rkcperea
rkcperea

Posted on

Getting Started with PHP on Ubuntu 24.04

I'll document how to install Laravel on Ubuntu 24.04, currently in progress.

I tried following Laravel documentation, but below didn't work for me:

/bin/bash -c "$(curl -fsSL https://php.new/install/linux/8.4)"
Enter fullscreen mode Exit fullscreen mode

If you did, you might need to uninstall first with:

~/.config/herd-lite/bin/uninstall-herd-lite
Enter fullscreen mode Exit fullscreen mode

and remove the path changes in ~/.bashrc

I tried using mise, but there was also an error.

mise use php
Enter fullscreen mode Exit fullscreen mode

something about Japanese characters and missing gdlib

Learning from git

Since we have a #learning tag, this is what I normally do

  • with this, we'll be aware of caveats, issues, trends, etc.

First, go to php-src

run the following commands

sudo apt install --dry-run pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev
Enter fullscreen mode Exit fullscreen mode

I usually start with a --dry-run option, check the size by removing the --dry-run, finally continue or rerun with a -y . In my case, I'm only missing bison libxml2-dev re2c which is less than 10 MB. For brevity, I will proceed with just a -y

sudo apt install -y pkg-config build-essential autoconf bison re2c libxml2-dev libsqlite3-dev
Enter fullscreen mode Exit fullscreen mode

I prefer having the git source code so I can backtrace and learn from changelogs. Check the latest version, in my case php-8.4.10

git clone git@github.com:php/php-src.git
git checkout php-8.4.10
./buildconf
Enter fullscreen mode Exit fullscreen mode

It's nice how PHP instructs the next step

./buildconf --force
./configure --enable-debug
Enter fullscreen mode Exit fullscreen mode

They'll reply with Thank you for using PHP.

make -j$(nproc)
Enter fullscreen mode Exit fullscreen mode

the reply:
Build complete.
Don't forget to run 'make test'.

make -j$(nproc) test 
Enter fullscreen mode Exit fullscreen mode

You may have found a problem in PHP.
This report can be saved and used to open an issue on the bug tracker at
https://github.com/php/php-src/issues
This gives us a better understanding of PHP's behavior.
Do you want to save this report in a file? [Yn]: Report saved to: /home/rkc/.php/php-src/php_test_results_20250723_2157.txt

So let's report a bug: https://github.com/php/php-src/issues/19227

It requires a php -v output

make install
sudo make install
php -v
Enter fullscreen mode Exit fullscreen mode

Finally, you'll see
PHP 8.4.10 (cli) (built: Jul 23 2025 14:34:18) (NTS DEBUG)
Copyright (c) The PHP Group
Zend Engine v4.4.10, Copyright (c) Zend Technologies

I'm a Rails developer who is new to dev.to, and to PHP. Exploring other languages.

I'll cut it short for now and go back to my rails project. Hopefully, I could edit this tomorrow.

Top comments (0)