How to update php debian
PHP 8.1 is the latest PHP version released on 2021. In this guide you are going to learn how to install the latest PHP version which is currently 8.1 on your Debian system or server and configure it with Apache and Nginx. You will also learn how to upgrade your PHP version to latest. Show
This tutorial guides you to configure PHP INI settings, FPM settings, Pools, etc which is more useful for your application to run smooth. This installation is tested on Google Cloud Platform with a Compute Compute Engine VM Instance. This set up will work on all Linux servers. PrerequisitesBasic knowledge of using SSH Terminal on Linux. Getting StartedMake sure your Debian server is having the latest packages by running the following command. sudo apt update This will update the package index and update the installed packages to the latest version. Download SURY PPA for PHP 8.1Download the Sury PPA for PHP 8.1 package using sudo apt -y install lsb-release apt-transport-https ca-certificates wget sudo wget -O /etc/apt/trusted.gpg.d/php.gpg https://packages.sury.org/php/apt.gpg Once you have downloaded the PPA you can add it to the server packages. echo "deb https://packages.sury.org/php/ $(lsb_release -sc) main" | sudo tee /etc/apt/sources.list.d/php.list Now you can proceed the installation of PHP 8 by updating the system. sudo apt update Once you have added the Surry PPA you can install PHP 8.1. Install PHP 8.1 for ApacheExecute the following command to install PHP 8.1 sudo apt install php8.1 After the installation has completed, you can confirm the installation using the following command php -v Install PHP 8.1 FPM for NginxFor Nginx you need to install FPM. Execute the following command to install PHP 8.1 FPM sudo apt install php8.1-fpm After the installation has completed, confirm that PHP 8.1 FPM has installed correctly with this command php-fpm8.1 -v Install PHP 8.1 ExtensionsInstalling PHP extensions are simple with the following syntax. sudo apt install php8.1-extension_name Now,
install some commonly used sudo apt install php8.1-common php8.1-mysql php8.1-xml php8.1-xmlrpc php8.1-curl php8.1-gd php8.1-imagick php8.1-cli php8.1-dev php8.1-imap php8.1-mbstring php8.1-opcache php8.1-soap php8.1-zip php8.1-redis php8.1-intl -y Configure PHP 8.1Now we configure PHP for Web Applications by changing some values in For PHP 8.1 with Apache the sudo nano /etc/php/8.1/apache2/php.ini For PHP 8.1 FPM with Nginx the sudo nano /etc/php/8.1/fpm/php.ini Hit upload_max_filesize = 32M Once you have modified your PHP settings you need to restart your Apache for the changes to take effect. For users with Nginx to who use PHP-FPM, you need to restart PHP-FPM. sudo service php8.1-fpm restart Configure PHP 8.1 FPM PoolsPHP-FPM allows you to configure the sudo nano /etc/php/8.1/fpm/pool.d/www.conf If you want to change the username name you can change the following lines by
replacing the www-data with your user = username group = username listen.owner = username listen.group = username Hit Restart PHP 8.1 FPMOnce you have updated your PHP FPM settings you need to restart it to apply the changes. sudo php-fpm8.1 -t sudo service php8.1-fpm restart Now you are having PHP 8.1 Installed and configured. Prepare yourself for a role working as an Information Technology Professional with Linux operating system Upgrade to PHP 8.1 for ApacheOnce you have installed PHP 8.1 you need to upgrade to the latest installed version of PHP. You need to tell Apache to use the PHP 8.1version we installed right now. Disable the old PHP module (below I have mentioned php7.4, you need to use your current php version used by Apache) and enable the new PHP module using the following command. Replace the current enabled PHP version with your version. sudo a2dismod php7.4 sudo a2enmod php8.1 Restart Apache for the changes to take effect. sudo service apache2 restart Upgrade PHP 8.1 for NginxFor Nginx you need to update the PHP-FPM socket in your Nginx configration located inside the Edit your configuration… sudo nano /etc/nginx/sites-available/your.conf The line you need to modify will look like this… fastcgi_pass unix:/run/php/php7.4-fpm.sock; You need to replace the old PHP version with the new version. fastcgi_pass unix:/run/php/php8.1-fpm.sock; Test your configration. sudo nginx -t Save the file and exit the editor and restart Nginx for the changes to take effect. sudo service nginx restart ConclusionNow you have learned how to install PHP 8.1 on your Debian server for Apache and Nginx and also how to upgrade to latest version. Thanks for your time. If you face any problem or any feedback, please leave a comment below. How do I upgrade to the latest version of PHP?How do I change the PHP version?. Log in to your one.com control panel.. Scroll down to the Advanced settings tile and select PHP and database settings.. Scroll down to Update PHP version.. Select the PHP version you want to switch to and click Update.. How install PHP modules Debian 11?How to Install PHP 7.4 on Debian 11 Bullseye. Update Debian.. Install Required Packages.. Import Ondřej Surý PHP Repository.. Install PHP 7.4 with Apache Option. Install Apache Module. Install Apache with PHP-FPM.. Install PHP 7.4 with Nginx Option.. Comments and Conclusion.. How do I update Debian?How to Upgrade from Debian 10 to Debian 11. Step 1: Update Existing Server Packages. SSH to the server as a regular user with sudo privileges. ... . Step 2: Back Up the Server. ... . Step 3: Change the Debian Sources. ... . Step 3: Upgrade Debian. ... . Step 4: Reboot the Server. ... . Step 5: Verify Applications and Services. ... . Step 6: Secure the Server.. How do I install the latest version of PHP in Linux?Follow the below steps to install PHP on Linux:. Step 1: Open your terminal in Linux. On your Linux computer open the terminal. ... . Step 2: Update your packages. On your terminal update your packages using the following command. ... . Step 3: Upgrade your packages. ... . Step 4: Install PHP.. |