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

The default PHP max file upload and post value is actually quite small (around 2 MB) for security reasons. In this guide we will increase the max value using php.ini.

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. Edit php.ini Open your php.ini file with nano. sudo nano…

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.2.15-1+ubuntu18.04.1+deb.sury.org+1 (cli) (built: Feb 8 2019 15:38:01) ( NTS ) Copyright (c) 1997-2018 The PHP Group Zend Engine v3.2.0, Copyright (c) 1998-2018 Zend Technologies with Zend OPcache v7.2.15-1+ubuntu18.04.1+deb.sury.org+1, Copyright (c) 1999-2018, by Zend…

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