How to Compile PHP 8.3 Locally and Deploy a ThinkPHP 8.0 Application
This guide walks you through downloading, compiling, and installing PHP 8.3 from source, configuring PHP‑FPM, creating systemd service files, and then installing ThinkPHP 8.0 with Composer, including Nginx setup and verification steps to get a working PHP web application.
Overview
This tutorial explains how to build PHP 8.3 from source on a Linux system, set up PHP‑FPM as a systemd service, and then install the ThinkPHP 8.0 framework using Composer. It also covers Nginx configuration and basic verification of the deployment.
Install PHP 8.3
Download source
wget https://www.php.net/distributions/php-8.3.1.tar.gz
tar -zxvf php-8.3.1.tar.gzInstall required packages
sudo apt-get install libfcgi-dev libfcgi0ldbl libjpeg-turbo8-dev \
libmcrypt-dev libssl-dev libc-client2007e libc-client2007e-dev 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 libkrb5-dev libssl-dev libbz2-dev libpng-dev libfreetype6-dev \
libc-client2007e-dev libonig-dev libreadline-dev libxslt1-dev libzip-devIf a package is missing, you can search for it with apt-cache search <name> and install the appropriate one.
Configure and compile
cd php-8.3.1
./configure \
--prefix=/usr/local/php-8.3.1 \
--with-config-file-path=/usr/local/php-8.3.1/etc \
--with-zlib-dir \
--with-freetype \
--enable-mbstring \
--enable-soap \
--enable-calendar \
--with-curl \
--with-zlib \
--enable-gd \
--disable-rpath \
--enable-inline-optimization \
--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-kerberos \
--with-gettext \
--with-xmlrpc \
--with-xsl \
--enable-opcache \
--enable-intl \
--with-pear \
--enable-fpmBuild and install
make
make installThe installation logs show binaries placed under /usr/local/php-8.3.1, including the CLI, FPM daemon, and related utilities.
Configure PHP
Verify version
/usr/local/php-8.3.1/bin/php -vphp.ini
sudo cp php.ini-production /usr/local/php-8.3.1/etc/php.iniSet cgi.fix_pathinfo=0 to prevent Nginx from exposing scripts unintentionally.
PHP‑FPM configuration
sudo mv /usr/local/php-8.3.1/etc/php-fpm.conf.default \
/usr/local/php-8.3.1/etc/php-fpm.conf
sudo mv /usr/local/php-8.3.1/etc/php-fpm.d/www.conf.default \
/usr/local/php-8.3.1/etc/php-fpm.d/www.confUser and group
user = www
group = www
listen.owner = www
listen.group = www
listen.mode = 0660Optionally adjust ownership of the configuration file: chown www:www /opt/php-8.3.1/etc/php-fpm.d/www.conf.
Listen socket
#listen = 127.0.0.1:9000 ; comment out to disable TCP
listen = /var/run/php8.3.1-fpm.sock ; use Unix socketCreate systemd service
[Unit]
Description=The PHP 8.3.1 FastCGI Process Manager
After=network.target
[Service]
Type=simple
PIDFile=/usr/local/php-8.3.1/var/run/php-fpm.pid
ExecStart=/usr/local/php-8.3.1/sbin/php-fpm --nodaemonize \
--fpm-config /usr/local/php-8.3.1/etc/php-fpm.conf
ExecReload=/bin/kill -USR2 $MAINPID
[Install]
WantedBy=multi-user.target sudo systemctl enable php-8.3.1-fpm.service
sudo systemctl daemon-reload
sudo systemctl start php-8.3.1-fpm.service
sudo systemctl status php-8.3.1-fpm.serviceInstall ThinkPHP 8.0
Install Composer
wget https://getcomposer.org/download/latest-stable/composer.phar
php composer.phar -v # verify installationOptionally configure the Alibaba Cloud mirror:
php composer.phar config -g repo.packagist composer https://mirrors.aliyun.com/composer/Create ThinkPHP project
php composer.phar create-project topthink/think tp8.0
# output shows downloading and extracting the frameworkProject structure includes app, public, config, vendor, etc.
Nginx configuration for ThinkPHP
server {
listen 80;
server_name 121.128.128.128;
set $root_path /home/www/build/tp8.0/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.3.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;
}
}After reloading Nginx, visiting http://121.128.128.128 should display the ThinkPHP welcome page.
Verify PHP installation
vim public/tinywan.php
<?php
phpinfo();
?>Access http://121.128.128.128/tinywan.php to see the PHP information page.
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.
