There could be multiple reasons why your setup is not working as expected. The first thing you want to try is access your PHP script yourself by entering its URL in your browser. If you can’t even see the page, then the problem doesn’t come from the script’s folder-creation or file-writing operations, but from the PHP script’s execution itself.
As far as permissions are concerned, one option is to set the directory containing your PHP to 0755 (basically read+execute across the board) although there are more secure options. Here’s a detailed post about configuring things to give write permission to a PHP script: https://unix.stackexchange.com/a/174114
Feel free to send me the URL to your php script at email@example.com if you want me to give a look, although there won’t be much I can do on my end