Step‑by‑Step Guide to Installing PHP 8.4, Composer, Webman and ThinkPHP on Linux
This tutorial walks you through downloading PHP 8.4, installing required libraries, compiling and installing the interpreter, configuring php.ini and PHP‑FPM, setting up a systemd service, then adding Composer, Webman and ThinkPHP frameworks, and finally configuring Nginx to serve the applications.
Install PHP 8.4
PHP 8.4 (release 8.4.1) adds property hooks, asymmetric visibility, an updated DOM API, performance improvements and numerous bug fixes.
Download source
wget https://www.php.net/distributions/php-8.4.1.tar.gz
tar -zxvf php-8.4.1.tar.gzInstall build dependencies (Debian/Ubuntu)
sudo apt-get install libfcgi-dev libfcgi0ldbl libjpeg-turbo8-dev \
libmcrypt-dev libssl-dev libc-client2007e libxml2-dev libbz2-dev \
libcurl4-openssl-dev libjpeg-dev libpng-dev libfreetype6-dev \
libkrb5-dev libpq-dev libxslt1-dev libzip-dev libsqlite3-dev \
libonig-dev pkg-config libreadline-devIf a package is missing, locate it with apt-cache search <name> and install the appropriate package.
Configure and compile
cd php-8.4.1
sudo ./configure \
--prefix=/usr/local/php-8.4.1 \
--with-config-file-path=/usr/local/php-8.4.1/etc \
--with-freetype \
--enable-mbstring \
--enable-soap \
--enable-calendar \
--with-curl \
--with-zlib \
--enable-gd \
--disable-rpath \
--with-bz2 \
--enable-sockets \
--enable-sysvsem \
--enable-sysvshm \
--enable-pcntl \
--enable-mbregex \
--enable-exif \
--enable-bcmath \
--with-mhash \
--with-zip \
--with-pdo-mysql \
--with-mysqli \
--with-mysql-sock=/var/run/mysqld/mysqld.sock \
--with-jpeg \
--with-openssl \
--with-fpm-user=www \
--with-fpm-group=www \
--with-libdir=/lib/x86_64-linux-gnu \
--enable-ftp \
--with-gettext \
--with-xsl \
--enable-opcache \
--enable-intl \
--with-pear \
--enable-fpmBuild and install
make
sudo make installThe installation places the CLI binary, PHP‑FPM binaries, shared extensions, man pages and the PEAR environment under /usr/local/php-8.4.1.
Verify installation
/usr/local/php-8.4.1/bin/php -vExpected output includes PHP 8.4.1 (cli) and Zend Engine v4.4.1.
Configure php.ini
sudo cp php.ini-production /usr/local/php-8.4.1/etc/php.iniNote: Set cgi.fix_pathinfo=0 to prevent Nginx from exposing arbitrary scripts.
Configure PHP‑FPM
Copy default configuration files and adjust user/group and socket settings:
cd /usr/local/php-8.4.1/etc
cp php-fpm.conf.default php-fpm.conf
cp php-fpm.d/www.conf.default php-fpm.d/www.conf
# Edit www.conf
user = www
group = www
listen.owner = www
listen.group = www
listen.mode = 0660
# Use a Unix socket instead of a TCP port
listen = /var/run/php8.4.1-fpm.sockCreate a systemd unit for PHP‑FPM
sudo vim /lib/systemd/system/php-8.4.1-fpm.serviceFile content:
[Unit]
Description=PHP 8.4.1 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/usr/local/php-8.4.1/var/run/php-fpm.pid
ExecStart=/usr/local/php-8.4.1/sbin/php-fpm --nodaemonize --fpm-config /usr/local/php-8.4.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.targetEnable and start the service:
sudo systemctl enable php-8.4.1-fpm.service
sudo systemctl daemon-reload
sudo systemctl start php-8.4.1-fpm.service
sudo systemctl status php-8.4.1-fpm.serviceInstall Composer
wget https://getcomposer.org/download/latest-stable/composer.pharVerify:
/usr/local/php-8.4.1/bin/php composer.phar -VInstall Webman 1.6
Create a new Webman project using the freshly installed Composer:
/usr/local/php-8.4.1/bin/php composer.phar create-project workerman/webman webman1.6Start the server: /usr/local/php-8.4.1/bin/php start.php start The console lists workers and shows the listening address (e.g., 0.0.0.0:8289).
Install ThinkPHP 8.1
Because multiple PHP versions may coexist, invoke Composer with the absolute PHP binary path:
/usr/local/php-8.4.1/bin/php composer.phar create-project topthink/think tp8.1Nginx host configuration for ThinkPHP
server {
listen 80;
server_name 121.128.128.128;
set $root_path /home/www/build/tp8.1/public;
root $root_path;
location / {
if (!-e $request_filename) {
rewrite ^(.*)$ /index.php?s=/$1 last;
break;
}
}
location ~ \.php$ {
try_files $fastcgi_script_name =404;
include fastcgi_params;
fastcgi_pass unix:/var/run/php8.4.1-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_buffer_size 128k;
fastcgi_buffers 4 256k;
fastcgi_busy_buffers_size 256k;
fastcgi_connect_timeout 10000;
fastcgi_send_timeout 6000;
fastcgi_read_timeout 6000;
}
}Reload Nginx and visit http://121.128.128.128 to see the ThinkPHP welcome page.
Access URLs
Webman: http://0.0.0.0:8289 (as shown by the start script).
ThinkPHP: the IP address configured in the Nginx server block.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Open Source Tech Hub
Sharing cutting-edge internet technologies and practical AI resources.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
