ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

[Âà¶K] PHP+Apache+MySQL(Linux)§¹¾ã¦w¸Ëªk

[Âà¶K] PHP+Apache+MySQL(Linux)§¹¾ã¦w¸Ëªk

³q ¥Î][±Ð¾Ç] Âà¶K PHP+Apache+MySQL(Linux)§¹¾ã¦w¸Ëªk

¡iÃþ«¬¡j¨ä¥L
¡iª©¥»¡j³q ¥Î

¦w¸ËMYSQL

¦pªG¬OLinux¥Î¤á¡A¥ý½T©w¬O§_¤w¦w¸ËMySQL RPM¡A¦pªG¦³¡A½Ð±N¥¦²¾°£¡G

Shell# rpm -qa|grep mysql

Shell# rpm -e mysql®M¥ó¦WºÙ

µù¡G­Y¦³¸ê®Æ®w½Ð¥ý±N¥¦³Æ¥÷


¨ú¦^¨Óªº³nÅé³q±`¬OÀ£ÁYÀÉ¡A¥ý¥Hroot¨­¥÷±N³nÅé¸ÑÀ£

Shell# cd /root

Shell# gunzip < mysql-3.23.36.tar.gz | tar xvf -

( Shell# tar -zxvf mysql-3.23.36.tar.gz)


³]©w¦w¸Ë²ÕºA

Shell# cd mysql-3.23.36

Shell# ./configure --prefix=/usr/local/mysql -with-charset=big5

(¦pªG¦³¨ä¥L³]©w¤è­±ªº°ÝÃD¥i¿é¤Jconfigure --helpÅã¥Ü³]©w»¡©ú¡C)


½sĶ¤Î¦w¸Ë

Shell# make

Shell# make install


«Ø¥ßMySQLªì©l¤ÆTable

Shell# scripts/mysql_install_db

»¡©ú¡G«Ø¥ßMySQL Grant Table¡A²Ä¤@¦¸¦w¸ËMySQL³£¥²¶·°õ¦æ³o­Ó«ü¥O

½Æ»smy.cnf ¡]my.cnf¬°mysql daemon°_°Ê³]©wÀÉ¡^

Shell# cp support-files/my-medium.cnf /etc/my.cnf


«Ø¥ßmysql¸s²Õ¥H¤Î¨Ï¥ÎªÌ¡A¨Ã¥Hmysqlªº¨­¥÷°_°Êserver

Shell# groupadd mysql

Shell# useradd mysql -g mysql

shell# chown -R root /usr/local/mysql

Shell# chown -R mysql /usr/local/mysql/var

Shell# chgrp -R mysql /usr/local/mysql

Shell# /usr/local/mysql/bin/safe_mysqld --user=mysql &


´ú¸ÕMySQL Server¬O¤£¬O¦³¥¿±`¹B§@

Shell# /usr/local/mysql/bin/mysqladmin version

Shell# /usr/local/mysql/bin/mysqladmin variables


8. ¶}¾÷¦Û°Ê°õ¦æMySQL Server ¡G­×§ï /etc/rc.d/rc.local¡A¥[¤J

/bin/sh -c 'cd /usr/local/mysql ; ./bin/safe_mysqld --user=mysql &'

¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×¡×

¦w¸ËAPACHE+PHP

¦w¸Ë©µ¦ù³nÅé(­Y­nPHP¯à¨Ï¥ÎGD¡BFreetypeµ¥¨ç¦¡®w¡A¶·¥ý¥¦­Ì±N½sĶ©Î¦w¸Ë¦n)

¤@¡BGD¡]­ì©lÀɽsĶ¦w¸Ë¡^

# tar -zxvf gd.1.3.tar.gz

# cd gd.1.3

# make


¤G¡BFreetype¡]¥Îrpm¦w¸Ë¤§¡^

# rpm -ivh freetype-2.0.1.CLE.rpm

# rpm -ivh freetype-devel-2.0.1.CLE.rpm

