View Single Post
  #15  
Old 18th January 2009, 14:41
Melchior Melchior is offline
Junior Member
 
Join Date: Jul 2007
Location: Germany, Darmstadt
Posts: 25
Thanks: 5
Thanked 1 Time in 1 Post
Default

Hi,

for all those preferring to use FastCgi I want to supply my little tweaked version of this great post (thx Tosser).

Also if you've got problems to execute the outdated patch this could help you.

The following instructions are only about patching ISPConfig to support FastCgi.

I added

- support that every Vhost will automatically gets copied his own php.ini file into webroot directory.
- new var directory to Vhost that contains sessions and uploaded_tmp files

Please note:

- use on own risk
- only apache2 support (you can easily add apache1)
- only FASTCGI-Support (can't be switched)
- You've to controll the config.lib.php and make your custom changes (CHOWN: Webserver-User, CHMOD: your rights!)
- If you want to regenerate the .php.ini // .php-fcgi-starter // var folder - just delete them and run a vhost change.


here we go:

1. open config.lib.php

2. find "if($web["web_php"]){"

3. delete this complete if condition including bracket content { ... }

4. and inner in this exact place this:
Code:
   // FIXED TO SUPPORT FASTCGI
    if($web["web_php"]){
    	$php = '';
        $php = "ScriptAlias /php/ ".$mod->system->server_conf["server_path_httpd_root"]."/"."web".$web["doc_id"]."/\n";
    
     	$fcgip = $mod->system->server_conf["server_path_httpd_root"]."/"."web".$web["doc_id"];
     	
     	// COPY /var/www/webX/.php-fcgi-starter AND fill in right webId
     	$fgiFile = $fcgip."/.php-fcgi-starter";
		if(!file_exists($fgiFile)) {
			exec("cp -p /root/ispconfig/scripts/php-fcgi-starter $fgiFile && chown root:root $fgiFile");
			$contentCgiFile = $mod->file->rf($fgiFile);
      		$contentCgiFile = str_replace("{WEB_ID}", "web".$web["doc_id"], $contentCgiFile);
    		$mod->file->wf($fgiFile, $contentCgiFile);
		}
		
		// COPY /etc/php5/ispconfig_fastcgi_default/php.ini TO /var/www/webX/.php.ini AND fill in right webId
		$phpIniFile = $fcgip."/.php.ini";
		if(!file_exists($phpIniFile)) {
			exec("cp -p /etc/php5/ispconfig_fastcgi_default/php.ini $phpIniFile && chown root:root $phpIniFile");
			$contentPhpIniFile = $mod->file->rf($phpIniFile);
      		$contentPhpIniFile = str_replace("{WEB_ID}", "web".$web["doc_id"], $contentPhpIniFile);
    		$mod->file->wf($phpIniFile, $contentPhpIniFile);
		}
		
    	if(!is_dir("$fcgip/var/uploads_tmp")) {
			exec("mkdir -p $fcgip/var/uploads_tmp");
		}
		
    	if(!is_dir("$fcgip/var/sessions")) {
			exec("mkdir -p $fcgip/var/sessions");
		}
		
		exec("chown -R webserv:web".$web["doc_id"]." $fcgip/var");
		exec("chmod -R 775 $fcgip/var");
		
		// "/var/www/{WEB_ID}/var/uploads_tmp/"
		// var/www/{WEB_ID}/var/sessions"
		
    	if($go_info["server"]["apache2_php"] == 'addtype' or $go_info["server"]["apache2_php"] == 'both') {
			$php .= "AddType application/x-httpd-php .php .php3 .php4 .php5\n";
		}
    } else {
      $php = "";
    }
5. in /root/ispconfig/scripts/ create or replace php-fcgi-starter with chmod 755 (!) this (new) content

#!/bin/sh
PHPRC="/var/www/{WEB_ID}/.php.ini"
export PHPRC
PHP_FCGI_CHILDREN=1
export PHP_FCGI_CHILDREN
exec /usr/lib/cgi-bin/php5


6. create /etc/php5/ispconfig_fastcgi_default and place in here php.ini with this sample config (if you want)
Code:
;;;;;;;;;;;;;;;;;;; PHP INI FOR {WEB_ID} ;;;;;;;;;;;;;;;;;;;

error_reporting = E_ALL & ~E_NOTICE
display_errors = On
display_startup_errors = On
log_errors = On
log_errors_max_len = 1024
error_log = /var/www/{WEB_ID}/log/phperrors.log

ignore_repeated_errors = Off
ignore_repeated_source = Off

report_memleaks = On

register_globals = Off
register_long_arrays = On
magic_quotes_gpc = Off
magic_quotes_runtime = Off

default_mimetype = "text/html"
default_charset = "utf-8"

post_max_size = 50M
file_uploads = On
upload_tmp_dir = "/var/www/{WEB_ID}/var/uploads_tmp/"
upload_max_filesize = 60M
max_execution_time = 600    ; Maximum execution time of each script, in seconds (30)
max_input_time = 600		; Maximum amount of time each script may spend parsing request data (60)
memory_limit = 60M      	; Maximum amount of memory a script may consume (8MB)

session.auto_start 0
session.save_path = "/var/www/{WEB_ID}/var/sessions"
session.use_cookies = 1
session.name = PHPSESSID_{WEB_ID}
session.cookie_lifetime = 0


;;;;;;;;;;;;;;;;;;; APPENDIX, SELECT IF WANTED ;;;;;;;;;;;;;;;;;;;

;error_log = filename
;error_log = syslog

;date.timezone = 
;iconv.input_encoding = "utf-8"
;iconv.internal_encoding = "utf-8"
;iconv.output_encoding = "utf-8"

; NOT WORKING WITH FASTCGI AFAIK
;session.gc_maxlifetime = 5
;session.gc_probability = 1
;session.gc_divisor = 1000

;session.cookie_path = /
;session.cookie_domain =
;session.cache_limiter = nocache
;session.cache_expire = 180
;safe_mode = Off
;safe_mode_gid = Off
;safe_mode_include_dir =
;safe_mode_exec_dir =
;safe_mode_allowed_env_vars = PHP_
;safe_mode_protected_env_vars = LD_LIBRARY_PATH
;open_basedir =

;extension=apc.so
;apc.mode = on
;apc.rfc1867 = on
;apc.max_file_size = 128M
;apc.enabled=1
;apc.shm_segments=1
;apc.shm_size=128
;apc.ttl=7200
;apc.user_ttl=7200
;apc.num_files_hint=1024
;apc.mmap_file_mask=/tmp/apc.XXXXXX
;apc.enable_cli=1
Done.


Hope it works for you!

regards,
Melchior

Last edited by Melchior; 18th January 2009 at 14:45.
Reply With Quote