ºìÁªLinuxÃÅ»§
Linux°ïÖú
µ±Ç°Î»ÖÃ: ºìÁªLinuxÃÅ»§ > Debian

Debian·þÎñÆ÷ÉèÖÃÈëÃÅ

·¢²¼Ê±¼ä:2008-03-08 00:49:19À´Ô´:ºìÁª×÷Õß:Lhhba
1 Ñ¡ÔñApache+MySQL+PHP4
Äã¿ÉÄÜ»áÎÊÎÒ£ºÎªÊ²Ã´²»Ñ¡Ôñ±ðµÄÈí¼þ£¬¶ø·ÇµÃÑ¡ÔñApache+MySQL+PHP4µÄ×éºÏ£¿ºÇºÇ£¬ÎÒÒª¸æËßÄ㣬ÖøÃûµÄFree Lamp×éºÏ£¬ËµµÄ¾ÍÊÇLinux/Apache/MySQL/PHP/Perl/Python£¬Äã¿ÉÒÔµ½www.freelamp.comÉÏÃæÈ¥¿´¿´¡£PHPÔÚ»¥ÁªÍøÉϵÄÓ¦Óã¬Õý³ÉÁÇÔ­Ö®ÊÆ¡£Èç¹û×÷Web¿ª·¢£¬ÔÚÎÒ¿´À´£¬±ðÎÞÑ¡Ôñ£¬¾ÍÊÇPHP¡£ÏêϸÇé¿ö¿ÉÒÔµ½www.php.netÉÏÃæÈ¥Á˽⡣MySQL·Ç³£Çá±ã£¬ÐÔÄÜ׿Խ¡£Apache¾Í²»±Ø¶à˵ÁË£¬»¥ÁªÍøÉÏûÓм¸¸öWebÕ¾µã²»ÓÃËü¡£

2 °²×°

ÔÚDebianÉÏ°²×°Èí¼þ£¬ÕæµÄÊǷdz£¼òµ¥¡£²»ÐèÒªconfigure£¬²»ÓÃmake£¬²»ÓÃmake install£¬±é²¼È«ÇòµÄDebianµÄ¹¤×÷ÈËÔ±ÒѾ­ÎªÄã×öºÃÁËÒ»ÇС£

Äã¿ÉÒÔÒ»¿ÚÆø°ÑÕâЩÈí¼þÈ«²¿×°ÉÏ£º

# apt-get install apache php4 php4-gd php4-mysql mysql-server mysql-client

ÆäÖУ¬php-gdÊÇÒ»¸ö·Ç³£°ôµÄͼÐο⣬Èç¹ûÄã²»ÐèҪʹÓÃphpÉú³É¶¯Ì¬Í¼Æ¬£¬¾Í²»ÓÃ×°¡£

Õâʱ£¬ÏµÍ³»á×Ô¶¯ÁгöһЩÏà¹ØµÄÈí¼þ£¬È»ºóÎÊÄãÊDz»ÊÇÒª¼ÌÐø£¨ËµDebian°ô£¬ÕâÊÇÆäÖÐÒ»µã£º×Ô¶¯²éÕÒÈí¼þ¹ØÁª£¬×Ô¶¯²¹³ä°²×°£©----Debian¸øÄãÒ»´Î·´»ÚµÄ»ú»á£¬Èç¹ûÄãÏÖÔÚ²»Ïë×°ÁË£¬ÄÇô°´n£¬¾ÍÍ˳öÀ´ÁË¡£

µ±È»ÎÒÃÇÔÚÕâÀïÒª°´»Ø³µ£¬¼ÌÐø°²×°¡£ÏÖÔÚDebian»áµ½ÄãµÄsources.listÀïÃæÖ¸¶¨µÄÕ¾µãÈ¥ÏÂÔØÕâЩÈí¼þ¡£ÏÂÔØÍêºó£¬»á×Ô¶¯½øÐÐÅäÖã¬ÅäÖùý³ÌÖлáÕ÷ÇóÄãµÄÒâ¼û£¬ÎÊÄ㼸¸öÎÊÌâ¡£

