Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

[转] 新版Apache+php+MySQL安装指南 Crossday 修改版

 关闭 [复制链接]
Crossday 发表于 2003-4-3 07:53:47 | 显示全部楼层 |阅读模式
新版mysql+apache+php Linux安装指南

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


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

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

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

  1.mysql

  在如下页面下载mysql的for linux rpm包
  http://www.mysql.com/downloads/down...3.52-1.i386.rpm
  http://www.mysql.com/downloads/down...3.52-1.i386.rpm

  存至/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配置(不运行一些没必要的东西,记录程序运行的慢查询)

  1. skip-locking
  2. skip-networking
  3. skip-bdb
  4. skip-innodb
  5. set-variable    = log-slow-queries=/var/lib/mysql/slow_queries
复制代码


  2.apache

  在如下页面下载apache的for linux 的源码包

  http://www.apache.org/dist/httpd/apache_1.3.28.tar.gz

  存至/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 的源码包

  http://www.php.net/get_download.php?df=php-4.2.3.tar.gz

  存至/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 q3boy@younet.com一行改为您的邮箱地址

#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

  1. #!/bin/bash
  2. #
  3. # Startup script for the Apache Web Server
  4. #
  5. # chkconfig: - 85 15
  6. # description: Apache is a World Wide Web server.  It is used to serve \
  7. #              HTML files and CGI.
  8. # processname: httpd
  9. # pidfile: /var/run/httpd.pid
  10. # config: /etc/httpd/conf/access.conf
  11. # config: /etc/httpd/conf/httpd.conf
  12. # config: /etc/httpd/conf/srm.conf

  13. # Source function library.
  14. . /etc/rc.d/init.d/functions

  15. # This will prevent initlog from swallowing up a pass-phrase prompt if
  16. # mod_ssl needs a pass-phrase from the user.
  17. INITLOG_ARGS=""

  18. # Path to the apachectl script, server binary, and short-form for messages.
  19. apachectl=/usr/local/apache/bin/apachectl
  20. httpd=/usr/local/apache/bin/httpd
  21. prog=httpd
  22. RETVAL=0

  23. # Find the installed modules and convert their names into arguments httpd
  24. # can use.
  25. moduleargs() {
  26.         moduledir=/usr/local/apache
  27.         moduleargs=`
  28.         /usr/bin/find ${moduledir} -type f -perm -0100 -name "*.so" | env -i tr '[:lower:]' '[:upper:]' | awk '{\
  29.         gsub(/.*\//,"");\
  30.         gsub(/^MOD_/,"");\
  31.         gsub(/^LIB/,"");\
  32.         gsub(/\.SO$/,"");\
  33.         print "-DHAVE_" $0}'`
  34.         echo ${moduleargs}
  35. }

  36. # The semantics of these two functions differ from the way apachectl does
  37. # things -- attempting to start while running is a failure, and shutdown
  38. # when not running is also a failure.  So we just do it the way init scripts
  39. # are expected to behave here.
  40. start() {
  41.         echo -n $"Starting $prog: "
  42.         daemon $httpd `moduleargs` $OPTIONS
  43.         RETVAL=$?
  44.         echo
  45.         [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
  46.         return $RETVAL
  47. }
  48. stop() {
  49.         echo -n $"Stopping $prog: "
  50.         killproc $httpd
  51.         RETVAL=$?
  52.         echo
  53.         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd /var/run/httpd.pid
  54. }
  55. reload() {
  56.         echo -n $"Reloading $prog: "
  57.         killproc $httpd -HUP
  58.         RETVAL=$?
  59.         echo
  60. }

  61. # See how we were called.
  62. case "$1" in
  63.   start)
  64.         start
  65.         ;;
  66.   stop)
  67.         stop
  68.         ;;
  69.   status)
  70.         status $httpd
  71.         RETVAL=$?
  72.         ;;
  73.   restart)
  74.         stop
  75.         start
  76.         ;;
  77.   condrestart)
  78.         if [ -f /var/run/httpd.pid ] ; then
  79.                 stop
  80.                 start
  81.         fi
  82.         ;;
  83.   reload)
  84.         reload
  85.         ;;
  86.   graceful|help|configtest)
  87.         $apachectl $@
  88.         RETVAL=$?
  89.         ;;
  90.   *)
  91.         echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  92.         exit 1
  93. esac

  94. exit $RETVAL
复制代码
szboy 发表于 2003-4-4 13:08:30 | 显示全部楼层
正.
回复

使用道具 举报

 楼主| Crossday 发表于 2003-4-4 13:56:07 | 显示全部楼层
Originally posted by szboy at 2003-4-4 01:08 PM:
正.

晕 真能灌!
回复

使用道具 举报

gzdenny 发表于 2003-4-5 04:30:10 | 显示全部楼层
Good~~~ :]
回复

使用道具 举报

DDoS 发表于 2003-4-5 12:18:24 | 显示全部楼层
这个指南里边软件好像有点老了
现在官方网站上提供的rpm和tar.gz包的版本更新太快
我再我的机器上安装时发现和上面说的已经有了一些变化
等我自己安好了
给大家来个最新的安装指南:)
回复

使用道具 举报

gzdenny 发表于 2003-4-5 16:19:57 | 显示全部楼层
支持!!~:]
回复

使用道具 举报

 楼主| Crossday 发表于 2003-4-5 17:16:32 | 显示全部楼层
Originally posted by DDoS at 2003-4-5 12:18 PM:
这个指南里边软件好像有点老了
现在官方网站上提供的rpm和tar.gz包的版本更新太快
我再我的机器上安装时发现和上面说的已经有了一些变化
等我自己安好了
给大家来个最新的安装指南:)

这个可以算很新的了,而且用的是现在用的比较多的DSO方式 升级也比较方便
回复

使用道具 举报

DDoS 发表于 2003-4-5 21:03:59 | 显示全部楼层
我不知道怎么回事
按照上面讲的安装就失败了
害得我反复安装了好多遍系统?
呵呵
主要是我喜欢完美一点:)
请问大C你用的Linux的版本是那个啊?
还有Apache+php+mysql是和指南上面的一样吗?
回复

使用道具 举报

zxp 发表于 2003-7-30 10:05:56 | 显示全部楼层
red hat 9.0 已经默认安装了APACHE  PHP MYSQL
可是还是不能运行PHP
不知道什么缘故


http://localhost/info.php
显示如下

Forbidden
You don't have permission to access /info.php on this server.


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

Apache/2.0.40 Server at zxp Port 80


该如何设置
回复

使用道具 举报

tonyvicky 发表于 2003-7-30 11:34:52 | 显示全部楼层
Originally posted by zxp at 2003-7-30 10:05 AM:
red hat 9.0 已经默认安装了APACHE  PHP MYSQL
可是还是不能运行PHP
不知道什么缘故


http://localhost/info.php
显示如下
...

你可能没有正确设置目录属性,你可以用chmod 命令来改变目录的访问权限.
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-6-15 17:23 , Processed in 0.111533 second(s), 16 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表