(SOLVED) Template phpcgi not working - Hack included to Automate php.ini to cgi-bin
(SOLVED) Template phpcgi not working - Hack included to Automate php.ini to cgi-bin
Hello this is my first time posting, I tried the phpCGI setting for the apache web template and had problems that i could not figure out till now and even learned how to write simply bash while searching for a solution. Firstly im using Vestacp 0.9.8.15 on ubuntu 14.04 for only 2 days, I wanted to use php with a independent php.ini. in my cgi-bin(i saw this in cpanel) I selected phpcgi for the Web Template. But my php files located in my public html folder did not work, regular html files worked. I tried to run info.php from my public html folder, the browser would return a 404 error with the message:
Now for the Hack. Automate php.ini to cgi-bin when using phpcgi
The server was still using a shared php.ini (I assume) so i edited the file phpcgi.sh (/usr/local/vesta/data/templates/web/apache2/phpcgi.sh) with the skills i just learnt.
Original :
To:
Now every time hosting is created in VestaCP with the phpcgi template, a fresh copy of /etc/php5/cgi/php.ini is created in the domain cgi-bin folder.
Disclaimer: Not a programmer feel free to fix code
but my file was not in cgi-bin. What was the problem??? VestaCP default installation did not enable the apache CGI module. I enabled the Apache CGI module (using Webmin) and my main problem was fixed.The requested URL /cgi-bin/info.php was not found on this server.
Now for the Hack. Automate php.ini to cgi-bin when using phpcgi
The server was still using a shared php.ini (I assume) so i edited the file phpcgi.sh (/usr/local/vesta/data/templates/web/apache2/phpcgi.sh) with the skills i just learnt.
Original :
Code: Select all
#!/bin/bash
# Adding php wrapper
user="$1"
domain="$2"
ip="$3"
home_dir="$4"
docroot="$5"
wrapper_script='#!/usr/bin/php-cgi -cphp5-cgi.ini'
wrapper_file="$home_dir/$user/web/$domain/cgi-bin/php"
echo "$wrapper_script" > $wrapper_file
chown $user:$user $wrapper_file
chmod -f 751 $wrapper_file
exit 0
Code: Select all
#!/bin/bash
# Adding php wrapper
user="$1"
domain="$2"
ip="$3"
home_dir="$4"
docroot="$5"
wrapper_script='#!/usr/bin/php-cgi -c'"$home_dir"'/'"$user"'/web/'"$domain"'/cgi-bin/php.ini'
wrapper_file="$home_dir/$user/web/$domain/cgi-bin/php"
phpini_file="$home_dir/$user/web/$domain/cgi-bin/php.ini"
echo "$wrapper_script" > $wrapper_file
chown $user:$user $wrapper_file
chmod -f 751 $wrapper_file
cp /etc/php5/cgi/php.ini $phpini_file
chown $user:$user $phpini_file
chmod -f 751 $phpini_file
exit 0
Disclaimer: Not a programmer feel free to fix code