Increasing PHP File Upload Limit

When it comes to uploading large files (videos in particular,) you will be screaming at your computer wondering why your files won’t upload! This is due to a few things, one in particular is not at all obvious (and took me hours to figure out.) The PHP configuration file (php.ini) has default upload limit settings, which should suffice for most web applications, but for videos and other large files, they are way too small. First, let’s increase those limits. Find and open your php.ini file and enter/edit these values with the following:

upload_max_filesize = 2G
post_max_size = 4G
max_execution_time = 0

The first setting is the obvious one, increase the max upload filesize to 2GB (you can always increase this if needed, of course.) Secondly is your post max size, which is the maximum for the total amount of data per single post. Think of it as uploading multiple videos all at once – the maximum combined size. Always make this number bigger than your upload max filesize, I have doubled it here – which is a bit overkill – just in case. Next up is the max execution time, meaning how long the php script will run before it times out. Just in case your internet is running slow and it takes a bit longer than usual – I set it to zero which means unlimited.

Those are the easy things, but your files still may not be uploading! If you are running FastCGI you may get a mod_fcgid error, which can be fixed by editing your virtual hosts:

FcgidMaxRequestLen 2000000000000000000000000

If my math is right (doubt it,) that should be about 2GB. Now, if you are poor like me and can’t edit your virtual hosts file because you are on a shared server, you will have to switch to standard CGI. Sucks but, it is what it is, unless someone can comment on this post and help me out on that so I can go back to FastCGI!

Lastly is the super tricky thing that took me hours to figure out. I was able to upload files up to ~220MB but no more, why!? I didn’t even get any errors in the log file, no debug information, it simply stopped uploading and failed. The reason, I found out, was because of the default directory PHP uploads to wasn’t big enough! Create yourself a new “tmp” directory in the root of your server and open back up php.ini and enter/edit this line:

upload_tmp_dir = /home/your_shell_username/tmp

Just like that, it works!!!

Installing MAMP (Mac Apache MySQL and PHP stack)

If you are using a version of OSX other than “High Sierra” see this post to setup apache, PHP, and your “Sites” folder, then continue reading this post to setup MySQL.


If you are using OSX High Sierra, apache is already installed on your Mac, start it up:

$ sudo apachectl start

Test that it worked by navigating to “http://localhost” you should see “It works!”


Now let’s install MariaDB (which is a fork of MySQL by the creator of MySQL.) by using homebrew: (visit if you haven’t installed homebrew yet)

$ brew install mariadb

Now start it up:

$ mysql.server start

Add MariaDB (MySQL) as a service, so it auto-starts:

$ brew services start mariadb

Now let’s setup the root user login:

$ sudo mysql_secure_installation

Press enter for current password (none,) then answer yes (Y) and enter your new password twice, then answer yes (Y) for all the following questions.


PHP 7 is already installed on OSX High Sierra so let’s enable it:

$ sudo nano /etc/apache2/httpd.conf

Press ctrl+w to search and type “php” and hit enter, now uncomment the line:

#LoadModule php7_module libexec/apache2/

So that it reads:

LoadModule php7_module libexec/apache2/

Right below that, paste this code:

AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html

That makes sure apache understands PHP code, now we need to make sure apache understands “.php” files. Search for “DirectoryIndex” and change:

<IfModule dir_module>
    DirectoryIndex index.html

To this:

<IfModule dir_module>
    DirectoryIndex index.html index.php

<FilesMatch \.php$>
    SetHandler application/x-httpd-php

Save and exit, then restart apache:

$ sudo apachectl restart

“Sites” Folder:

Create a “Sites” directory inside your home directory:

$ sudo mkdir ~/Sites

The folder icon should automatically change to a Safari design:

Sites Folder

Make an information file:

$ sudo nano ~/Sites/info.php

Paste this code in:

<?php phpinfo(); ?>

Save and exit, now configure your apache to use this folder to host local sites:

$ sudo nano /etc/apache2/httpd.conf

Press ctrl+w and search for “DocumentRoot” and change this:

DocumentRoot "/Library/WebServer/Documents"
<Directory "/Library/WebServer/Documents">

To this:

DocumentRoot "/Users/username/Sites"
<Directory "/Users/username/Sites">

Replacing “username” with your username, of course, and if you don’t know your username you can always check with:

$ whoami

Now restart your apache:

$ sudo apachectl restart

Finally check the info.php file we created earlier by navigating your browser to “http://localhost/info.php”


We will also install PhpMyAdmin to administrate our MariaDB (MySQL) databases:

$ brew install phpmyadmin

Enable your virtual hosts, edit your httpd.conf once again:

$ sudo nano /etc/apache2/httpd.conf

Search for “Virtual hosts” and uncomment this line:

#Include /private/etc/apache2/extra/httpd-vhosts.conf

So it reads:

Include /private/etc/apache2/extra/httpd-vhosts.conf

