php | LinuxHostSupport Linux Tutorials and Guides Mon, 25 Mar 2024 11:06:33 +0000 en-US hourly 1 https://wordpress.org/?v=6.6.1 How to Install PHP 8.3 on Ubuntu 24.04 https://linuxhostsupport.com/blog/how-to-install-php-8-3-on-ubuntu-24-04/ https://linuxhostsupport.com/blog/how-to-install-php-8-3-on-ubuntu-24-04/#comments Tue, 30 Apr 2024 17:30:00 +0000 https://linuxhostsupport.com/blog/?p=2078 This tutorial will teach you how to install PHP 8.3 on Ubuntu 24.04. PHP is a scripting language used for development purposes. It was an abbreviation for Personal Home Page, but now it stands for the recursive initialism known as PHP Hypertext Preprocessor. PHP is used for creating dynamic web pages, and according to the […]

The post How to Install PHP 8.3 on Ubuntu 24.04 appeared first on LinuxHostSupport.

]]>
This tutorial will teach you how to install PHP 8.3 on Ubuntu 24.04. PHP is a scripting language used for development purposes. It was an abbreviation for Personal Home Page, but now it stands for the recursive initialism known as PHP Hypertext Preprocessor. PHP is used for creating dynamic web pages, and according to the reports in 2024, PHP is used by 76% of all websites whose programming language can be determined. Most popular CMS systems like WordPress, Drupal, or Joomla are written in PHP. The latest stable version of PHP is PHP 8.3.

Installing PHP 8.3 and its extensions is straightforward and may take a few minutes. Let’s get started!

Prerequisites to install PHP 8.3 on Ubuntu 24.04

  • A server running Ubuntu 24.04 or any Linux OS
  • User privileges: root or non-root user with sudo privileges

Step 1. Update the system

We assume that you have a fresh installation of Ubuntu 24.04, and we need to update the system before we start installing PHP 8.3. To do that, execute the following commands:

sudo apt update -y && sudo apt upgrade -y

Step 2. Install PHP 8.3

Once the system is updated, we can install the latest stable version of PHP8.3. This version is, by default, enabled in the Ubuntu 24.04 repository, and we do not need to add any keys and repositories. The installation command is straightforward:

sudo apt install php8.3 -y

After successful installation, you can check the version of the PHP:

php -v

You should get the following output:

root@host:~# php -v
PHP 8.3.0-1ubuntu1 (cli) (built: Jan 19 2024 14:00:34) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.3.0, Copyright (c) Zend Technologies
    with Zend OPcache v8.3.0-1ubuntu1, Copyright (c), by Zend Technologies

Step 3. Install PHP 8.3 extensions

Installation of the PHP itself will not run the websites smoothly. We need additional modules, such as PHP, to work with MySQL, with images, for HTTP requests, XML data, etc. In the next command, we will install a couple of PHP extensions that are very important for one website:

sudo apt install libapache2-mod-php php8.3-common php8.3-cli php8.3-mbstring php8.3-bcmath php8.3-fpm php8.3-mysql php8.3-zip php8.3-gd php8.3-curl php8.3-xml -y

After the installation, we can check the installed PHP modules with the command below:

php -m

We will get a long list of modules:

root@host:~# php -m
[PHP Modules]
bcmath
calendar
Core
ctype
curl
date
dom
exif
FFI
fileinfo
filter
ftp
gd
gettext
hash
iconv
json
libxml
mbstring
mysqli
	.
	.
	.
	.
xml
xmlreader
xmlwriter
xsl
Zend OPcache
zip
zlib	

Step 4. Test PHP

Now, in this last step, we will make a test PHP file in our web server document root to test whether or not the PHP is working. But before that, we need to install the Apache Web server:

sudo apt install apache2 -y

After installation, start and enable the service:

sudo systemctl start apache2 && sudo systemctl enable apache2

If everything is ok, check the status of the service:

sudo systemctl status apache2

You should get output similar to this:

root@host:# sudo systemctl status apache2
● apache2.service - The Apache HTTP Server
     Loaded: loaded (/usr/lib/systemd/system/apache2.service; enabled; preset: enabled)
     Active: active (running) since Thu 2024-03-14 07:33:03 CDT; 8min ago
       Docs: https://httpd.apache.org/docs/2.4/
   Main PID: 92315 (apache2)
      Tasks: 7 (limit: 4624)
     Memory: 16.1M (peak: 16.2M)
        CPU: 170ms
     CGroup: /system.slice/apache2.service

Next, go into your Apache document root:

cd /var/www/html

Create info.php file:

touch info.php

Open the file with your favorite editor and paste the following lines of code:

<?php
phpinfo();
?>

Save the file, close it, and restart the Apache service.

sudo systemctl restart apache2

