[轉(zhuǎn)] 新版Apache+php+MySQL安裝指南 Crossday 修改版
新版mysql+apache+php Linux安裝指南
2002-12-06· ·q3boy··喜悅國際村
剛剛看到有人貼win下安裝步驟
剛好今天公司網(wǎng)站的新服務器到手?;艘簧衔绨惭bmysql+php+apache。
新版的老版的還是有些不同的?,F(xiàn)在把步驟帖一下
安裝步驟:
1.mysql
在如下頁面下載mysql的for linux rpm包
[url]http://www.mysql.com/downloads/down...3.52-1.i386.rpm[/url]
[url]http://www.mysql.com/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 & #啟動mysql server
mysql #運行mysql 客戶端,并開放root用戶的遠程訪問權(quán)限。以便調(diào)試
use mysql
update user set host = ‘%‘ where user = ‘root‘ and host <> ‘localhost‘;
flush privileges;
quit
至此mysql安裝完成
我修改的部分my.cnf配置(不運行一些沒必要的東西,記錄程序運行的慢查詢)
[code]
skip-locking
skip-networking
skip-bdb
skip-innodb
set-variable = log-slow-queries=/var/lib/mysql/slow_queries
[/code]
2.apache
在如下頁面下載apache的for linux 的源碼包
[url]http://www.apache.org/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
在如下頁面下載php的for linux 的源碼包
[url]http://www.php.net/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 開啟mysql,xml支持
4.配置
vi /usr/local/apache/conf/httpd.conf
對apache做如下配置
#將ServerAdmin [email]q3boy@younet.com[/email]一行改為您的郵箱地址
#DocumentRoot "/home/httpd/html/" 此處為html文件主目錄
# 同上
#Options FollowSymLinks MultiViews 為安全起見,去掉"Indexes"
#
# DirectoryIndex default.php default.phtml default.php3 default.html default.htm
#
#設(shè)置apache的默認文件名次序
#AddType application/x-httpd-php .php .phtml .php3 .inc
#AddType application/x-httpd-php-source .phps
#設(shè)置php文件后綴
存盤退出
vi /usr/local/lib/php.ini
#register-golbals = On
存盤退出
5.啟動服務
/usr/local/apache/bin/apachectl start
6.備注
apache在linux下的默認最大進程數(shù)為256,無論如何修改httpd.conf都不能超過這個限制。如果想加大這個限制,在編譯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)不是默認模塊了。編譯時候需加上--enable-module=so,我第一次編譯沒加此參數(shù),結(jié)果php編譯時無法找到apxs
php 4.2.3中默認配置文件路徑似乎變了。編譯時需加上 --with-config-file-path=/usr/local/lib 參數(shù),我第一次編譯完php.ini放了n個地方都沒有用。不得已。只能加上這個參數(shù)。
p.s. 不保證本文所述步驟適用于其他版本
apache 啟動腳本 /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]
本站僅提供存儲服務,所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請
點擊舉報。