Now edit the virtual hosts configuration:

$ sudo nano /private/etc/apache2/extra/httpd-vhosts.conf

Paste in your virtual host for PhpMyAdmin:

Alias /phpmyadmin /usr/local/share/phpmyadmin
<Directory /usr/local/share/phpmyadmin/>
    Options Indexes FollowSymLinks MultiViews
    AllowOverride All
    <IfModule mod_authz_core.c>
        Require all granted
    <IfModule !mod_authz_core.c>
        Order allow,deny
        Allow from all

Save and restart apache one last time:

$ sudo apachectl restart

Simply visit “http://localhost/phpmyadmin” to administer your databases! Your login will be “root” and the password you setup earlier. Enjoy! 🙂

Installing PHP 7 on Mac OSX

If you are using older hardware and cannot upgrade to OSX High Sierra (which includes PHP 7) simply use homebrew to upgrade. If you don’t have homebrew yet, visit to install. We will also need the homebrew apache rather than the built-in apache.


Unload the old apache:

$ sudo apachectl stop
$ sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

Now install the homebrew version of apache:

$ brew install httpd


Now install PHP 7:

$ brew install php72
$ brew install php72 --with-httpd --with-thread-safety

Check your version:

$ php --version

If the version isn’t 7, you may have to restart your computer, I had to. Now update your httpd.conf: (notice the location of the httpd.conf differs from the built-in apache, which is located at “/etc/apache2/httpd.conf”)

$ sudo nano /usr/local/etc/httpd/httpd.conf

To load the new PHP 7 module, press ctrl+w and search for “LoadModule” and add this to the end of the list:

LoadModule php7_module /usr/local/opt/php/lib/httpd/modules/
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html

Search for “Listen” and change:

Listen 8080


Listen 80

Search for “DirectoryIndex” and change:

<IfModule dir_module>
    DirectoryIndex index.html

To this:

<IfModule dir_module>
    DirectoryIndex index.html index.php

<FilesMatch \.php$>
    SetHandler application/x-httpd-php

“Sites” Folder:

If you are using the “Sites” folder, search for “DocumentRoot” and change this:

DocumentRoot "/usr/local/var/www"
<Directory "/usr/local/var/www">

To this:

DocumentRoot "/Users/username/Sites"
<Directory "/Users/username/Sites">

Replacing “username” with your username. Save and restart apache:

$ sudo apachectl restart

Create a test file as usual:

$ sudo nano ~/Sites/info.php

And paste in:

<?php phpinfo(); ?>

Navigate your browser to “http://localhost/info.php”

Finally make sure your apache and php services are active:

$ sudo brew services start httpd
$ sudo brew services start php

All done! Enjoy 🙂

Installing LAMP (Linux Apache MySQL and PHP stack)

Unfortunately in the Linux community, nobody can make up their minds for a standard package manager across all distributions. I currently run Ubuntu, so I will be using the Debian “apt” package manager to install software. If you are on a different distro (such as Fedora) you will need to find the corresponding software package for your chosen distro. However, the commands to run the software will be the same.

Installing Apache:

$ sudo apt update
$ sudo apt install apache2

Check to see if it’s installed correctly on your machine, navigate to “http://localhost” in your preferred web browser. You should see a web page that says “It works!” If not, try to start apache manually:

$ sudo systemctl start apache2.service

You can also check the status with:

$ sudo systemctl status apache2

Installing MariaDB:

Typically, one would install MySQL. However, it appears everyone is switching over to MariaDB due to licensing concerns after Oracle’s acquisition. Let’s follow the sheeple! Luckily, MariaDB is a fork of MySQL and is supposedly backwards compatible, so we hopefully won’t have any issues using MySQL commands and queries… hopefully…

$ sudo apt install mariadb-server mariadb-client

Once again it should be up and running automatically. If not:

$ sudo systemctl start mysql.service

You can check the status with:

$ sudo systemctl status mysql

Now let’s setup the root user login:

$ sudo mysql_secure_installation

Press enter for current password (none,) then answer yes (Y) and enter your new password twice, then answer yes (Y) for all the following questions.

Now lets install PHP:

$ sudo apt install php php-common php-mysql php-gd php-cli

Check your installation by creating a simple info.php:

$ echo "<?php phpinfo(); ?>" | sudo tee /var/www/html/info.php

Navigate your browser to this newly created file “http://localhost/info.php” to make sure everything is installed correctly. You should see a web page with currently installed PHP information.

Awesome! Now let’s install the wonderful phpmyadmin to easily manage MySQL/MariaDB databases:

$ sudo apt install phpmyadmin

Select apache2 for your webserver, then select yes and enter a password when asked.

Now restart your web server to make sure everything takes effect:

$ sudo systemctl restart apache2

