Cara menggunakan is php 7.4 outdated?

Upgrading or Downgrading PHP versions on a Webdock stack is essentially the same procedure. In short what you need to do is:

  • Ensure the php packages for the version you want are installed
  • Update any configuration for that PHP version
  • Update your web server configuration to point to the correct PHP version
  • Point PHP CLI to the correct PHP version
  • Restart your web server and php-fpm
  • Mask the old php-fpm daemon

Before performing this operation, it is always a good idea to take a snapshot of your server in case something goes wrong!

1. Make sure packages for your target version of PHP are installed

You need to make sure the correct packages are available on your system for the PHP version you want.  First make sure your system is up to date:

sudo apt update
sudo apt upgrade

If it prompts you what to do with config files, usually you should just go with the default option and leave the current config as-is.

Next, install the packages - the packages you want are listed on our Perfect Server stack pages. For example say you want to use PHP7.4 you would go to the 7.4 guide and find the section titled Install PHP7.4 and common PHP packages - the command you are looking for would look something like:

sudo apt install -y php7.4-cli php7.4-dev php7.4-pgsql php7.4-sqlite3 php7.4-gd php7.4-curl php7.4-memcached php7.4-imap php7.4-mysql php7.4-mbstring php7.4-xml php7.4-imagick php7.4-zip php7.4-bcmath php7.4-soap php7.4-intl php7.4-readline php7.4-common php7.4-pspell php7.4-tidy php7.4-xmlrpc php7.4-xsl php7.4-opcache php7.4-apcu

If you get an error claiming the appropriate PHP packages cannot be found, then you are on a really old version of our stacks which does not have the ondrej/php PPA added. In which case, execute:

sudo apt-add-repository ppa:ondrej/php -y

In general, please copy/paste commands from our Perfect Server guides as these are always kept up to date, and commands shown here are for example purposes only!

Finally, you should install php-fpm in the target version you want:

sudo apt install php7.4-fpm

2. Make sure PHP configuration for your target version is updated

Again, here you copy/paste the commands from the Perfect Server guide in the sections titled 

  • Update PHP CLI configuration
  • Tweak PHP-FPM settings
  • Tune PHP-FPM pool settings

3. Update your web server configuration to point to the correct PHP version

For Nginx you would edit /etc/nginx/sites-available/webdock. Look for this line and replace the PHP version number with the one you want:

fastcgi_pass unix:/var/run/php/php7.4-fpm.sock;

For Apache you would edit /etc/apache2/sites-available/webdock.conf and /etc/apache2/sites-available/webdock-le-ssl.conf. Look for this line and replace the PHP version number with the one you want:

SetHandler "proxy:unix:/run/php/php7.4-fpm.sock|fcgi://localhost"

4. Make sure PHP-CLI points to the right PHP version

Especially if you are downgrading, you need to check that php-cli is pointing to the correct version. First check what version the cli is using right now by executing:

sudo php -v

If the version number reported is different than the one you want, execute the following command replacing the version number with the one you want:

sudo rm /etc/alternatives/php; sudo ln -s /usr/bin/php5.6 /etc/alternatives/php;

Confirm by running php -v once more.

5. Restart PHP-FPM and your webserver

For example if your web server is nginx, you would execute:

sudo systemctl restart php7.4-fpm; sudo systemctl restart nginx;

Again, look in the Perfect Server guides for your version and webserver for the correct command here.

Congratulations, you should now be running on the PHP version you want. You can check it by creating a small php file in your web root with the following contents and visiting it in your web browser:

6. Mask the old PHP-FPM daemon

Here you essentially just tell the system to not start the old php-fpm daemon - replace the version number below with the previous version you are moving away from, say if you are going from php7.2 to php7.4 you would do:

A large part of our service involves keeping server-side and client-side software up to date, secure and fast. One of the key elements of our server stack that requires expert maintenance is the PHP programming language, which is a prerequisite for the functioning of the majority of the websites. PHP is an extremely popular and well-supported language and, as any software, its development involves the continuous release of new versions. New versions introduce new features and important performance and security enhancements. As a managed hosting service provider we keep track of how each PHP version evolves, especially how fast it is adopted by the leading application developers, and we make proactive efforts to make sure our customers get all the benefits of the newer versions as soon as possible. Here is our latest PHP maintenance update.

Moving to PHP 7.4 as the server default

As of June 2021, we will be switching the default version on our servers to PHP 7.4. This means that all new sites will be using 7.4, unless manually switched to a different one. PHP 7.4 has been around for more than 2 years now and has already become widely compatible with different CMS’s, themes and plugins, where PHP 7.3 (our current default) is already out of active support and will get out of security support too by the end of this year. Keeping your PHP version up to date has undeniable performance and security advantages and that is why we are now helping you switch to PHP 7.4.

All websites using our Managed PHP service will also be upgraded to 7.4 in the period June 10-21, 2021. PHP 7.3 will still be available on our servers and can be set up manually for any site by our clients from Site Tools > Dev > PHP Manager.

Discontinuing support for 7.2, 7.1, 7.0, 5.6 and lower at the end of the year

At the same time, the security support for all PHP versions below 7.3 has been officially over for quite some time, and given the exploits that leak out once in a while, we believe the risk of using them is growing higher. Additionally, the performance of websites using old PHP versions is considerably lower compared to sites using newer versions. That is why we are starting a process of discontinuation of PHP 7.2, 7.1, 7.0, 5.6 and lower on our servers. After June 21, 2021 we will be gradually updating the sites using old PHP versions to PHP 7.4. PHP versions below 7.3 will no longer be supported on our servers after December 31, 2021.