How to remove a script installation after it's completed?

Write a small project in php, it will be installed with a single command git clone. In .htaccess is redirect index.php for install.php
Options +FollowSymLinks
RewriteEngine On
RewriteRule index.php install.php [L]

Ie conceived that the first visit of the host instead of the main page will get to the installation process. Immediately after it .htac—Āess need to remove or clean.
if (unlink('.htaccess')) { echo "File deleted"; } else { echo "Error deleting file"; }

system("echo" > .htaccess");
And even tried to rename
rename('.htaccess', "*.htaccess");
But all this does not work, but the log gets a "permission denied" error. Rights on all files to 755 these scripts work if the entire DocumentRoot to give the 777, but it's a strange decision, especially since the script needs more users to unfold and who knows how they will have the right set up.
Is there a more reliable solution for this problem?
March 19th 20 at 08:33
2 answers
March 19th 20 at 08:35
Why do you need .htaccess? the host is right, that forbids you to work with him.

I on your place would look over the config (config.php) if config exists then start up your website. And if not - then start the process of installation/configuration.
March 19th 20 at 08:37
Rights on all files to 755

To delete a file, you can not only when right and when right there in the directory with this file.
Check that you have rw on the directory?

Find more questions by tags PHP