分享

(转) 新版Apache php MySQL安装指南 Crossday 修改版

 todaytomo 2007-01-07
[转] 新版Apache+php+MySQL安装指南 Crossday 修改版

新版mysql+apache+php Linux安装指南

2002-12-06· ·q3boy··喜悦国际村


  刚刚看到有人贴win下安装步骤

  刚好今天公司网站的新服务器到手。花了一上午安装mysql+php+apache。

  新版的老版的还是有些不同的。现在把步骤帖一下
  安装步骤:

  1.mysql

  在如下页面下载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 & #启动mysql server
mysql #运行mysql 客户端,并开放root用户的远程访问权限。以便调试
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./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方式

最大连接数设置

在httpd.conf中设置:
MaxClients n
n是整数,表示最大连接数,取值范围在1和256之间,如果要让apache支持更多的连接数,那么需要修改源码中的httpd.h文件,把定义的HARD_SERVER_LIMIT值改大然后再编译。

  3.php

  在如下页面下载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 设置配置文件目录为/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
#
#设置apache的默认文件名次序

#AddType application/x-httpd-php .php .phtml .php3 .inc
#AddType application/x-httpd-php-source .phps
#设置php文件后缀


  存盘退出

vi /usr/local/lib/php.ini
#register-golbals = On  

  存盘退出

  5.启动服务
  /usr/local/apache/bin/apachectl start

  6.备注
  apache在linux下的默认最大进程数为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似乎已经不是默认模块了。编译时候需加上--enable-module=so,我第一次编译没加此参数,结果php编译时无法找到apxs

  php 4.2.3中默认配置文件路径似乎变了。编译时需加上 --with-config-file-path=/usr/local/lib 参数,我第一次编译完php.ini放了n个地方都没有用。不得已。只能加上这个参数。

  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]

    本站是提供个人知识管理的网络存储空间,所有内容均由用户发布,不代表本站观点。请注意甄别内容中的联系方式、诱导购买等信息,谨防诈骗。如发现有害或侵权内容,请点击一键举报。
    转藏 分享 献花(0

    0条评论

    发表

    请遵守用户 评论公约

    类似文章 更多