Now navigate to “http://localhost/phpmyadmin” to administer your databases! If it didn’t work right away, mine didn’t, you will need to copy over the phpmyadmin apache configuration, activate, then restart:

$ sudo cp /etc/phpmyadmin/apache.conf /etc/apache2/conf-available/phpmyadmin.conf
$ sudo a2enconf phpmyadmin
$ sudo systemctl restart apache2

One last thing you have to do, if you try to login as root and use the password you setup earlier it will say access denied, so we must change the plugin from “unix_socket” to “mysql_native_password”

$ sudo mysql
> use mysql;
> UPDATE user SET plugin='mysql_native_password' WHERE User='root';
> exit;

Not sure why the root user is broken by default… oh well. Everything SHOULD be working properly now!

OPTIONAL: If you have a website you would like to run locally, let’s configure a virtual host file. Copy over the default file to a new one and edit it:

$ sudo cp /etc/apache2/sites-available/000-default.conf /etc/apache2/sites-available/
$ sudo nano /etc/apache2/sites-available/

Here is an example virtual host:

<VirtualHost *:80>
   DocumentRoot "/home/users/username/Sites/website/webroot"
   ServerName website.local
   <Directory "/home/users/username/Sites/website/webroot">
       Options Indexes MultiViews FollowSymLinks
       AllowOverride All
       Order allow,deny
       Allow from all

Now activate it:

$ sudo a2ensite

It’s probably a good idea to disable the default virtual host:

$ sudo a2dissite 000-default.conf

Now we have to setup the “hosts” file:

$ sudo nano /etc/hosts

And add: website.local

Replacing “website.local” with whatever you want your locally hosted website name to be (i.e. “mylocalwebsite” or “”) that matches the “ServerName” you set in the virtual host file.

EXTRA OPTIONAL: While you are at it, if you haven’t already, also paste in this awesome host list to absolutely demolish ads, spyware, scams, and reduce bandwidth! I personally commented out/removed “” and “” from the list because I want to keep my history for that particular website.

Restart apache:

$ sudo systemctl restart apache2

Finally, check out your website by posting the host name into your web browser (i.e. “http://website.local”)!

Installing WAMP (Windows Apache MySQL and PHP stack)

Before you make the mistake of downloading “WampServer” (which the download link doesn’t even work – and it hasn’t been updated since 2015!) or similar application, let’s do it the much better “manual” way.

What is WAMP anyway? WAMP stands for Windows Apache MySQL and PHP, a “server stack.” The common stack is LAMP (which uses Linux rather than Windows) which is used 99.9% of the time on web servers. If you are unfortunately stuck using Windows as your development environment, you will want a way to test your web application locally without having to upload it to a web server.

First, download and install the MSVC++ Redistributable, which is required by Apache and PHP.

For a 64-bit machine:


Download apache:

Extract, and then move the “Apache24” directory to “c:\Apache24”
Open a command prompt (cmd.exe) as administrator (right-click, then select “Run as administrator”).

Navigate to the apache binary directory:

> c:\Apache24\bin\

Install the apache service:

> httpd -k install

Start the service:

> httpd -k start

Open your browser and navigate to “http://localhost”
You should see “It works!”

Download and install MariaDB: (this is basically the open-source version of MySQL)

Download PHP thread safe:

Extract the files to “c:\PHP”

Set your PATH variable to include the PHP directory “c:\PHP\”

Now, edit your apache configuration to load the PHP module open the file “c:\Apache24\conf\httpd.conf” and paste in the following text: (at the top or bottom, doesn’t matter)

LoadModule php7_module "c:/PHP/php7apache2_4.dll"
AddHandler application/x-httpd-php .php
AddType application/x-httpd-php .html
PHPIniDir "c:/PHP"

Search for “DirectoryIndex” and change:

<IfModule dir_module>
DirectoryIndex index.html


<IfModule dir_module>
DirectoryIndex index.php index.html

Test that it works in your command prompt:

> httpd -t

In the “c:/PHP” directory, rename the file “php.ini-development” to “php.ini”.

Lastly, restart your apache service:

> httpd -k restart

Create a file called “info.php” in “c:\Apache24\htdocs\” and paste in:

<?php phpinfo(); ?>

Now navigate your broswer to “http://localhost/info.php”

You should see a web page with your PHP configuration. If you see just the code (happened to me,) the apache restart didn’t work, and you have to fully stop and start the apache service again:

> httpd -k stop
> httpd -k start

There is also a task bar utility program for apache called “ApacheMonitor.exe” located in “c:\Apache24\bin” for starting and stopping the apache service.

If it still didn’t work try yelling several curse words at your computer at the top of your lungs. Give it the middle finger a couple times, blame Windows, then write Microsoft a very tasteful complaint. Use your words. Before smashing your computer, also consider installing a Linux distribution, such as Ubuntu, to completely write over and replace Windows entirely. This will solve ALL of your Windows problems instantly. 100% guaranteed!