When I deploy php application on apache, some problem come out, and solved. Here's the tips and problems solved.
0.How could I deploy an apache server armed with php, mysql, perl, and phpMyAdmin on the fly?
You need a package bundled with all these tools, xampp shall meet you needs, you can download it here
(windows/mac/linux/Solaris supported):
http://sourceforge.net/projects/xampp/files/
1. I meet the php page error:
strftime() [function.strftime]: It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier.
You can
explicitly set it in any of the following ways:
a.The date.timezone setting in php.ini
b.At runtime with date_default_timezone_set()
c. Setting the TZ variable in Apache's environment (in
httpd.conf, .htaccess, or a few other ways) ......
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte[] desKey;
public DES(String desKey) {
this.desKey = desKey.getBytes();
}
public byte[] desEncrypt(byte[] plainText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key, sr);
byte data[] = plainText;
byte encryptedData[] = cipher.doFinal(data);
return encryptedData;
}
public byte[] desDecrypt(byte[] encryptText) throws Exception {
SecureRandom sr = new SecureRandom();
byte ra ......
import java.io.IOException;
import java.security.SecureRandom;
import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.SecretKeyFactory;
import javax.crypto.spec.DESKeySpec;
import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;
public class DES {
private byte[] desKey;
public DES(String desKey) {
this.desKey = desKey.getBytes();
}
public byte[] desEncrypt(byte[] plainText) throws Exception {
SecureRandom sr = new SecureRandom();
byte rawKeyData[] = desKey;
DESKeySpec dks = new DESKeySpec(rawKeyData);
SecretKeyFactory keyFactory = SecretKeyFactory.getInstance("DES");
SecretKey key = keyFactory.generateSecret(dks);
Cipher cipher = Cipher.getInstance("DES");
cipher.init(Cipher.ENCRYPT_MODE, key, sr);
byte data[] = plainText;
byte encryptedData[] = cipher.doFinal(data);
return encryptedData;
}
public byte[] desDecrypt(byte[] encryptText) throws Exception {
SecureRandom sr = new SecureRandom();
byte ra ......
1.»ù±¾Àà
//smarty_config.php
<?php
define('TEMPLATE_DIR','templates/');
define('COMPILE_DIR','templates_c/');
define('CONFIG_DIR','configs/');
define('CACHE_DIR','cache/');
?>
//View.class.php
<?php
//ÅäÖÃÎļþ
require_once 'configs/smart_config.php';
//SmartyÀà
require('smarty/Smarty.class.php');
class View extends Smarty {
function SmartyFactory() {
$this->Smarty();
//Ä£°å·¾¶
$this->template_dir = TEMPLATE_DIR;
//±àÒëºóÎļþ
$this->compile_dir = COMPILE_DIR;
//ÅäÖÃÎļþ
$this->config_dir = CONFIG_DIR;
//»º´æÎļþ
$this->cache_dir = CACHE_DIR;
$this->debugging = true;
}
//ÖØÐ·â×°display ¸öÈËϰ¹ß¸Ä³Éshow
function show($name,$cacheId='') {
if($cacheId == '')
$this->display($name.'.htm');
else
$this->display($name.'.htm',$cacheId);
}
//ÖØÐ·â×°assign ϰ¹ßÓÃadd
function add($name,$value) {
$this->assign($name,$value);
}
}
?>
»ù±¾Ä¿Â¼Èç:
test
|-conf ......
ÎÒʹÓÃWAMP5 version 1.7.4°²×°PHP+Apache+MySQL¼¯³É»·¾³£¬ÔÚµ÷ÊÔÒ»¸ö³ÌÐòʱ£¬ÆäÑéÖ¤Âë²»ÄÜÏÔʾ£¬ÊÔÁ˺öà´Î£¬ÐÞ¸ÄÁËºÜ¶àµØ·½Ò²Ã»Äܳɹ¦¡£ÒÑ×öºÃµÄÅäÖÃÈçÏ£º
¢ÙÔÚphpinfÒ³ÃæLoaded Configuration FileºóÃæËùÖ¸¶¨µÄphp.iniÖаÑ;extension=php_gd2.dllÇ°ÃæµÄ;È¥µô¡£
¢ÚÖØÆôÁËApache·þÎñÆ÷¡£
Âé·³¸÷λָµãһϡ£Ð»Ð»~ ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/01/25/29/
ѧϰÁËÒ»¶Îʱ¼äPHP£¬¾õµÃÓеãÊÕ»ñ¡£Ò²Ó¦¸Ã½«Ñ§¹ýµÄ¶«Î÷ÄóöÀ´É¹É¹ÁË£¬²»È»¾Í½»»Ø¸ø¿Î±¾ÁË¡£
PHPÊÇÊ²Ã´ÄØ£¿
PHP£¬Êdz¬¼¶Îı¾Ô¤´¦ÀíÓïÑÔ£¨PHP:Hypertext Preprocessor£©µÄËõд¡£PHP ÊÇÒ»ÖÖ HTML ÄÚǶʽµÄÓïÑÔ£¬ÊÇÒ»ÖÖÔÚ·þÎñÆ÷¶ËÖ´ÐеÄǶÈëHTMLÎĵµµÄ½Å±¾ÓïÑÔ£¬ÓïÑԵķç¸ñÓеãÀàËÆÓÚCÓïÑÔ£¬ÏÖÔÚ±»ºÜ¶àµÄÍøÕ¾±à³ÌÈËÔ±¹ã·ºµÄÔËÓá£
PHP ¶ÀÌØµÄÓï·¨»ìºÏÁË C¡¢Java¡¢Perl ÒÔ¼° PHP ×Ô´´ÐµÄÓï·¨¡£Ëü¿ÉÒÔ±È CGI »òÕß Perl ¸ü¿ìËÙµÄÖ´Ðж¯Ì¬ÍøÒ³¡£ÓÃPHP×ö³öµÄ¶¯Ì¬Ò³ÃæÓëÆäËûµÄ±à³ÌÓïÑÔÏà±È£¬PHPÊǽ«³ÌÐòǶÈëµ½HTMLÎĵµÖÐÈ¥Ö´ÐУ¬Ö´ÐÐЧÂʱÈÍêÈ«Éú³ÉHTML±ê¼ÇµÄCGIÒª¸ßÐí¶à£»ÓëͬÑùÊÇǶÈëHTMLÎĵµµÄ½Å±¾ÓïÑÔJavaScriptÏà±È£¬PHPÔÚ·þÎñÆ÷¶ËÖ´ÐУ¬³ä·ÖÀûÓÃÁË·þÎñÆ÷µÄÐÔÄÜ£»PHPÖ´ÐÐÒýÇæ»¹»á½«Óû§¾³£·ÃÎʵÄPHP³ÌÐòפÁôÔÚÄÚ´æÖУ¬ÆäËûÓû§ÔÙÒ»´Î·ÃÎÊÕâ¸ö³ÌÐòʱ¾Í²»ÐèÒªÖØÐ±àÒë³ÌÐòÁË£¬Ö»ÒªÖ±½ÓÖ´ÐÐÄÚ´æÖеĴúÂë¾Í¿ÉÒÔÁË£¬ÕâÒ²ÊÇPHP¸ßЧÂʵÄÌåÏÖÖ®Ò»¡£PHP¾ßÓзdz£Ç¿´óµÄ¹¦ÄÜ£¬ËùÓеÄCGI»òÕßJavaScriptµÄ¹¦ÄÜPHP¶¼ÄÜʵÏÖ£¬¶øÇÒÖ§³Ö¼¸ºõËùÓÐÁ÷ÐеÄÊý¾Ý¿âÒÔ¼°²Ù×÷ϵͳ¡£
PHP×î³õÊÇ1994ÄêRasmus Lerdorf´´½¨µÄ£¬¸Õ¸Õ¿ªÊ¼Ö»ÊÇÒ»¸ö¼ ......
ÔÎÄÁ´½Ó£ºhttp://www.phpdo.net/index.php/2010/01/26/1-2/
ËùÓбà³ÌÓïÑԵĿªÊ¼:Hello,world!Ò³Ãæ¡£
Ê×ÏÈʹÓÃhtml±àдһ¸ö¼òµ¥µÄÒ³Ãæ¡£´úÂëÈçÏ£º
<html>
<head>
<title>Hello, world</title>
</head>
<body>
<H1><p align=center>Hello, world</p></H1>
<?php?>
</body>
</html>
ÔÚhtmlÖÐǶÈëPHP´úÂëµÄ·½·¨ÊÇʹÓÃ<?php···?>½«PHPǶÈëµ½HTMLÖС£
PHPÖеÄ×¢ÊÍ
1¡¢ ʹÓÃ˫бÏß“//···”×¢ÊÍ¡£Ë«Ð±ÏßÒÔºóÖªµÀÐеĽáβ¶¼ÊÇ×¢ÊÍÓï¾ä¡£
2¡¢ ʹÓþ®×ֺœ#···”×¢ÊÍ¡£¾®×ÖºÅÒÔºóÖªµÀÐеĽᶼÊÇ×¢ÊÍÓï¾ä¡£
3¡¢ ʹÓÓ”,Á½¸ö±êʾ·ûÖ®¼äµÄÄÚÈݶ¼ÊÇ×¢ÊÍ£¬ÕâÖÖ×¢ÊÍ·½·¨Ö§³Ö¶àÐÐ×¢ÊÍ¡£
×¢Ò⣺µÚÈýÖÖ×¢ÊͲ»ÔÊÐíǶÌס£
PHPÖеÄÊä³öÓï¾ä
·   ......