Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

Ubuntu 9.04 server°²×°nginx+php(fastcgi)

 
×¼±¸ÖªÊ¶£º
Ubuntu  :
 Ubuntu ÊÇlinuxµÄÒ»¸ö°æ±¾£¬ÓзÇÖÞ·¢²¼µÄ£¬ÏÖÔڱȽÏÁ÷ÐеÄÒ»¸ö°æ±¾¡£
²Î¿¼°Ù¶È˵Ã÷Ubuntu
nginx ¡¡£º
Nginx ("engine x") ÊÇÒ»¸ö¸ßÐÔÄÜµÄ HTTP ºÍ ·´Ïò´úÀí ·þÎñÆ÷£¬Ò²ÊÇÒ»¸ö IMAP/POP3/SMTP ´úÀí·þÎñÆ÷¡£ Nginx ÊÇÓÉ Igor Sysoev Ϊ¶íÂÞ˹·ÃÎÊÁ¿µÚ¶þµÄ Rambler.ru Õ¾µã¿ª·¢µÄ£¬ËüÒѾ­ÔÚ¸ÃÕ¾µãÔËÐг¬¹ýÁ½Äê°ëÁË¡£Igor ½«Ô´´úÂëÒÔÀàBSDÐí¿ÉÖ¤µÄÐÎʽ·¢²¼¡£¾¡¹Ü»¹ÊDzâÊ԰棬µ«ÊÇ£¬Nginx ÒѾ­ÒòΪËüµÄÎȶ¨ÐÔ¡¢·á¸»µÄ¹¦Äܼ¯¡¢Ê¾ÀýÅäÖÃÎļþºÍµÍϵͳ×ÊÔ´µÄÏûºÄ¶øÎÅÃûÁË¡£
Nginx µÄÖÐÎÄά»ù£ºhttp://wiki.codemongers.com/NginxChs ¡¡
Nginx µÄÖÐÎÄÕ¾£º http://www.nginx.cn
²Î¿¼ °Ù¶È°Ù¿Æ½âÊÍNGINX
 
FastCGI:
¸öÈ˳õ²½¸Ð¾õÊÇCGIµÄÏȽø²úÎ¾Ý˵ËٶȱÈCGI¿ìÎ屶¡£
ºÃÁË£¬ÏÖÔÚÀ´°²×°£º
µÚÒ»²½£¬°²×°nginx
 ÓÉÓÚUbuntu 904ÒѾ­°üº¬ÁËnginx£¬ËùÒÔ¸ù±¾²»Òª±àÒ룬°²×°³¬¼òµ¥£¡
