Redirect a site to HTTPS using PHP

This PHP script will redirect web site visitor to HTTPS (SSL) url. You can add this in your index.php of the web site

Move a site to new URL using PHP

You can also use Apache mod_rewrite .htacess to do the redirection.

Large file upload in PHP

To allow large file upload in PHP, you need to edit php.ini file and change fllowing settings

If you have Dedicated or VPS, you can edit php.ini file using ssh. To find location of this file, upload a phpinfo page to your server, that will display location of php.ini used by your web site.

Some control panel like CPanel have option to edit php.ini settings.

Run .htm files as PHP in Apache

On Ubuntu, to execute .htm files as PHP, create file

Add following content

This is similar code from your PHP configuration. In this case, it is from /etc/apache2/mods-available/php5.6.conf

Now restart apache

Apache | PHP

Laravel Database Migration Error Key too long

When doing a database migration on Laravel, i get following error

This is because MariaDB use different UTF8 format.

To fix, edit file

Inside, find

Replace with

You will also need to add

here is how my file look like after editing.

Laravel

Install PHP 5.6 on Debian

Debian 9 come with PHP 7. To install PHP 5.6, run

Install PHP 5.6 with

Enable SimpleXML module

Install php-fpm if required

See php

Sending Emails from PHP using Amazon SES

To create a PHP script to sent email using Amazon SES, create a folder

Install phpMailer using composer

Create a PHP file with following content

Now test it by running

php

Zend OpCache

PHP Script to Find GeoIP info

Enable PHP Error Reporting

Connect to redis from PHP

PHP Script to List Enabled Extensions

Run .htm files as PHP in Apache

Disable PHP insecure functions with disable_functions
PHP running system commands with exec
Large file upload in PHP

Install PHP