Originariamente inviato da andr3a
molto scomoda come situazione di produzione, ma e' gia' qualcosa per chi volesse installare php5 come modulo
[ qualcuno puo' fare un caffe' al Caccavella ???
]
ho installato php 5 e php 4 nel modo di guidoz , e proprio per evitare il problema che descrivi tu ho provato a fare uno script, un po idiota ma puo servire (almeno credo :stordita)
Codice PHP:
<?PHP
/*******************************
+-------------------------------
| script by frontmedia.it
+-------------------------------
********************************/
/* INFO UTILI */
/******************************************************************************************************************
* Per utilizzare questo script il safe_mode deve essere disabilitato.
* Per disattivare il safe mode:
* - aprire il file php.ini e cercare la riga: ; Safe Mode due righe piu sotto dovrebbe esserci: safe_mode = Off
* - Modificare safe_mode = Off in safe_mode = On
* - Eseguire la stessa operazione con i php.ini sia di PHP4 che PHP5
******************************************************************************************************************/
#[CONFIG]
// Root Apache Dir
$CONFIG['apache_conf_path'] = "C:/Programmi/Apache Group/Apache/";
// Config Apache Dir
$CONFIG['apache_conf_path'] = "C:/Programmi/Apache Group/Apache/conf/";
// Directory della cartella Windows (per il php.ini)
$CONFIG['phpini_conf_path'] = "C:/Windows/";
// > Nome per rinominare il config di php 4 (cartella di apache)
$CONFIG['apache_php4'] = "httpd4.conf";
// > Nome per rinominare il config di php 5 (cartella di apache)
$CONFIG['apache_php5'] = "httpd5.conf";
// > Nome per rinominare il php.ini per php 4 (cartella di windows)
$CONFIG['phpini_php4'] = "php4.ini";
// > Nome per rinominare il php.ini per php 5 (cartella di windows)
$CONFIG['phpini_php5'] = "php5.ini";
// > Nome originale del file di configurazione di apache
$CONFIG['apahce_conf'] = "httpd.conf";
// > Nome originale del php.ini
$CONFIG['phpini_conf'] = "php.ini";
#[FUNCTION]
// > Rename File
function php_swith ( )
{
global $CONFIG ;
$return = array ( ) ;
if ( file_exists ( $CONFIG['apache_conf_path'] . $CONFIG['apache_php4'] ) )
{
$return['convert_a'] = rename ( $CONFIG['apache_conf_path'] . $CONFIG['apahce_conf'] , $CONFIG['apache_conf_path'] . $CONFIG['apache_php5'] ) ;
$return['convert_b'] = rename ( $CONFIG['apache_conf_path'] . $CONFIG['apache_php4'] , $CONFIG['apache_conf_path'] . $CONFIG['apahce_conf'] ) ;
$return['phpconvert_a'] = rename ( $CONFIG['phpini_conf_path'] . $CONFIG['phpini_conf'] , $CONFIG['phpini_conf_path'] . $CONFIG['phpini_php5'] ) ;
$return['phpconvert_b'] = rename ( $CONFIG['phpini_conf_path'] . $CONFIG['phpini_php4'] , $CONFIG['phpini_conf_path'] . $CONFIG['phpini_conf'] ) ;
$return['new_php'] = 'php4';
} else if ( file_exists ( $CONFIG['apache_conf_path'] . $CONFIG['apache_php5'] ) )
{
$return['convert_a'] = rename ( $CONFIG['apache_conf_path'] . $CONFIG['apahce_conf'] , $CONFIG['apache_conf_path'] . $CONFIG['apache_php4'] ) ;
$return['convert_b'] = rename ( $CONFIG['apache_conf_path'] . $CONFIG['apache_php5'] , $CONFIG['apache_conf_path'] . $CONFIG['apahce_conf'] ) ;
$return['phpconvert_a'] = rename ( $CONFIG['phpini_conf_path'] . $CONFIG['phpini_conf'] , $CONFIG['phpini_conf_path'] . $CONFIG['phpini_php4'] ) ;
$return['phpconvert_b'] = rename ( $CONFIG['phpini_conf_path'] . $CONFIG['phpini_php5'] , $CONFIG['phpini_conf_path'] . $CONFIG['phpini_conf'] ) ;
$return['new_php'] = 'php5';
}else{
$return['error'] = "ERROR_404" ;
}
return $return;
}
// > Apache Restart
function apache_restart ( $apache_dir )
{
return exec("C:/Programmi/Apache Group/Apache/Apache.exe -k restart");
}
# [CONTROLLO]
$swt = php_swith ( ) ;
if ( $swt['error'] == "ERROR_404" )
{
die ( "I FILE SELEZIONATI NON ESISTONO ! " ) ;
}else
{
$return = "<span class='title'>Attivazione di ".$swt['new_php']."</span>
\n" ;
if ( $swt['convert_a'] == TRUE AND $swt['convert_b'] == TRUE )
{
$return .= "<span class='file_ok'>Rinominazione dei file di configurazione di Apache ... OK</span>
\n";
}else{
$return .= "<span class='failed'>Rinominazione dei file php.ini ... Fallita</span>
\n";
$error = TRUE;
}
if ( $swt['phpconvert_a'] == TRUE AND $swt['phpconvert_b'] == TRUE )
{
$return .= "<span class='file_ok'>Rinominazione dei file php.ini ... OK</span>
\n";
}else{
$return .= "<span class='failed'>Rinominazione dei file php.ini ... Fallita</span>
\n";
$error = TRUE;
}
if ( ! $error )
{
$return .= "<span class='apache_restart'>Restart di Apache ...</span>
\n" ;
echo apache_restart ( $CONFIG['apache_conf_path'] ) ;
}
}
$css = "<style type='text/css'>\n";
$css .= "body\n{\n";
$css .= "font-family: verdana,arial;\n";
$css .= "font-size: 12px;\n";
$css .= "}\n";
$css .= ".file_ok\n{\n";
$css .= " color: green;\n";
$css .= "}\n";
$css .= ".failed\n{\n";
$css .= " color: red;\n";
$css .= "}\n";
$css .= ".title\n{\n";
$css .= " color: black;\n";
$css .= " font-weight: bold;\n";
$css .= "}\n";
$css .= ".apache_restart\n{\n";
$css .= " color: darkblue;\n";
$css .= "}\n";
$css .= "</style>\n";
echo "<html>\n <head>\n <title>PHP Switch Version</title>\n".$css." </head>\n\n <body>\n".$return."\n </body>\n</html>";
?>
l'unico bug e che nn riesco a far resettare apahce