Tag: PHP

PHP setlocale and strftime Not Working

I was recently having problems displaying the day and month name in my local language after a server move. This was due to a missing locale.

If you don’t have shell access to your server, you may need to contact your web host for assistance. Firstly, check which locales are currently installed on the server. locale -a en_US.utf8 Above we can see only en_US.utf8 is installed. If your required locale is missing, you may need to install it using dpkg-reconfigure locales. sudo pkg-reconfigure…

Continue reading PHP setlocale and strftime Not Working

How to Run Multiple PHP Versions with Apache on Ubuntu 18.04 / 16.04

How to Run Multiple PHP Versions with Apache on Ubuntu 18.04 / 16.04

In this guide we will configure Apache to run PHP 7.x and PHP 5.6 simultaneously, and choose between them using Virtual Hosts or .htaccess.

Prerequisites This guide assumes you have Apache already installed and serving web pages. If you need to install Apache, please see: Installing Apache on Ubuntu 18.04 with Virtual Hosts Installing Apache on Ubuntu 16.04 / 17.10 with Virtual Hosts 1. Add Repository Let’s begin by updating the package lists. sudo apt update For Ubuntu 18.04 users, install libapache2-mod-fcgid. sudo…

Continue reading How to Run Multiple PHP Versions with Apache on Ubuntu 18.04 / 16.04

phpMyAdmin and PHP 7 issues

Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

It’s possible that when you installed phpMyAdmin, the version in the repository (phpMyAdmin v4.6.6) was not fully compatible with PHP 7.2. There is a newer version available on the official website (v4.8 as of writing), which fixes these compatibility issues with PHP 7.2.

sql.lib.php This error is caused by a line of code in /usr/share/phpmyadmin/libraries/sql.lib.php. If you don’t want to wait for the repositories to update with the latest version, it is strongly recommended that you manually upgrade to the latest version of phpMyAdmin yourself. Alternatively, you can make a change to sql.lib.php to temporarily fix the error. Firstly, backup sql.lib.php before editing.…

Continue reading Problem with phpMyAdmin and PHP 7.2: “Warning in ./libraries/sql.lib.php#613 count(): Parameter must be an array or an object that implements Countable”

Installing Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 18.04

Installing Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 18.04

Ubuntu Server 18.04 LTS (Bionic Beaver) is finally here and is being rolled out across VPS hosts such as DigitalOcean and AWS. In this guide we will install a LEMP Stack (Nginx, MySQL, PHP) and configure a web server.

Video Tutorial

Prerequisites You should use a non-root user account with sudo privileges. Please see the Initial server setup for Ubuntu 18.04 guide for more details. 1. Install Nginx Let’s begin by updating the package lists and installing Nginx on Ubuntu 18.04. Below we have two commands separated by &&. The first command will update the package lists to ensure you…

Continue reading Installing Nginx, MySQL, PHP (LEMP) Stack on Ubuntu 18.04

Installing PHP for Nginx on Ubuntu 18.04

Installing PHP for Nginx on Ubuntu 18.04

In this guide we will install and configure PHP to work with Nginx on Ubuntu 18.04 LTS (Bionic Beaver). Unlike Apache, Nginx does not contain native PHP processing. For that we have to install PHP-FPM (FastCGI Process Manager). FPM is an alternative PHP FastCGI implementation with some additional features useful for heavy-loaded sites.

1. Install PHP-FPM Let’s begin by updating the package lists and installing PHP-FPM on Ubuntu 18.04. Below we have two commands separated by &&. The first command will update the package lists to ensure you get the latest version and dependencies for PHP-FPM. The second command will then download and install PHP-FPM. Press y and ENTER when asked to…

Continue reading Installing PHP for Nginx on Ubuntu 18.04

Installing Apache, MySQL, PHP (LAMP) stack on Ubuntu 18.04

Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04

Ubuntu Server 18.04 LTS (Bionic Beaver) is finally here and is being rolled out across VPS hosts such as DigitalOcean and AWS. In this guide we will install a LAMP Stack (Apache, MySQL, PHP) and configure a web server.

Video Tutorial

Prerequisites You should use a non-root user account with sudo privileges. Please see the Initial server setup for Ubuntu 18.04 guide for more details. 1. Install Apache Let’s begin by updating the package lists and installing Apache on Ubuntu 18.04. Below we have two commands separated by &&. The first command will update the package lists to ensure you get…

Continue reading Installing Apache, MySQL, PHP (LAMP) Stack on Ubuntu 18.04

Installing PHP for Apache on Ubuntu 18.04 Server

Installing PHP for Apache on Ubuntu 18.04 Server

In this guide we will install PHP 7 and configure it to work with the Apache web server on Ubuntu Server 18.04 (Bionic Beaver). The PHP Hypertext Preprocessor (PHP) is a programming language that allows web developers to create dynamic and interactive Web pages. As of 2018, PHP was used as the server-side programming language on 85% of 10 million most popular websites!

Video Tutorial

Prerequisites You should use a non-root user account as explained in the Ubuntu 18.04 Initial Server Setup. You should also have Apache already installed and be able to access a test web page in your browser as explained in our guide Installing Apache on Ubuntu 18.04 Server with Virtual Hosts. 1. Install PHP Let’s begin by…

Continue reading Installing PHP for Apache on Ubuntu 18.04 Server

PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

cURL is a PHP extension used to transfer data to or from a remote server. If the extension is not installed on your web server, you may get a fatal PHP error about an undefined function curl_init().

Shared Hosting If you are on shared hosting and do not have command line access to your web server, you may have to contact your web host to see if they support the cURL PHP extension. Many web hosts disable this extension by default for security reasons but may enable it manually for you on…

Continue reading PHP Fatal error: Uncaught Error: Call to undefined function curl_init()

Enable PHP short open tags in PHP.ini

How to Enable PHP Short Open Tag (short_open_tag)?

PHP short open tags is a deprecated feature of PHP and it’s been recommended for several years that you not use the short tag “short cut” and instead to use the full <?php and ?> tag combination. But because this short cut has been a feature for such a long time, it’s currently still supported for backwards compatibility.

1. Locate php.ini Firstly, you need to locate your php.ini file. In this example, our php.ini is located in /etc/php/7.2/apache2/php.ini, however, this may be different for you depending on your PHP version. If you are unsure, please read: Where is my PHP php.ini Configuration File Located? 2. Apache Edit the PHP config. Replace php7.2 with your own version, e.g, php5.6, php7.1, etc. (Use ls /etc/php/…

Continue reading How to Enable PHP Short Open Tag (short_open_tag)?