ÔÚFedora 12Öа²×°Apache2+PHP5+MySQL£¨LAMP£©
1.
Ç°ÑÔ
ÎÒʹÓõÄÖ÷»úÃûΪserver1.example.com
£¬ip
µØÖ·ÊÇ192.168.0.100
¡£ÕâЩÉèÖÿÉÄÜÓëÄãÏëÒªµÄÓÐËù²»Í¬£¬ËùÒÔÄã±ØÐëÔÚÊʵ±µÄµØ·½ÐÞ¸Äһϡ£
2
°²×°MySQL5
ÓÃÏÂÁÐÃüÁî°²×°MySQL
£º
yum install mysql mysql-server
È»ºóÎÒÃÇΪMySQL
´´½¨ÏµÍ³Æô¶¯Á´½Ó£¨ÕâÑùµÄ»°£¬MySQL
¾Í»áËæ×ÅϵͳÆô¶¯¶øÆô¶¯£©£¬²¢Æô¶¯MySQL
·þÎñÆ÷£º
chkconfig --levels 235 mysqld on
/etc/init.d/mysqld start
ÔËÐÐ
mysqladmin -u root password yourrootsqlpassword
mysqladmin -h server1.example.com -u root password yourrootsqlpassword
À´Îªroot
Óû§ÉèÖÃÒ»¸öÃÜÂ루·ñÔòÈκÎÈ˶¼¿ÉÒÔ·ÃÎÊÄãµÄMySQL
Êý¾Ý¿â£¡£©
3
°²×°Apache2
Fedora
ĬÈÏÓÐApache2
Õâ¸ö°ü£¬ÎÒÃÇ¿ÉÒÔÓÃÏÂÁÐÃüÁî°²×°Ëü£º
yum install httpd
ÏÖÔÚÅäÖÃÏÂϵͳʹµÃApache
Äܹ»Ëæ×ÅϵͳÆô¶¯¶øÆô¶¯…
chkconfig --levels 235 httpd on
...
Æô¶¯Apache:
/etc/init.d/httpd start
ÏÖÔÚ´ò¿ªä¯ÀÀÆ÷£¬·ÃÎÊhttp://192.168.0.100
£¬Äã¾ÍÓ¦¸ÃÄÜ¿´µ½Apache2
µÄÔ¤ÁôÒ³ÁË£º
ÔÚFedora
ÖÐApache
µÄĬÈÏÎĵµÂ·¾¶ÔÚ/var/www/html
£¬ÅäÖÃÎļþÊÇ/etc/httpd/conf/httpd.conf
¡£ÆäÓàµÄÅäÖÃÎļþ´æ´¢ÔÚ/etc/httpd/conf.d/
¡£
4
°²×°PHP5
ÎÒÃÇÓÃÏÂÁÐÃüÁî°²×°PHP5
ºÍApache
PHP5
Ä£¿é£º
yum install php
È»ºóÎÒÃÇÆô¶¯ÏÂApache
£º
/etc/init.d/httpd restart
5
²âÊÔPHP5/
»ñÈ¡PHP5
°²×°ºóµÄÏêϸÐÅÏ¢
ÍøÕ¾µÄĬÈÏÎĵµÂ·¾¶ÊÇ/var/www/html
¡£ÎÒÃÇÏÖÔÚÔÚÕâ¸öÎļþ¼ÐÖд´½¨Ò»¸öСÐÍPHP(info.php)
Îļþ£¬²¢ÔÚ£»ä¯ÀÀÆ÷ÖзÃÎÊËü¡£Õâ¸öÎļþ»áÏÔʾ¹ØÓÚPHP
°²×°µÄ´óÁ¿µÄϸ½Ú£¬ÀýÈçPHP
µÄ°æ±¾¡£
vi /var/www/html/info.php
<?php
phpinfo();
?>
ÏÖÔÚÎÒÃÇÔÚä¯ÀÀÆ÷ÖзÃÎÊÕâ¸öÎļþ(
ÀýÈçhttp://192.168.0.100/info.php
)
£º
ÕýÈçÄãËù¿´µ½µÄÒ»Ñù£¬PHP5
ÒѾÕý³£¹¤×÷ÁË£¬²¢ÇÒÔÚServer
API
ÕâÒ»ÐÐÖÐÏÔʾµÄApache
ÊÇÒÔApache2.0
Handler
ģʽ¹¤×÷µÄ¡£Èç¹ûÄãÏòÏ·ҳ£¬Ä㽫»á¿´µ½ÒѾ°²×°ÁËPHP5
µÄËùÓеÄÄ£¿é¡£MySQL
ûÓÐÔÚÕâÀïÁгöÀ´£¬Ò²¾ÍÒâζ×ÅÄ¿Ç°PHP5
²¢²»Ö§³Ö
MySQL
¡£
6
ÈÃPHP5
Ö§³ÖMySQL
ÎÒÃÇ°²×°php-mysql
Õâ¸ö°ü¼È¿ÉÒÔʹMySQL
Ö§³Öphp
ÁË¡£ÔÚÕâÀï×îºÃÒ²°²×°ÆäËûµÄPHP5
Ä£¿é£¬ÕâЩģ¿éÒ²ÐíÄã»áÔÚÆäËûµÄÓ¦ÓÃÖÐÓõ½¡£Äã¿ÉÒÔʹÓÃÏÂÁÐÃ÷ÐÇÏÈËÑË÷Ò»ÏÂPHP5
µÄÄ£¿é£º
yum search php
Ñ¡È¡ÄãÐèÒªµÄÄ£¿é£¬²¢Ê¹ÓÃÏÂÁÐÃüÁî°²×°Ëü
Ïà¹ØÎĵµ£º
Õ¾µã½á¹¹
´úÂë:
Õ¾µã
©»includes
©»class.inc
©Çtemplet
©»index.htm
©Çlist.htm
©»content.htm
©Çindex.php
©»content.php
¿â½ ......
<?php
class Model_Data_FocusData{
....
public function getData(){...}
}
class Model_Data_IndexData{
....
public function getData(){...}
}
?>
ÓÐÕâô¼¸¸öÀ࣬ϣÍûÄܹ»×Ô¶¯µÄ¸ù¾Ý²ÎÊýÀ´µ÷Óò»Í¬µÄÀà´¦ÀíÊý¾Ý¡£
¿´µ÷ÓÃÄ£¿é£º
<?php
function getData($act){
$class = "Mode ......
php½Ì³Ì mysql½Ì³Ì_connect Óëmysql_pconnectº¯ÊýÓëʵÀý½Ì³Ì
mysql_connect
mysql_connect($this->root,$this->user,$this->pass)
/*
mysql_connect ,µ¥¸ö·´ÎÊÓû§²»»áƵ·±µÄµ÷ÓÃÊý¾Ý¿â½Ì³Ì£¬Ã»±ØÒª±£³ÖÁ¬½Ó£¬¶øÇÒmysqlµÄÁ¬½ÓÊýÒ²ÊÇÓÐÏÞÖƵģ¬ ʹÓà ¼°Ê±·ÃÎʱȽÏƵ·±£¬Ò²×îºÃʹÓÃmysql_connect£¬ÕâÑùÊ¹Ó ......
dir() º¯Êý´ò¿ªÒ»¸öĿ¼¾ä±ú£¬²¢·µ»ØÒ»¸ö¶ÔÏó¡£Õâ¸ö¶ÔÏó°üº¬Èý¸ö·½·¨£ºread() , rewind() ÒÔ¼° close()¡£
Èô³É¹¦£¬Ôò¸Ãº¯Êý·µ»ØÒ»¸öĿ¼Á÷£¬·ñÔò·µ»Ø false ÒÔ¼°Ò»¸ö error¡£¿ÉÒÔͨ¹ýÔÚº¯ÊýÃûÇ°¼ÓÉÏ "@" À´Òþ²Ø error µÄÊä³ö¡£
<?php
//´ò¿ª images Ŀ¼
$dir = dir("images");
//Áгö images Ŀ¼ÖеÄÎļþ
while ......