[轉(zhuǎn)] 新版Apache+php+MySQL安裝指南 Crossday 修改版
新版mysql+apache+php Linux安裝指南 2002-12-06· ·q3boy··喜悅國(guó)際村 剛剛看到有人貼win下安裝步驟 剛好今天公司網(wǎng)站的新服務(wù)器到手?;艘簧衔绨惭bmysql+php+apache。 新版的老版的還是有些不同的?,F(xiàn)在把步驟帖一下 安裝步驟: 1.mysql 在如下頁(yè)面下載mysql的for linux rpm包 [url]http://www./downloads/down...3.52-1.i386.rpm[/url] [url]http://www./downloads/down...3.52-1.i386.rpm[/url] 存至/home/tmp目錄 命令列表: cd /home/tmp rpm -ivh MySQL-3.23.52-1.i386.rpm #安裝mysql server rpm -ivh MySQL-client-3.23.52-1.i386.rpm #安裝mysql client /usr/mysql/safe_mysqld & #啟動(dòng)mysql server mysql #運(yùn)行mysql 客戶端,并開(kāi)放root用戶的遠(yuǎn)程訪問(wèn)權(quán)限。以便調(diào)試 use mysql update user set host = ‘%‘ where user = ‘root‘ and host <> ‘localhost‘; flush privileges; quit 至此mysql安裝完成 我修改的部分my.cnf配置(不運(yùn)行一些沒(méi)必要的東西,記錄程序運(yùn)行的慢查詢) [code] skip-locking skip-networking skip-bdb skip-innodb set-variable = log-slow-queries=/var/lib/mysql/slow_queries [/code] 2.apache 在如下頁(yè)面下載apache的for linux 的源碼包 [url]http://www./dist/httpd/apache_1.3.28.tar.gz[/url] 存至/home/tmp目錄 命令列表: cd /home/tmp tar -zxvf apache_1.3.28.tar.gz mv apache_1.3.28.tar.gz apache cd apache ./configure --prefix=/usr/local/apache --enable-module=so make make install 安裝apache至/usr/local/apache 并配置apache支持dso方式 最大連接數(shù)設(shè)置 在httpd.conf中設(shè)置: MaxClients n n是整數(shù),表示最大連接數(shù),取值范圍在1和256之間,如果要讓apache支持更多的連接數(shù),那么需要修改源碼中的httpd.h文件,把定義的HARD_SERVER_LIMIT值改大然后再編譯。 3.php 在如下頁(yè)面下載php的for linux 的源碼包 [url]http://www./get_download.php?df=php-4.2.3.tar.gz[/url] 存至/home/tmp目錄 命令列表: cd /home/tmp tar -zxvf php-4.2.3.tar.gz mv php-4.2.3.tar.gz php cd php ./configure --prefix=/usr/local/php --with-apxs=/usr/local/apache/bin/apxs --with-config-file-path=/etc --with-zlib --with-mysql --with-xml make make install cp php.ini-dist /usr/local/lib/php.ini 以dso方式安裝php至/usr/local/php 設(shè)置配置文件目錄為/usr/local/lib 開(kāi)啟mysql,xml支持 4.配置 vi /usr/local/apache/conf/httpd.conf 對(duì)apache做如下配置 #將ServerAdmin [email]q3boy@younet.com[/email]一行改為您的郵箱地址 #DocumentRoot "/home/httpd/html/" 此處為html文件主目錄 # 同上 #Options FollowSymLinks MultiViews 為安全起見(jiàn),去掉"Indexes" # # DirectoryIndex default.php default.phtml default.php3 default.html default.htm # #設(shè)置apache的默認(rèn)文件名次序 #AddType application/x-httpd-php .php .phtml .php3 .inc #AddType application/x-httpd-php-source .phps #設(shè)置php文件后綴 存盤(pán)退出 vi /usr/local/lib/php.ini #register-golbals = On 存盤(pán)退出 5.啟動(dòng)服務(wù) /usr/local/apache/bin/apachectl start 6.備注 apache在linux下的默認(rèn)最大進(jìn)程數(shù)為256,無(wú)論如何修改httpd.conf都不能超過(guò)這個(gè)限制。如果想加大這個(gè)限制,在編譯apache前編輯/home/tmp/apache/src/include/httpd.h,將其中#define HARD_SERVER_LIMIT 256 一行改為#define HARD_SERVER_LIMIT 2048后再編譯apache, apache 1.3.26中mod_so似乎已經(jīng)不是默認(rèn)模塊了。編譯時(shí)候需加上--enable-module=so,我第一次編譯沒(méi)加此參數(shù),結(jié)果php編譯時(shí)無(wú)法找到apxs php 4.2.3中默認(rèn)配置文件路徑似乎變了。編譯時(shí)需加上 --with-config-file-path=/usr/local/lib 參數(shù),我第一次編譯完php.ini放了n個(gè)地方都沒(méi)有用。不得已。只能加上這個(gè)參數(shù)。 p.s. 不保證本文所述步驟適用于其他版本 apache 啟動(dòng)腳本 /etc/init.d/httpd [code] #!/bin/bash # # Startup script for the Apache Web Server # # chkconfig: - 85 15 # description: Apache is a World Wide Web server. It is used to serve \ # HTML files and CGI. # processname: httpd # pidfile: /var/run/httpd.pid # config: /etc/httpd/conf/access.conf # config: /etc/httpd/conf/httpd.conf # config: /etc/httpd/conf/srm.conf # Source function library. . /etc/rc.d/init.d/functions # This will prevent initlog from swallowing up a pass-phrase prompt if # mod_ssl needs a pass-phrase from the user. INITLOG_ARGS="" # Path to the apachectl script, server binary, and short-form for messages. apachectl=/usr/local/apache/bin/apachectl httpd=/usr/local/apache/bin/httpd prog=httpd RETVAL=0 # Find the installed modules and convert their names into arguments httpd # can use. moduleargs() { moduledir=/usr/local/apache moduleargs=` /usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr ‘[:lower:]‘ ‘[:upper:]‘ | awk ‘{\ gsub(/.*\//,"");\ gsub(/^MOD_/,"");\ gsub(/^LIB/,"");\ gsub(/\.SO$/,"");\ print "-DHAVE_" $0}‘` echo ${moduleargs} } # The semantics of these two functions differ from the way apachectl does # things -- attempting to start while running is a failure, and shutdown # when not running is also a failure. So we just do it the way init scripts # are expected to behave here. start() { echo -n $"Starting $prog: " daemon $httpd `moduleargs` $OPTIONS RETVAL=$? echo [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd return $RETVAL } stop() { echo -n $"Stopping $prog: " killproc $httpd RETVAL=$? echo [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid } reload() { echo -n $"Reloading $prog: " killproc $httpd -HUP RETVAL=$? echo } # See how we were called. case "$1" in start) start ;; stop) stop ;; status) status $httpd RETVAL=$? ;; restart) stop start ;; condrestart) if [ -f /var/run/httpd.pid ] ; then stop start fi ;; reload) reload ;; graceful|help|configtest) $apachectl $@ RETVAL=$? ;; *) echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}" exit 1 esac exit $RETVAL [/code] |
|