Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

(SOLVED) Template phpcgi not working - Hack included to Automate php.ini to cgi-bin

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Post Reply
  • Print view
Advanced search
1 post • Page 1 of 1
rasheid
Posts: 7
Joined: Wed Dec 16, 2015 4:51 am

(SOLVED) Template phpcgi not working - Hack included to Automate php.ini to cgi-bin
  • Quote

Post by rasheid » Wed Dec 16, 2015 5:45 am

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:
The requested URL /cgi-bin/info.php was not found on this server.
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.

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
To:

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
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
Top


Post Reply
  • Print view
1 post • Page 1 of 1

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password