ª`·N¡G­Y¨t²Î¤w¦³¤W­zRPMÀÉ¡A¥i¥ý±N¥¦­Ì²¾°£

¦pªG¬OLinux¥Î¤á¡A¥ý¬d¬Ý¬O§_¦³¦w¸ËApache ©ÎPHP RPM¡A¦pªG¦³¡A½Ð±N¥¦­Ì²¾°£

Shell# rpm -qa|grep apache

Shell# rpm -e apache®M¥ó¦WºÙ

Shell# rpm -qa|grep php

Shell# rpm -e php®M¥ó¦WºÙ

ª`·N¡G­Y¨t²Î¦³¥¿¦b¹B§@ªºAPACHE SERVER¡A½Ð¥ý±Nhttpd.conf³Æ¥÷°_¨Ó

2.¥ý±N³nÅé¸ÑÀ£ÁY

Shell# cd /root

Shell# gunzip < php-4.0.5.tar.gz | tar xvf -

Shell# gunzip < apache_1.3.19.tar.gz | tar xvf -

3. ³]©wapache¦w¸Ë¥Ø¿ý

Shell# cd apache_1.3.19

Shell# ./configure --prefix=/home/www

4. ³]©wPHP¦w¸Ë¿ï¶µ

Shell# cd ../php-4.0.5

Shell# ./configure \

--with-apache=../apache_1.3.19 \

--with-mysql=/usr/local/mysql \

--with-openssl --with-gd=../gd1.3 --with-ttf \

------------------------------------------------
¡· ¿ï¶µ--with-apache=../apache_1.3.19ªí¥Üapache­ì©l¥Ø¿ý

¡· --with-mysql=/usr/local/mysqlªí¥Ü¨Ï¥Îmysql

¡· --with-gd=../gd1.3ªí¥Ü¨Ï¥Îgd¨ç¦¡®w(gd1.3¬°gd¦w¸Ë¥Ø¿ý)

¡· --with-openssl¤ä´©OpenSSL(»Ý¦³openssl®M¥ó)

¡· --with-ttf¤ä´©freetype

5. ½sĶ¤Î¦w¸ËPHP

Shell# make

Shell# make install

6. ½sĶApache

Shell# cd ../apache_1.3.19

Shell# ./configure --activate-module=src/modules/php4/libphp4.a

Shell# make

Shell# make install

7. ½Æ»sPHP³]©wÀÉ

Shell# cp /root/php-4.0.5/php.ini.dist /usr/local/lib/php.ini

8. ­×§ïApache³]©wÀÉhttpd.conf¡A¥[¤J©Î­×§ï¤U¦C³]©w¡G

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

9. ­«·s±Ò°ÊApache

Shell# /home/www/bin/apachectl restart

10. ´ú¸Õ

¦bWWWªººô­¶¥Ø¿ý¤U¡A¼g¤@´ú¸ÕÀÉ test.php¡A¤º®e¬° <?php phpinfo() ? > ¦p¥iÅã¥ÜphpªºÀô¹Ò¤º®eªí¥Ü phpªº¦w¸Ë¦¨¥\¤F!!

----------------------------------

http://dob.tnc.edu.tw/themes/old/showPage.php?s=54&t=1

¤@¯ë¨Ó»¡¡A¦bLinux¤U¦w¸Ëªº¶¶§Ç¬°MySQL-PHP-Apache¡A¦]¦¹¡A³o¤@³æ¤¸¡A§Ú­Ì´N¨Ó¬Ý¬Ý¦p¦ó¦bLinux¤U¦w¸ËMySQL¡C
½Ð±Napache_1.3.20.tar.gz¡Bphp-4.0.5.tar.gz¡Bmysql-3.23.39.tar.gz³o´X­ÓÀ£ÁYÀÉ¡A·Q¿ìªk§Ë¨ìLinux¥D¾÷¤¤ªº/usr/local/src/¤U¡C


¡i¦w¸ËMySQL¡j

¥ý¤U¸ü mysql-3.23.39.tar.gz ¨ìLinux¥D¾÷¤¤ªº/usr/local/src/¤U¡C
¤Á´«¨ì/usr/local/src/¥Ø¿ý¤U¡C
cd /usr/local/src

§â³o¤T­ÓÀɮ׳£¶i¦æ¸ÑÀ£ÁY¡G
tar zxvf mysql-3.23.39.tar.gz