ÐÞ¸Ä/etc/apt/sources.listÎļþÄÚÈÝΪ¹úÄÚ¾µÏñ£¬È»ºóÔËÐУº
apt-get update
apt-get install nginx
¼´¿ÉÍê³É°²×°
Æô¶¯nginx£º
/etc/init.d/nginx start
È»ºó¾Í¿ÉÒÔ·ÃÎÊÁË£¬http://localhost/ £¬ Ò»ÇÐÕý³££¡Èç¹û²»ÄÜ·ÃÎÊ£¬ÏȲ»Òª¼ÌÐø£¬¿´¿´ÊÇʲôԭÒò£¬½â¾öÖ®ºóÔÙ¼ÌÐø¡£
ÏÂÃæÅäÖÃphp ºÍmysql¡£
µÚ¶þ²½£¬°²×°PhpºÍmysql
°²×°phpºÍMySQL:
apt-get install php5-cli php5-cgi mysql-server-5.1 php5-mysql
µÚÈý²½£¬°²×°FastCgiºÍÅäÖÃ
ÎÒÃÇÐèÒª/usr/bin/spawn-fcgiÕâ¸öÎļþ£¬¶øËüÊÇÊôÓÚlighttpdÕâ¸ö°üÀïÃæµÄ£¬ËùÒÔÎÒÃÇ°²×°lighttpdÈ»ºó°ÑËüÉèÖÃΪ¿ª»ú²»Æô¶¯£º
apt-get install lighttpd #ÎÒÃÇÖ»Òª/usr/bin/spawn-fcgi
rcconf #È¥µôlighttpd¿ª»ú×ÔÆô¶¯
ÐÞ¸ÄnginxµÄÅäÖÃÎļþ£º/etc/nginx/sites-available/default
ÐÞ¸Ä server_name 58.30.17.154;
ÐÞ¸ÄindexµÄÒ»ÐÐÐÞ¸ÄΪ£º
index index.php index.html index.htm;
È¥µôÏÂÃ沿·ÖµÄ×¢ÊÍ£º
location ~ \.php$ {
fastcgi _pass   127.0.0.1:9000;
fastcgi_index  index.php;
fastcgi_param  SCRIPT_FILENAME /var/www/nginx-default $fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
 Ìرð×¢ÒâÉÏÃæºìÉ«µÄ×Ö¡£
ÖØÐÂÆô¶¯nginx:
/etc/init.d/nginx stop
/etc/init.d/nginx start
Æô¶¯fastcgi php:
spawn-fcgi -a 127.0.0.1 -p 9000 -C 10 -u www-data -f /usr/bin/php-cgi
ΪÁËÈÃphp-c


Ïà¹ØÎĵµ£º

¹ØÓÚphpÀïµÄinclude

 ÔÚÒÔÇ°µÄ×öµÄÀý×ÓÖÐÓöµ½¹ýÖظ´µÄ¼ÓÔصĴíÎó ¶î ÄǸöÊÇͨ¹ýinclude_once()À´½â¾ö »òÕß²»ÈÃËûÖظ´¼ÓÔØ°ÑÖظ´µÄinclude()È¥µôÒ»¸ö»ò¶à¸ö£¬×îÖÕֻʣÏÂÒ»¸öÕâÑùÎÊÌâ¾Í½â¾öÁË£¬µ«½ñÌìÓöµ½µÄÎÊÌâ¾Í¼¬ÊÖÁË ËµÊÇÕÒ²»µ½Îļþ¡£
     ÊÂÇéÊÇÕâÑùµÄ £¬½ñÌìÔÚÎļþ¼ÐÀïÔÙн¨ÁËÒ»¸öÎļþ¼Ð£¬È»ºóÒÔÇ°includ ......

PHPÖÐmysql_fetch_array()ºÍmysql_fetch_row()µÄÇø±ð

 ×î½üÔÚ×öPHPÓëÊý¾Ý¿â½»»¥µÄproject£¬¼±ÓÚÇó³É£¬Ä£·ÂÁËÏÂÀý×ӾͿªÊ¼¶¯ÊÖ£¬½á¹ûÎó°Ñmysql_fetch_arrayд³ÉÁËmysql_fetch_row,囧ÊÂÀ´ÁË£¬·¢ÏÖ·µ»ØµÄÊý×é¾ÓÈ»ÊÇindex=>valueµÄÐÎʽ£¬¶øÃ÷Ã÷¼ÇµÃÊÇfield name=>valueµÄ¹þ£¬²éÊÖ²á²ÅÃ÷°×¡£
1. mysql_fetch_arrayµÄº¯ÊýÔ­ÐÍÊÇ
array mysql_fetch_array ( resour ......

ħÊÞÕù°ÔÖ®PHPÉè¼Æģʽ

 
Ç°ÑÔ£ºÎÒдµÄ¹ØÓÚÉè¼ÆģʽµÄһϵÁÐÎÄÕ¡£ÕâϵÁеÄÎÄÕÂÖ÷ÒªÕë¶Ôû½Ó´¥¹ýÉè¼ÆģʽµÄ£¬»òÕß˵½Ó´¥¹ýµ«»¹²»ÊǺÜÃ÷°×µÄPHPer¡£
ÎÊÌâµÄÌá³ö:
¿ÉÄܺܶàÈ˶¼Ð´¹ýÀ࣬Îļþ²Ù×÷µÄ£¬Êý¾Ý¿âµÄ……
¶ÔÓÚÊý¾Ý¿âµÄÀàÀ´ËµÓÐʱºò¿ÉÄܱ»ºöÂÔµÄÒ»¸öÎÊÌâÊÇ£ºÎÒÃÇ´´½¨ÀàµÄʵÀýʱһ°ã¶¼ÊÇͨ¹ý¹¹Ô캯ÊýÁ¬½ÓÁËÊý¾Ý¿â¡£Õâû´ ......

phpÓÅ»¯·½·¨

1.Èç¹ûÒ»¸ö·½·¨¿É¾²Ì¬»¯£¬¾Í¶ÔËü×ö¾²Ì¬ÉùÃ÷¡£ËÙÂÊ¿ÉÌáÉýÖÁ4±¶¡£
2.echo ±È print ¿ì¡£
3.ʹÓÃechoµÄ¶àÖزÎÊý£¨Òë×¢£ºÖ¸ÓöººÅ¶ø²»ÊǾäµã£©´úÌæ×Ö·û´®Á¬½Ó¡£
4.ÔÚÖ´ÐÐforÑ­»·Ö®Ç°È·¶¨×î´óÑ­»·Êý£¬²»ÒªÃ¿Ñ­»·Ò»´Î¶¼¼ÆËã×î´óÖµ¡£
5.×¢ÏúÄÇЩ²»ÓõıäÁ¿ÓÈÆäÊÇ´óÊý×飬ÒÔ±ãÊÍ·ÅÄÚ´æ¡£
6.¾¡Á¿±ÜÃâʹÓÃ__get£¬__set£¬__autolo ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