Now you can access the file in the browser by vising the following URL: http:YourServerIPaddress:/info.php

Learn how to Install PHP 8.3 on Ubuntu 24.04

That’s it. You successfully learned how to install PHP 8.3 on Ubuntu 24.04. Of course, you do not have to do this on your own. Our admins can help you with any aspect of the PHP installation on your server. Feel free to contact us. We are available 24/7.

PS. If you liked this post on how to install PHP 8.3 on Ubuntu 24.04, please share it with your friends on social networks or leave a comment in the comments section. Thank you.

The post How to Install PHP 8.3 on Ubuntu 24.04 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-php-8-3-on-ubuntu-24-04/feed/ 1
How to Install PHP 8 on Debian https://linuxhostsupport.com/blog/how-to-install-php-8-on-debian/ https://linuxhostsupport.com/blog/how-to-install-php-8-on-debian/#respond Tue, 30 Jan 2024 18:30:00 +0000 https://linuxhostsupport.com/blog/?p=2026 Let’s follow this step-by-step guide on how to install PHP 8.0 on Debian 10. PHP is an open-source general-purpose scripting language, mostly used by web developers as it can easily be embedded into HTML. PHP version 8.0 was officially released on November 26, 2020, and it is the latest release of the PHP language. It […]

The post How to Install PHP 8 on Debian appeared first on LinuxHostSupport.

]]>
Let’s follow this step-by-step guide on how to install PHP 8.0 on Debian 10. PHP is an open-source general-purpose scripting language, mostly used by web developers as it can easily be embedded into HTML.

PHP version 8.0 was officially released on November 26, 2020, and it is the latest release of the PHP language. It is packed with lots of new improvements, features, and optimizations including named arguments, attributes, constructor property promotion, JIT (Just in Time Compiler), match expression, union types, null safe operator, better error handling, improvements in the type system, and better consistency.

Also, according to multiple tests, PHP 8.0 can handle much more requests per second compared to the older versions of PHP. If your PHP-based website or application is fully compatible with PHP 8.0 you should definitely consider upgrading to the latest version.

Prerequisites

  • A Linux VPS or server running Debian 10.
  • SSH access
  • System user with sudo or root privileges

Login and Update the server

In order to start with the installation of PHP 8.0 on our Debian 10 server, we have to access the server via SSH. We will log in as the root user, but you can use any system user which has sudo privileges:

ssh root@IP_Address -p Port_number

IP_Address and Port_number should be replaced with the actual IP address and SSH port number.

Once the SSH connection is established and you are in, in order to have the latest bug fixes, new features, and security fixes of all installed packages, it is always a good idea to update the installed packages on the server.

apt update && apt upgrade

Add third party APT repository

Debian 10 by default has PHP 7.3 in its repositories. To check what PHP version is available in the Debian repositories, run the following command:

apt-cache policy php

Output:

php:
Installed: 2:7.3+69
Candidate: 2:7.3+69
Version table:
*** 2:7.3+69 500
500 http://httpredir.debian.org/debian buster/main amd64 Packages
100 /var/lib/dpkg/status

Or if PHP is already installed on the VPS, check the installed version:

php -v

Output:

PHP 7.3.27-1~deb10u1 (cli) (built: Feb 13 2021 16:31:40) ( NTS )
Copyright (c) 1997-2018 The PHP Group
Zend Engine v3.3.27, Copyright (c) 1998-2018 Zend Technologies
with Zend OPcache v7.3.27-1~deb10u1, Copyright (c) 1999-2018, by Zend Technologies

From the output above we can see that we can only install PHP 7.3 from the official Debian repositories, so if need the latest PHP 8.0 version, we will have to add a third-party repository. But first, let’s install some necessary packages:

apt -y install apt-transport-https software-properties-common gnupg2

Once the packages are installed, download the GPG key and add it to your server to verify the necessary PHP packages

wget -qO - https://packages.sury.org/php/apt.gpg | sudo apt-key add -

Create a Personal Package Archives (PPAs) file with the new PHP repository

echo "deb https://packages.sury.org/php/ buster main" | sudo tee /etc/apt/sources.list.d/php.list

And finally, update the repositories and install PHP 8.

apt update && apt install php8.0

Once all dependencies are installed, check the version of PHP installed on your Debian 10 server, to confirm that PHP 8 is successfully installed

php -v

Output:

PHP 8.0.9 (cli) (built: Jul 30 2021 13:09:07) ( NTS )
Copyright (c) The PHP Group
Zend Engine v4.0.9, Copyright (c) Zend Technologies
with Zend OPcache v8.0.9, Copyright (c), by Zend Technologies

Install PHP 8 extensions

In order to enable some extra features, functionalities, or libraries, PHP has lots of additional extensions. To check the list of all available extensions for PHP 8.0, execute the following command:

apt search php8.0-*

Output:

…
php8.0-maxminddb/buster 1.10.1-1+0~20210802.2+debian10~1.gbp162f0b amd64
Reader for the MaxMind DB file format for PHP

php8.0-maxminddb-dbgsym/buster 1.10.1-1+0~20210802.2+debian10~1.gbp162f0b amd64
debug symbols for php8.0-maxminddb

php8.0-mbstring/buster 8.0.9-1+0~20210730.22+debian10~1.gbp99e7e9 amd64
MBSTRING module for PHP

php8.0-mbstring-dbgsym/buster 8.0.9-1+0~20210730.22+debian10~1.gbp99e7e9 amd64
debug symbols for php8.0-mbstring

php8.0-mcrypt/buster 3:1.0.4-5+0~20210223.3+debian10~1.gbp68347e amd64
PHP bindings for the libmcrypt library
…

If for some reason you need to install the PHP mbstring extension for example, you can easily do it with the following command:

apt -y install php8.0-mbstring

That’s all. If you closely followed the tutorial, you have successfully installed PHP 8 on your Debian 10 VPS from a third-party repository. If you need more specific details about this major update of PHP, you can check their release notes or their documentation.

Of course, you don’t need to install PHP 8.0 on Debian 10 yourself if you use our Linux server management plans, in which case you can simply ask our team of expert Linux admins to install and set this up for you. They are available 24/7 and will take care of your request immediately.

If you liked this post on how to install PHP 8.0 on Debian 10, please share it with your friends on the social networks by using the share shortcuts, or simply leave a comment in the comments section. Thank you.

The post How to Install PHP 8 on Debian appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/how-to-install-php-8-on-debian/feed/ 0
Speed up your application by upgrading to PHP 7 https://linuxhostsupport.com/blog/speed-up-your-application-by-upgrading-to-php-7/ https://linuxhostsupport.com/blog/speed-up-your-application-by-upgrading-to-php-7/#comments Tue, 21 Feb 2017 13:28:13 +0000 https://linuxhostsupport.com/blog/?p=15 In this tutorial, we are going to provide you with step by step instructions on how to install PHP 7 on an Ubuntu 16.04 VPS and on a CentOS 7 VPS. PHP 7 is the latest version of the PHP processing engine and it is faster than any other previous version of PHP. Also, PHP […]

The post Speed up your application by upgrading to PHP 7 appeared first on LinuxHostSupport.

]]>
In this tutorial, we are going to provide you with step by step instructions on how to install PHP 7 on an Ubuntu 16.04 VPS and on a CentOS 7 VPS. PHP 7 is the latest version of the PHP processing engine and it is faster than any other previous version of PHP. Also, PHP 7 consumes less memory.

Install PHP 7 on Ubuntu

Make sure your server OS packages are fully up to date by running the following commands:

sudo apt-get update 
sudo apt-get upgrade

Install PHP and commonly used PHP packages:

sudo apt-get install php7.0-cli php7.0-common php7.0-json php7.0-readline php7.0-xml php7.0-mysql php7.0-mcrypt php7.0-gd

To make sure that PHP 7 is installed on your server, run the following command:

sudo php -v

You should get an output like this:

PHP 7.0.13-0ubuntu0.16.04.1 (cli) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2016 Zend Technologies
with Zend OPcache v7.0.13-0ubuntu0.16.04.1, Copyright (c) 1999-2016, by Zend Technologies

If you’d like to install additional PHP 7 modules, like OPCache for example, you can use the command below:

sudo apt-get install php7.0-opcache

In order to search for available PHP 7 modules, run:

sudo apt-cache search php7

To see which files are used by PHP in CLI mode, run:

# php --ini
Configuration File (php.ini) Path: /etc/php/7.0/cli
Loaded Configuration File:         /etc/php/7.0/cli/php.ini
Scan for additional .ini files in: /etc/php/7.0/cli/conf.d
Additional .ini files parsed:      /etc/php/7.0/cli/conf.d/10-mysqlnd.ini,
/etc/php/7.0/cli/conf.d/10-opcache.ini,
/etc/php/7.0/cli/conf.d/10-pdo.ini,
/etc/php/7.0/cli/conf.d/15-xml.ini,
/etc/php/7.0/cli/conf.d/20-calendar.ini,
/etc/php/7.0/cli/conf.d/20-ctype.ini,
/etc/php/7.0/cli/conf.d/20-dom.ini,
/etc/php/7.0/cli/conf.d/20-exif.ini,
/etc/php/7.0/cli/conf.d/20-fileinfo.ini,
/etc/php/7.0/cli/conf.d/20-ftp.ini,
/etc/php/7.0/cli/conf.d/20-gd.ini,
/etc/php/7.0/cli/conf.d/20-gettext.ini,
/etc/php/7.0/cli/conf.d/20-iconv.ini,
/etc/php/7.0/cli/conf.d/20-json.ini,
/etc/php/7.0/cli/conf.d/20-mcrypt.ini,
/etc/php/7.0/cli/conf.d/20-mysqli.ini,
/etc/php/7.0/cli/conf.d/20-pdo_mysql.ini,
/etc/php/7.0/cli/conf.d/20-phar.ini,
/etc/php/7.0/cli/conf.d/20-posix.ini,
/etc/php/7.0/cli/conf.d/20-readline.ini,
/etc/php/7.0/cli/conf.d/20-shmop.ini,
/etc/php/7.0/cli/conf.d/20-simplexml.ini,
/etc/php/7.0/cli/conf.d/20-sockets.ini,
/etc/php/7.0/cli/conf.d/20-sysvmsg.ini,
/etc/php/7.0/cli/conf.d/20-sysvsem.ini,
/etc/php/7.0/cli/conf.d/20-sysvshm.ini,
/etc/php/7.0/cli/conf.d/20-tokenizer.ini,
/etc/php/7.0/cli/conf.d/20-wddx.ini,
/etc/php/7.0/cli/conf.d/20-xmlreader.ini,
/etc/php/7.0/cli/conf.d/20-xmlwriter.ini,
/etc/php/7.0/cli/conf.d/20-xsl.ini

If you only want to locate your php.ini configuration file, use:

# php -i | grep -i php.ini
Configuration File (php.ini) Path => /etc/php/7.0/cli
Loaded Configuration File => /etc/php/7.0/cli/php.ini

The PHP Opcache extension can boost PHP performance by a large amount, so edit the PHP configuration file:

vi /etc/php/7.0/cli

Add the following lines in the ‘[opcache]’ section:

opcache.enable=1;
opcache.memory_consumption=256;
opcache.max_accelerated_files=20000;
opcache.max_wasted_percentage=10;
opcache.revalidate_freq=360;
opcache.fast_shutdown=0;
opcache.enable_cli=0;
opcache.revalidate_path=0;
opcache.validate_timestamps=0;
opcache.interned_strings_buffer=32;
opcache.fast_shutdown=1;

Do not forget to restart the web server for the changes to take effect:

service apache2 restart

Install PHP 7 on CentOS

Make sure that all OS packages are up to date:

yum clean all
yum update

Check if there are any installed PHP packages, e.g:

rpm -qa | grep php
php-cli-5.4.16-42.el7.x86_64
php-pdo-5.4.16-42.el7.x86_64
php-common-5.4.16-42.el7.x86_64
php-5.4.16-42.el7.x86_64
php-mysql-5.4.16-42.el7.x86_64

Remove PHP 5.4 packages prior installing PHP 7:

yum remove php-cli php-pdo php-common php php-mysql

Add the required repositories:

cd /opt
wget https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
wget https://mirror.webtatic.com/yum/el7/webtatic-release.rpm
rpm -Uvh epel-release-latest-7.noarch.rpm
rpm -Uvh webtatic-release.rpm

Install PHP 7 and PHP 7 packages:

yum install php70w  php70w-cli php70w-mysql php70w-pdo php70w-common

To search for available PHP7 modules, run:

yum search php70w

You may install additional PHP extensions, like mycrypt, mbstring, OPCache etc.:

yum install php70w-opcache php70w-mcrypt php70w-mbstring

Check the PHP 7 version installed on your server:

#php -v
PHP 7.0.15 (cli) (built: Jan 19 2017 21:35:05) ( NTS )
Copyright (c) 1997-2017 The PHP Group
Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies
    with Zend OPcache v7.0.15, Copyright (c) 1999-2017, by Zend Technologies

To optimize PHP 7, locate the PHP configuration file and edit it:

#php -i | grep -i php.ini
Configuration File (php.ini) Path => /etc
Loaded Configuration File => /etc/php.ini
vi /etc/php.ini

Add the following lines:

max_execution_time: 600
max_input_time: 600
max_input_vars: 5000
upload_max_filesize: 64M

Also, enable OPCache and configure it by adding the same settings in the ‘[opcache]’ section as on the Ubuntu 16.04 VPS.
Restart the Apache web server for the changes to take effect:

systemctl restart httpd

Of course, you don’t have to do any of this if you use one of our Software Installation services, in which case you can simply ask our expert Linux admins to install PHP 7 for you. They are available 24×7 and will take care of your request immediately.

PS. If you liked this post please share it with your friends on the social networks using the buttons on the left or simply leave a reply below. Thanks.

The post Speed up your application by upgrading to PHP 7 appeared first on LinuxHostSupport.

]]>
https://linuxhostsupport.com/blog/speed-up-your-application-by-upgrading-to-php-7/feed/ 3