Make PHP Workspace
August 19, 2025·MIRRR jr.·20 min read
Make PHP Workspace
I use Debian 13 Trixie, but my configs will also work on Debian-based Ubuntu, Linux Mint, and other Linux distros (with slight differences).
1. First, we will install the latest version of PHP available at this time.
Add ondrej/php DPA
Because PHP 8.4 packages are not available in any of the current Debian or Ubuntu software repositories, the PHP packages must come from another repo.
Ondřej Surý maintains a package archive that contains compiled binaries of all current PHP versions, for Ubuntu and Debian. It also ships several PECL extensions including PECL extensions for PHP core extensions unbundled in PHP 8.4.
Once this repository is added, the initial installation and updates can be done with the standard apt commands.
bash
# for debian
sudo apt-get update
sudo apt-get -y install lsb-release ca-certificates curl apt-transport-https
sudo curl -sSLo /tmp/debsuryorg-archive-keyring.deb https://packages.sury.org/debsuryorg-archive-keyring.deb
sudo dpkg -i /tmp/debsuryorg-archive-keyring.deb
sudo sh -c 'echo "deb [signed-by=/usr/share/keyrings/deb.sury.org-php.gpg] https://packages.sury.org/php/ $(lsb_release -sc) main" > /etc/apt/sources.list.d/php.list'
sudo apt-get update
# for ubuntu
sudo LC_ALL=C.UTF-8 add-apt-repository ppa:ondrej/php # Press enter to confirm.
sudo apt updatePHP CLI and PHP-FPM (recommended)
It is recommended to install PHP-FPM to integrate PHP with web-servers such as Apache, Nginx, and Caddy.
bash
sudo apt install php8.4-cli php8.4-fpmInstall PHP Extensions
bash
sudo apt install php8.4-common php8.4-{bcmath,bz2,curl,gd,gmp,intl,mbstring,opcache,readline,xml,zip,mysql,pgsql,redis,imagick,memcached,soap,xmlrpc,exif,ftp,ldap,sodium}2. Install Nginx
bash
sudo apt install nginx nginx-extras3. Install MySQL (users using distros other than debian, type "mysql-server" instead of "mariadb-server")
bash
# for debian
sudo apt install mariadb-server
# for ubuntu
sudo apt install mysql-serverCreate a custom user as desired.
bash
sudo mysql -u root -psql
CREATE USER 'myapp_user'@'localhost' IDENTIFIED BY 'strong_password';
CREATE DATABASE myapp_db;
GRANT ALL PRIVILEGES ON myapp_db.* TO 'myapp_user'@'localhost';
FLUSH PRIVILEGES;
exitTo connect:
bash
mysql -u myapp_user -p myapp_db4. Install PostgreSQL
bash
sudo apt install postgresql postgresql-contribCreate a custom user as desired.
bash
sudo -u postgres psqlsql
CREATE USER myapp_user WITH PASSWORD 'strong_password';
CREATE DATABASE myapp_db WITH OWNER myapp_user;
GRANT ALL PRIVILEGES ON DATABASE myapp_db TO myapp_user;
\qTo connect:
bash
psql -U myapp_user -d myapp_db5. Install Composer
bash
sudo apt install composer6. Install Laravel
bash
composer global require laravel/installer7. Install phpMyAdmin (optional)
bash
sudo apt install phpmyadminConfigure Nginx to use phpMyAdmin
bash
sudo nano /etc/nginx/sites-available/defaultAdd the following location block inside the server block:
nginx
location /phpmyadmin {
alias /usr/share/phpmyadmin/;
index index.php index.html index.htm;
location ~ ^/phpmyadmin/(.+\.php)$ {
alias /usr/share/phpmyadmin/$1;
fastcgi_pass unix:/run/php/php8.4-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/phpmyadmin/$1;
include fastcgi_params;
}
location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
alias /usr/share/phpmyadmin/$1;
}
}Restart Nginx
bash
sudo systemctl restart nginx