¸ÑÀ£ÁY¤§«á¡A½Ð¤Á´«¨ìmysql¥Ø¿ý¡A¥H·Ç³Æ¶i¦æMySQLªº½sĶ¥H¤Î¦w¸Ëªº°Ê§@¡G
cd mysql-3.23.39

¶i¥h¤§«á¡A§Ú­Ì¿é¤J¤U­±«ü¥O¡A¥H°õ¦æmysql²ÕºA³]©w¡G
./configure --prefix=/usr/local/mysql --localstatedir=/usr/local/mysql/var

¨ä¦w¸Ë¸ô®|¡]prefix¡^¬°/usr/local/mysql¡Alocalstatedir ¬O¥Î¨Ó«ü©w¸ê®Æ®wÀɪº¦s©ñ¥Ø¿ý¦ì¸m¡A§Ú­Ì±N¤§³]¦b/usr/local/mysql/var¡A¦Ü©ó¥H«eªºÂª©¥»¬°¤F¥[¤J¹ï¤¤¤å¦rªº¤ä´©¡A§Ú­Ì±`·|¦A¥[¤J--with-charset=big5¡A¤£¹L¡A¦¹¤@·sª©¥»¤£»Ý­n¡A¥[¤Jªº¸Ü¤Ï¦Ó¹ï¤¤¤åªº¤ä´©·|¦³°ÝÃD¡A©Ò¥H§Ú­Ì¨Ã¤£¥[¤J¦¹°Ñ¼Æ¡C¾ã­Ó¹Lµ{¶·¬ù¤@¡B¤G¤ÀÄÁ¡Aµy·Lµ¥µ¥§a¡I­Y·Q¶i¶¥³]©w½Ð¤U./configure --helpÆ[¬Ý¨ä»¡©ú¡C

±µµÛ¡A¿é¤J½sĶ«ü¥O¡A¥H»s³yMySQLªº¦w¸Ëµ{¦¡¡A¾ã­Ó¹Lµ{·|¤ñ¤W­±¨º­Ó°Ê§@ÁÙ¤[¤W³\¦h¡AºÝ¬Ý±z¹q¸£ªº¹Bºâ¯à¤O¦Ó©w°Õ¡I¹³¤u¤Íªº¹q¸£´N¨¬¨¬¶]¶W¹L¤Q¤ÀÄÁ¦³¾l¡C±z¥i¥H¶X¾÷¥hªw©@°Ø¡A¤Ï¥¿Åý¹q¸£¥h¦£´N¦n¤F¡C½sĶªº¹Lµ{·|¥X²{¤@°ï¶Ã¤C¤KÁVªºªF¦è¡A¤£¥Î¥h¬Ý¨SÃö«Y¡A­Ë¬O³Ì«á°±¤U¨Ó¤§«áªºµ²ªG±z¥²¶·ª`·N¤@¤U¡A¬Ý¬Ýµe­±¤¤¦³µL¥ô¦óerrorªº°T®§¡A­Y¬O¨S¦³ªº¸Ü¡A¨ºªí¥Ü½sĶ¦¨¥\¤F¡I
make

½sĶ¦n¤§«á¡A§Ú­Ì¶}©l¶i¦æ¦w¸ËMySQLªº°Ê§@¡A³o­Ó´N§Ö¦h¤F¡A¬ù²ö¤@¤ÀÄÁ¤£¨ì´N¥i¥H§¹¦¨¤F¡G
make install


¡i«Ø¥ßmysqlÅv­­¸ê®Æ®w¡j

¦w¸Ë¦n¤§«á¡A¿é¤J¤U¤è«ü¥O¡A¥H²£¥Í¦W¬°mysqlªº¸ê®Æ®w¡A³o­Ó°Ê§@«D±`ªº­«­n¡A¨S¦³°µªº¸Ü¡AMySQL¬O¤£·|°Êªº¡A°ò¥»¤WMySQL¨ì¦¹¦w¸Ë¥i¥Hºâ¬O§¹¦¨¤F¡I
scripts/mysql_install_db

½Ðª`·N¡AMySQL«üªº¬OMySQL¸ê®Æ®w¦øªA¾¹¡A¦Ómysql«h¬OMySQL¦øªA¾¹¤¤ªº¤@­Ó¸ê®Æ®w¦WºÙ¡A¦¹¨âªÌ®e©ö²V²c¡A½Ðª`·N¡C
mysql¸ê®Æ®w«D±`­«­n¡A¬OMySQL¦øªA¾¹ªº®Ö¤ß¡A¥u¦³MySQLªºroot¦³Åv­­¥i¥H¬Ý¡C