±ÈÈçÏÖÔÚËû¾ÍÎÊÄ㣺ÄãÒªÔÚ¼ÆËã»úÆô¶¯Ê±¾ÍÔËÐÐMySQLÂ𣿵±È»Ñ¡YesÁË£¬·ñÔòÿ´ÎÒªÓõÄʱºò²ÅÆô¶¯£¬¹ÖÂé·³µÄ¡£

ÓÖÎÊÄ㣺ÄãÏëÔËÐÐapacheconfig½Å±¾Âð£¿Ä¬ÈÏÊÇN£¬²»¹ýÎÒÃÇÊäÈëYÈÃËüÌæÎÒÃÇÅäÖÃһϡ£ÅäÖÃÍêºó£¬ÎÊÄãÊÇ·ñ±£´æÅäÖ㬵±È»ÊÇÁË£¬ºÇºÇ¡£È»ºó£¬Ëû»áÎÊÄãÊÇ·ñÒªÆô¶¯Apache£¬ºÃ£¬Æô¶¯Ëü¡£

½Ó×Å£¬ÏµÍ³»á×Ô¶¯ÅäÖÃPHP¡£ÓÉÓÚÄãÑ¡ÔñÁËphp-gdºÍphp-mysql£¬Ëû»áÎÊÄãÊÇ·ñ°Ñgd.soºÍmysql.soµÄÖ§³ÖдÈëphp.ini£¬»Ø´ðÊÇ¡£Äã¿´£¬Debian´ÏÃ÷°É¡£

3 ÅäÖÃ

3.1 ÅäÖÃApache

3.1.1 ÌṩphpÖ§³Ö

