Tag: PHP

Guide: Installing PHP for Apache (Ubuntu 16.04 / 17.10)

In this guide we will install and configure PHP for Apache on  Ubuntu 16.04 / 17.10. 1. Install PHP Let’s begin by updating the package lists. sudo apt-get update Now install PHP and associated packages. sudo apt-get install php libapache2-mod-php php-mcrypt php-mysql 2. Configure Apache We will need to alter the dir.conf file to tell Apache…

Continue reading Guide: Installing PHP for Apache (Ubuntu 16.04 / 17.10)

PHP / Apache: set max file upload and post size

Firstly, you need to locate your php.ini file. In this example, our php.ini file is located in /etc/php/7.2/apache2/php.ini sudo nano /etc/php/7.2/apache2/php.ini In nano, press CTRL + W and search for upload_max_filesize and change the value to 64M (for 64 megabytes). /etc/php/7.2/apache2/php.ini … upload_max_filesize = 64M … Press CTRL + W again and search for post_max_size and…

Continue reading PHP / Apache: set max file upload and post size

How to Restart PHP-FPM service and reload config

To restart the PHP-FPM service and reload the configuration file, firstly check which version of PHP you are running: php -v PHP 7.0.30-0ubuntu0.16.04.1 (cli) ( NTS ) Copyright (c) 1997-2017 The PHP Group Zend Engine v3.0.0, Copyright (c) 1998-2017 Zend Technologies with Zend OPcache v7.0.30-0ubuntu0.16.04.1, Copyright (c) 1999-2017, by Zend Technologies Above we can see…

Continue reading How to Restart PHP-FPM service and reload config

PHP / Nginx: set max file upload and post size

Firstly, you need to locate your php.ini file. In this example, our php.ini file is located in /etc/php/7.0/fpm/php.ini sudo nano /etc/php/7.0/fpm/php.ini In nano, press CTRL + W and search for upload_max_filesize and change the value to 64M (for 64 megabytes). /etc/php/7.0/fpm/php.ini … upload_max_filesize = 64M … Press CTRL + W again and search for post_max_size and…

Continue reading PHP / Nginx: set max file upload and post size

PHP php.ini Configuration File location

Where is my PHP php.ini Configuration File Located?

As there are multiple versions of PHP with different sever configurations, php.ini could be located in several different folders.

Method 1 One way to find out exactly which php.ini file your web sever is using is by creating a new PHP file in document root called info.php. info.php <?php phpinfo(); Load this file in your browser, press CTRL + F and search for “Loaded Configuration File”. You should see something like /etc/php/7.2/apache2/php.ini This will tell…

Continue reading Where is my PHP php.ini Configuration File Located?

How to create a simple PHP cache script

$cache_file = getcwd().’/filename.cache’; if (file_exists($cache_file) && (filemtime($cache_file) > (time() – 60 * 9 ))) { header(‘Content-Type: application/json’); echo file_get_contents($cache_file); } else { $feed = “content to cache”; file_put_contents($cache_file, $feed, LOCK_EX); echo $feed; }

Continue reading How to create a simple PHP cache script