¡i³]©wroot±b¸¹¡j

MySQL¸Ìªº±b¸¹©MLinuxªº¨Ï¥ÎªÌ±b¸¹¬O¨â¦^¨Æ¡A²@¤£¬Û¤z¡A©³¤Uªºroot«üªº¬OMySQL¦øªA¾¹¤¤ªºroot±b¸¹¡C
¦w¸Ë§¹²¦¤§«á¡A§Ú­Ì·s¼W­Ó±b¸¹¨Ó°õ¦æMySQL¸ê®Æ®w¡A±µµÛ±N/usr/local/mysql¸ÌªºÀÉ®×¾Ö¦³Åv­­³]µ¹¦¹¤@±b¸¹¡C³o­Ó°Ê§@¬O¬°¼W¥[MySQLªº¦w¥þ©Ê¡C
adduser mysql

chown -R mysql.mysql /usr/local/mysql

±µ¤U¨Ó§Ú­Ì¨Ó±Ò°ÊMySQL§a¡I±Ò°ÊMySQLªº«ü¥O¦p¤U¡G
/usr/local/mysql/bin/safe_mysqld --user=mysql &

±Ò°Ê¤FMySQL¤§«á¡A§Ú­Ì»°ºò¨Óµ¹MySQL³]©w±K½X§a¡I­º¥ý¥ý¤Á´«¨ì/usr/local/mysql/binªº¥Ø¿ý¤U¡AµM«á°õ¦æ¡u./mysqladmin -u root password '±K½X'¡v¨Óµ¹root³]©w±K½X¡C¨Ò¦p¡G§Ú­Ì·Q§âMySQLªººÞ²zªÌrootªº±K½X³]¬°12345¡A«h°õ¦æ¤U¦C«ü¥O¡G
cd /usr/local/mysql/bin
./mysqladmin -u root password '12345'


¡i¦Û°Ê±Ò°Ê³]©w¡j

¶â¡K¨C¦¸¶}¾÷³£­n¦Û¤v±Ò°ÊMySQL¤]¬O«Ü²Öªº¤@¥ó¨Æ¡A©Ò¥H¡A±z¥i¥H§â±Ò°Ê«ü¥O¡]¦p¤U¡^¥[¨ì/etc/rc.d/rc.localÀɮתº³Ì«á¤@¦æ¡A¨º»ò¡A¥H«á¶}¾÷«K·|¦Û°Ê±Ò°ÊMySQL¤F¡C
/usr/local/mysql/bin/safe_mysqld --user=mysql &

MySQL¨ì³o¸Ìºâ¬O¤w¸g§¹¥þ·d©w¤F¡I±z­Y¤£½T©wMySQL¬O¤£¬O¤w¸g¥¿¦b¹B§@¤F¡A±z¥i¥H¤Ups aux |moreªº«ü¥O¡A­Y±z¬Ý¨ì¦p¤UªºªF¦è¡A¨ºªí¥Ümysql¤w¸g¦b¹B§@Åo¡I

mysql 32274 0.0 0.3 12012 1964 pts/1 S 15:01 0:00 /usr/local/mysql/
mysql 32276 0.0 0.3 12012 1964 pts/1 S 15:01 0:00 /usr/local/mysql/
mysql 32277 0.0 0.3 12012 1964 pts/1 S 15:01 0:00 /usr/local/mysql/

        ÀR«ä¦Û¦b : ¤â¤ß¦V¤U¬O§U¤H¡A¤â¤ß¦V¤W¬O¨D¤H¡F§U¤H§Ö¼Ö¡A¨D¤Hµh­W¡C
ªð¦^¦Cªí ¤W¤@¥DÃD