Apache¸Õ×°ÉϵÄʱºò²»ÌṩphpÖ§³Ö¡£µ±Äãµã»÷ÓÐ.php½Å±¾µÄÁ¬½Ó£¬ä¯ÀÀÆ÷»áÏÂÔØÕâ¸ö½Å±¾:-(

ÐÞ¸Ä/etc/apache/httpd.conf£¬ÒÔ±ãÌṩphpÖ§³Ö¡£ÔËÐУº

#nano /etc/apache/httpd.conf

˳±ãÌáһϣ¬Îҷdz£Ï²»¶Õâ¸ö½Ð×önanoµÄ±à¼­Æ÷£¬ËüºÜÈÝÒ×ÉÏÊÖ¡£

ʹÓÃnanoµÄctrl+w¹¦ÄÜÕÒµ½ÏÂÃæÕâÒ»ÐУº

# LoadModule php4_module /usr/lib/apache/1.3/libphp4.so

°ÑÕâÒ»ÐÐÇ°ÃæµÄ¾®ºÅÈ¥µô£¬ÒÔ±ãapache¼ÓÔØÕâ¸ölibphp4.soÄ£¿é¡£

È»ºó£¬ÅäÖÃĬÈÏÒ³£¬ÕÒµ½£º

DirectoryIndex index.html index.htm index.shtml index.cgi

¸Ä³É£º

DirectoryIndex index.php index.php3
¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡ index.html index.htm index.shtml index.cgi

È»ºóÔÙ¼ÓÉÏ.php3À©Õ¹ÃûµÄÖ§³ÖºÍphpÔ´ÂëÖ§³Ö£¬ÕÒµ½£º

#
# And for PHP 4.x, use:
#
#AddType application/x-httpd-php .php
#AddType application/x-httpd-php-source .phps

°ÑºóÃæÁ½ÐÐÐ޸ijɣº

#
# And for PHP 4.x, use:
#
AddType application/x-httpd-php .php .php3
AddType application/x-httpd-php-source .phps

3.1.2 ÐÞ¸ÄĬÈÏ×Ö·û¼¯

ÈÃApache°Ñ¼òÌåÖÐÎÄ×÷ΪĬÈϵÄ×Ö·û¼¯¡£ÕÒµ½ÕâÒ»ÐУº

AddDefaultCharset on

Ð޸ijɣº

AddDefaultCharset gb2312

ºÃ£¬Apache¾ÍÅäÖÃÍêÁË£¬°´ctrl+o±£´æºó£¬ÔÙ°´ctrl+xÍ˳önano¡£

ΪÁËʹÎÒÃǵÄÐÞ¸ÄÉúЧ£¬ÐèÒªÖØÐÂÆô¶¯Apache£¬ÔËÐУº

#apachectl restart

apache 1.3 ÌṩÁËÕâ¸öapachectl¹¤¾ß£¬µ«ÊÇ2.0¾ÍûÁË¡£

ÁíÍ⣬עÒâÒ»¸ö¼¼ÇÉ£ºDebianÌṩµÄ·þÎñÆ÷Èí¼þ°ü£¬¼¸ºõ¶¼»áÌṩһ¸ö½Å±¾ÓÃÓÚÆô¶¯/ÖÕÖ¹/ÖØÐÂÆô¶¯Õâ¸ö·þÎñ¡£½Å±¾È«²¿·ÅÔÚ/etc/init.d/ÏÂÃæ¡£

±ÈÈçApache£¬¿ÉÒÔͨ¹ýÏÂÃæµÄÃüÁî¿ØÖÆ£º

#/etc/init.d/apache restart

ÆäËüµÄ·þÎñÒ²¿ÉÒÔÈç´Ë²Ù×÷¡£

3.2 MySQLÅäÖÃ

3.2.1 ÐÞ¸ÄMySQLµÄ¿ÚÁî

ÓÉÓÚMySQLĬÈÏûÓпÚÁΪÁË°²È«Æð¼û£¬Ò»¶¨ÒªÐÞ¸ÄÄãµÄ¿ÚÁ

ÏÈÀ´¿´¿´ÄãµÄmysqlÊDz»ÊÇÕæµÄûÓпÚÁ

$mysqladmin version

Èç¹ûÄãÄܹ»¿´µ½mysqlµÄ°æ±¾ÐÅÏ¢£¬Ö¤Ã÷Ä¿Ç°MySQLûÓпÚÁî¡£

ºÃ£¬ÔËÐÐmysqladmin password xxxxxx Ð޸ĿÚÁî:

#mysqladmin password xxxxxx

ÕâÀïxxxxxxÊÇÄãµÄпÚÁî¡£

ÏÖÔÚÄãÐèÒªÔËÐÐ mysqladmin version --user=root --pass,È»ºóÊäÈë¿ÚÁ²ÅÄܲ鿴°æ±¾ºÅµÈÐÅÏ¢¡£

×¢Ò⣬ÉÏÃæÃüÁîÖеÄ--user=root --passÕâÒ»²¿·Ö£¬¿ÉÒÔ¼òдΪ-u root -p¡£ÎÒÃÇÀ´²âÊÔһϣ¬¿´¿ÚÁîÊÇ·ñÉúЧ£º

#mysqladmin version -u root -p
Enter password:

3.2.2 ´ò¿ª3306¶Ë¿Ú¼àÌý

ÕâÏ×÷ÒªÉ÷ÖØ¡£´¦ÓÚ°²È«¿¼ÂÇ£¬Ä¬ÈÏÇé¿öÏ£¬Debian°Ñ3306¶Ë¿Ú¹Ø±ÕÁË¡£ÒòΪ£¬²»ÉÙºÚ¿Íͨ¹ýËüÀ´¹¥»÷ÄãµÄϵͳ¡£Èç¹ûÄ㲻ͨ¹ýÆäËû»úÆ÷À´´æÈ¡Êý¾Ý¿â£¬ÄÇô²»Òª´ò¿ªÕâ¸ö¶Ë¿Ú¡£

ÐÞ¸Ä/etc/mysql/my.cnf£¬ÕÒµ½£º

skip-networking

°ÑËü×¢Ê͵ô£º

# skip-networking

3.2.3 ÐÞ¸ÄĬÈÏ×Ö·û¼¯

ÈÃMySQL°Ñ¼òÌåÖÐÎÄ×÷ΪĬÈϵÄ×Ö·û¼¯¡£±à¼­/etc/init.d/mysql£¬ÕÒµ½ÕâÒ»ÐУº

/usr/bin/safe_mysqld > /dev/null 2>&1 &

¸Ä³É£º

/usr/bin/safe_mysqld > --default-character-set=gb2312 > /dev/null 2>&1 &

ºÃ£¬ÖØÐÂÆô¶¯MySQL:

#/etc/init.d/mysql restart

3.3 PHPÅäÖÃ

Ö÷ÒªÊÇÒªÐÞ¸ÄphpµÄĬÈÏ×Ö·û¼¯£¬°ÑËü¸Ä³É¼òÌåÖÐÎÄ¡£±à¼­/etc/php4/apache/php.ini£º

#nano /etc/php4/apache/php.ini

ÕÒµ½ ;default_charset = "iso-8859-1"ÕâÒ»ÐУº

;default_charset = "iso-8859-1"

°ÑÇ°ÃæµÄ·ÖºÅÈ¥µô£¬²¢¸Ä³É£ºdefault_charset = "gb2312"

default_charset = "gb2312"

4 ×ۺϲâÊÔ

ºÃÁË£¬°²×°ÍêÁË£¬ÎÒÃÇÀ´²âÊÔһϡ£

ÕâÒ»²¿·Ö£¬¸ßÊÖÍêÈ«¿ÉÒÔÂÔ¹ý¡£ÎÒÖ÷Òª¿¼Âǵ½³õѧÕߣ¬²ÅдÁËÕâЩ¡£

4.1 ½¨Á¢Ò»¸öÊý¾Ý¿â

ÏÂÃæÎÒÃÇÀ´´´½¨Ò»¸ö¼òµ¥µÄÊý¾Ý¿â£¬Õâ¸ö¿âÀïÃæÖ»ÓÐÒ»ÕÅ±í£¬½Ð×öuser£¬ÓÃÀ´´æ·ÅÓû§Ãû/Ã÷ÎÄÃÜÂë/³öÉúÈÕÆÚ/¼¤»î״̬¡£


¡¡¡¡ $dbname='mytest';
$tablename='user';
$page=0;
$rowperpage=20;

mysql_connect("localhost", "root", "ÄúµÄÃÜÂë");

4.2 ²âÊÔ

°ÑÕâ¸ömytest.php¸´ÖƵ½/var/wwwÏÂÃ棬ÔÚÄãµÄä¯ÀÀÆ÷ÀïÃ棬·ÃÎÊÕâ¸ömytest.php£¬¾Í»á¿´µ½Êý¾Ý¿âµÄÄÚÈÝ¡£

Ö®ËùÒÔ°Ñmytest.php·Åµ½/var/wwwÏÂÃ棬ÊÇÒòΪ£¬Ä¬ÈÏÇé¿öÏ£¬ApacheµÄhttpd.confÀïÃ涨ÒåÁË°Ñ/var/www×÷ΪÎĵµ¸ùĿ¼¡£

³õѧÕß×¢Ò⣬ÔÚlinux¿ØÖÆ̨ÏÂÃæÓкü¸¿îä¯ÀÀÆ÷£¬w3c£¬lynx£¬linksµÈµÈ¡£Èý¸ö¸÷ÓÐÓÅÁÓ£¬¶¼²»ÍêÃÀ¡£¸öÈ˸оõlinks±È½ÏÊʺϳõѧÕߣ¬ÒòΪ°´ÏÂesc¼üÖ®ºóÓв˵¥³öÏÖ¡£

5 ½áÊøÓï

±¾ÎÄÊÇ¡¶Debian·þÎñÆ÷ÉèÖÃÈëÃÅ¡·ÏµÁн̳ÌÖ®µÚÒ»Õ£¬½¨ÒéÄú°´ÕÕ˳ÐòÔĶÁ£¬ÓÐÎÊÌâ¿ÉÒÔºÍ×÷ÕßkanakaÁªÏµ¡£
ÎÄÕÂÆÀÂÛ

¹²ÓÐ 0 ÌõÆÀÂÛ