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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

CentOS5.2配置LAMP全过程(第二版)

[复制链接]
hew 发表于 2008-11-24 19:37:30 | 显示全部楼层 |阅读模式
作者:eddiechen 原文地址:http://bbs.linuxsky.org/thread-7226-1-1.html

最近发现我以前写centos5.2的配置过程,里面有不少错误的地方。很多编译安装的软件,事实上,好像没有最后用到。这也是我重新写一次。

这次学会了几个sed的用法,所以很多的改动我尽量用sed来完成,这样就简单很多。还有就是系统的初始设置。我已经重新整理过来。基本可以做到一个脚本完成全过程。

下面的配置,很多关于安全的设置,都没有做,现在还没有搞的太明白,如果web是给内网使用或者测试,那么应该问题不大,如果是拿到外面使用,估计还是需要做不少的优化。如cache,防盗链这些。



参考文档

参考了网上不少文档,下面的3篇是重点,不少代码都是从下面复制过来的。

RHEL4上安装基于postfix的全功能邮件服务器(全部使用目前最新源码包构建) (http://bbs.chinaunix.net/thread-987344-1-1.html
Nginx 0.7.x + PHP 5.2.6(FastCGI)搭建胜过Apache十倍的Web服务器(第4版)(http://blog.s135.com/read.php/366.htm
基于CentOS构建高性能的LAMP平台.(http://bbs.linuxtone.org/thread-122-1-1.html

文章内容分为7部分

一:系统约定
二:系统基本设置
三:下载软件
四:安装必须的软件
五:编译安装软件
六:配置apache PHP
七:测试 (通过phpinfo,phpmyadmin,sugarcrm的安装来测试)

一:系统约定
    采用Centos5.2光盘,
    软件源代码包存放位置        /usr/local/src
    源码包编译安装位置(prefix)        /usr/local/software_name
    MySQL 数据库位置        /data/mysql/data
    Apache 网站根目录        /data/www/wwwroot(虚拟主机在这个目录下)
    Apache 虚拟主机日志根目录        /data/www/logs
    Apache 运行账户        www:www
    创建两个虚拟主机    test.com linux.com

所有的配置的文件修改,都做备份,备份的名字为 文件名.save

下面的实验是用vmware station 6 创建一个 redhat AS5的vm,安装centos5.2,安装的时候,选择安装语言是英文,采用文本方式来安装,选择最小化的安装。

yum的更新,采用本地光盘的方式,这样比较快捷。

我的机器基本设置

IP:192.168.1.200/255.255.255.0

网关:192.16.1.1

DNS:192.168.1.1

hostname:ns1

二:系统基本设置

我已经把所有需要配置的内容,做一个一个脚本,只需要运行一次就可以。
  1. cd /usr/local/src

  2. vi /usr/local/src/init.sh
复制代码
  1. #####################

  2. #Diabe IPV6
  3. cp /etc/modprobe.conf /etc/modprobe.conf.save
  4. echo "alias net-pf-10 off" >> /etc/modprobe.conf
  5. echo "alias ipv6 off" >> /etc/modprobe.conf

  6. #SSH
  7. cp /etc/ssh/sshd_config /etc/ssh/sshd_config.save
  8. sed -i '/#PermitRootLogin/s/#PermitRootLogin/PermitRootLogin/' /etc/ssh/sshd_config
  9. sed -i -e '74 s/^/#/' -i -e '76 s/^/#/' /etc/ssh/sshd_config
  10. sed -i "s/#UseDNS yes/UseDNS no/" /etc/ssh/sshd_config
  11. sed -i -e '44 s/^/#/' -i -e '48 s/^/#/' /etc/ssh/sshd_config
  12. /etc/init.d/sshd restart

  13. #停止 the “beep"


  14. cp /etc/inputrc /etc/inputrc.save
  15. sed -i '/#set bell-style none/s/#set bell-style none/set bell-style none/' /etc/inputrc


  16. #关闭SElinux

  17. cp /etc/sysconfig/selinux /etc/sysconfig/selinux.save
  18. sed -i '/SELINUX=enforcing/s/SELINUX=enforcing/SELINUX=disabled/' /etc/sysconfig/selinux



  19. #加载光驱

  20. mkdir /mnt/cdrom
  21. mount /dev/cdrom /mnt/cdrom
  22. echo "mount /dev/cdrom /mnt/cdrom" >> /etc/rc.local


  23. #设置yum使用本地光盘

  24. mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.save
  25. mv /etc/yum.repos.d/CentOS-Media.repo /etc/yum.repos.d/CentOS-Media.repo.save
  26. echo "[DVDISO]" >> /etc/yum.repos.d/dvdiso.repo
  27. echo "name=DVD ISO" >> /etc/yum.repos.d/dvdiso.repo
  28. echo "baseurl=file:///mnt/cdrom/" >> /etc/yum.repos.d/dvdiso.repo
  29. echo "enabled=1" >> /etc/yum.repos.d/dvdiso.repo
  30. echo "gpgcheck=0" >> /etc/yum.repos.d/dvdiso.repo


  31. #vim设置

  32. yum -y install vim-enhanced
  33. mv /bin/vi /bin/vi.save
  34. ln -s /usr/bin/vim /bin/vi
  35. cp /etc/vimrc /etc/vimrc.save
  36. sed -i "39 s/^/ set number \n filetype on\n set history=1000\n syntax on\n set tabstop=4\n set showmatch\n set vb t_vb=\n set mouse=a\n set ignorecase\n set autowrite\n /" /etc/vimrc

  37. #时间的设置
  38. yum -y install ntp
  39. ntpdate 210.72.145.44 && clock -w

  40. #安装常用软件

  41. yum -y install wget unzip

  42. #停止没有必要的服务
  43. chkconfig --list |grep 3:on |awk '{print $1}' |egrep -v 'sshd|network|syslog' |xargs -i{} chkconfig --level 3 {} off
  44. chkconfig --list | grep 3:on | cut -f1

  45. #重新启动
  46. init 6
  47. ####################
复制代码
  1. sh init.sh
复制代码
三:下载软件
  1. cd /usr/local/src

  2. vi list
复制代码
  1. http://download.filehat.com/apache/httpd/httpd-2.2.8.tar.gz
  2. http://opensource.nchc.org.tw/COSA/CNS4/cronolog-1.6.2.tar.gz
  3. http://www.libgd.org/releases/gd-2.0.35.tar.bz2
  4. http://ftp.gnu.org/pub/gnu/libiconv/libiconv-1.12.tar.gz
  5. http://mirror.optus.net/sourceforge/m/mc/mcrypt/libmcrypt-2.5.8.tar.gz
  6. http://jaist.dl.sourceforge.net/sourceforge/mcrypt/mcrypt-2.6.7.tar.gz
  7. http://www.openssl.org/source/openssl-0.9.8h.tar.gz
  8. http://openbsd.md5.com.ar/pub/OpenBSD/OpenSSH/portable/openssh-5.0p1.tar.gz
  9. http://mysql.byungsoo.net/Downloads/MySQL-5.0/mysql-5.0.51b.tar.gz
  10. http://cn2.php.net/get/php-5.2.6.tar.bz2/from/this/mirror
  11. http://downloads.phpchina.com/zend/optimizer/3.3.3/ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
  12. ftp://ftp.cac.washington.edu/mail/imap.tar.Z
  13. http://puzzle.dl.sourceforge.net/sourceforge/phpmyadmin/phpMyAdmin-2.11.8.1-all-languages-utf-8-only.tar.gz
  14. http://dl.sugarforge.org/sugarcrm/Latest-SugarCE5.1/SugarCE5.1.0/SugarCE-5.1.0.zip
  15. http://mirror.optus.net/sourceforge/m/mh/mhash/mhash-0.9.9.tar.gz
复制代码
  1. wget -i list
复制代码
四:安装必须的软件

采用yum的方式安装
  1. yum -y install gcc make patch gcc-c++ gcc-g77 flex bison autoconf automake \
  2. libjpeg libjpeg-devel libpng libpng-devel freetype freetype-devel libxml2 libxml2-devel zlib zlib-devel glibc glibc-devel glib2 glib2-devel bzip2 bzip2-devel ncurses ncurses-devel curl curl-devel libtiff-devel fontconfig-devel libXpm-devel gettext-devel   pam-devel pcre-devel libtool libtool-ltdl
复制代码
五:编译安装软件


下面的内容,其实你可以复制到一个文本,比如 install.sh 运行这个脚本,我已经测试过了,整整运行了快1个小时,估计是我在vm上跑道原因。前提是你下载的软件和我是一样的,也就是软件都是通过上面的下载的。
  1. ###############################################

  2. #安装openssl
  3. cd /usr/local/src
  4. tar zxvf openssl-0.9.8h.tar.gz
  5. cd openssl-0.9.8h
  6. ./config shared zlib
  7. make
  8. make test
  9. make install
  10. mv /usr/bin/openssl /usr/bin/openssl.save
  11. mv /usr/include/openssl /usr/include/openssl.save
  12. mv /usr/lib/libssl.so /usr/lib/libssl.so.save
  13. ln -s /usr/local/ssl/bin/openssl /usr/bin/openssl
  14. ln -s /usr/local/ssl/include/openssl /usr/include/openssl
  15. ln -sv /usr/local/ssl/lib/libssl.so.0.9.8 /usr/lib/libssl.so
  16. cd ..


  17. #配置库文件搜索路径
  18. echo "/usr/local/ssl/lib" >> /etc/ld.so.conf
  19. ldconfig -v

  20. #检测安装结果
  21. openssl version

  22. #安装openssh

  23. tar xvf openssh-5.0p1.tar.gz

  24. cd openssh-5.0p1

  25. ./configure \
  26.       "--prefix=/usr" \
  27.       "--with-pam" \
  28.       "--with-zlib" \
  29.       "--sysconfdir=/etc/ssh" \
  30.       "--with-ssl-dir=/usr/local/ssl" \
  31.       "--with-md5-passwords"

  32. make
  33. make install

  34. cd ..

  35. service sshd restart

  36. ssh -v

  37. #安装GD

  38. tar jxvf gd-2.0.35.tar.bz2
  39. cd gd-2.0.35
  40. aclocal
  41. ./configure --prefix=/usr/local/gd2
  42. make && make install
  43. cd ..

  44. #安装 libmcrypt


  45. tar zxvf libmcrypt-2.5.8.tar.gz

  46. cd libmcrypt-2.5.8/
  47. ./configure
  48. make
  49. make install
  50. /sbin/ldconfig
  51. cd libltdl/
  52. ./configure --enable-ltdl-install
  53. make
  54. make install
  55. cd ../../

  56. cp /usr/local/lib/libmcrypt.* /usr/lib



  57. #安装libiconv


  58. tar zxvf libiconv-1.12.tar.gz

  59. cd libiconv-1.12/
  60. ./configure --prefix=/usr/local
  61. make
  62. make install
  63. cd ../

  64. ln -s /usr/local/lib/libiconv.so.2 /usr/lib/


  65. #安装mhash

  66. tar zxvf mhash-0.9.9.tar.gz
  67. cd mhash-0.9.9/
  68. ./configure
  69. make
  70. make install
  71. cd ../
  72. ln -s /usr/local/lib/libmhash.so.2 /usr/lib/libmhash.so.2

  73. #安装mcrypt


  74. tar zxvf mcrypt-2.6.7.tar.gz
  75. cd mcrypt-2.6.7/
  76. ./configure
  77. make
  78. make install
  79. cd ../


  80. #安装cronolog

  81. tar xvf cronolog-1.6.2.tar.gz

  82. cd cronolog-1.6.2

  83. ./configure --prefix=/usr/local/cronolog

  84. make && make install

  85. cd ..


  86. #安装imap

  87. tar zxf imap.tar.Z
  88. cd imap-2007b
  89. make lr5 PASSWDTYPE=std SSLTYPE=unix.nopwd IP6=4
  90. echo "set disable-plaintext nil" > /etc/c-client.cf
  91. mkdir /usr/local/imap-2007b
  92. mkdir /usr/local/imap-2007b/include/
  93. mkdir /usr/local/imap-2007b/lib/
  94. chmod -R 077 /usr/local/imap-2007b
  95. rm -rf /usr/local/imap-2007b/include/*
  96. rm -rf /usr/local/imap-2007b/lib/*
  97. rm -rf /usr/sbin/imapd
  98. cp imapd/imapd /usr/sbin/
  99. cp c-client/*.h /usr/local/imap-2007b/include/
  100. cp c-client/*.c /usr/local/imap-2007b/lib/
  101. cp c-client/c-client.a /usr/local/imap-2007b/lib/libc-client.a

  102. cd ..

  103. #安装MYSQL


  104. tar zxvf mysql-5.0.51b.tar.gz

  105. cd mysql-5.0.51b

  106. ./configure \
  107.        "--prefix=/usr/local/mysql" \
  108.        "--localstatedir=/data/mysql/data" \
  109.        "--with-comment=Source" \
  110.        "--with-server-suffix=-test.com" \
  111.        "--with-mysqld-user=mysql" \
  112.        "--without-debug" \
  113.        "--with-big-tables" \
  114.        "--with-charset=gbk" \
  115.        "--with-collation=gbk_chinese_ci" \
  116.        "--with-extra-charsets=all" \
  117.        "--with-pthread" \
  118.        "--enable-static" \
  119.        "--enable-thread-safe-client" \
  120.        "--with-client-ldflags=-all-static" \
  121.        "--with-mysqld-ldflags=-all-static" \
  122.        "--enable-assembler" \
  123.        "--without-isam" \
  124.        "--without-innodb" \
  125.        "--without-ndb-debug"
  126. make && make install
  127. useradd mysql -d /data/mysql -s /sbin/nologin
  128. /usr/local/mysql/bin/mysql_install_db --user=mysql
  129. cd /usr/local/mysql
  130. chown -R root:mysql .
  131. chown -R mysql /data/mysql/data
  132. cp share/mysql/my-huge.cnf /etc/my.cnf
  133. cp share/mysql/mysql.server /etc/rc.d/init.d/mysqld
  134. chmod 755 /etc/rc.d/init.d/mysqld
  135. chkconfig --add mysqld
  136. /etc/rc.d/init.d/mysqld start

  137. cd /usr/local/mysql/bin
  138. for i in *; do ln -s /usr/local/mysql/bin/$i /usr/bin/$i; done

  139. cd /usr/local/src

  140. mysqladmin -u root password chenshake


  141. #安装Apache

  142. tar zxvf httpd-2.2.8.tar.gz  
  143. cd httpd-2.2.8
  144. ./configure \
  145.        "--prefix=/usr/local/apache2" \
  146. "--with-included-apr" \
  147.        "--enable-so" \
  148.        "--enable-deflate=shared" \
  149.        "--enable-expires=shared" \
  150.        "--enable-rewrite=shared" \
  151.        "--enable-static-support" \
  152.        "--disable-userdir"
  153. make
  154. make install
  155. cd ..

  156. #安装PHP

  157. tar jxvf php-5.2.6.tar.bz2
  158. cd php-5.2.6
  159. ./configure \
  160. "--prefix=/usr/local/php" \
  161. "--with-apxs2=/usr/local/apache2/bin/apxs" \
  162. "--with-config-file-path=/usr/local/php/etc" \
  163. "--with-mysql=/usr/local/mysql" \
  164. "--with-gd=/usr/local/gd2" \
  165. "--with-libxml-dir=/usr" \
  166. "--with-jpeg-dir" \
  167. "--with-png-dir" \
  168. "--with-freetype-dir" \
  169. "--with-zlib " \
  170. --with-iconv-dir=/usr/local \
  171. "--with-openssl=/usr/local/ssl" \
  172. "--with-curl " \
  173. "--with-curlwrappers " \
  174. "--with-mcrypt" \
  175. "--with-imap=/usr/local/imap-2007b" \
  176. "--with-kerberos" \
  177. "--with-bz2" \
  178. "--enable-soap" \
  179. "--enable-gd-native-ttf" \
  180. "--enable-ftp" \
  181. "--enable-mbstring" \
  182. "--enable-exif" \
  183. "--disable-ipv6" \
  184. "--disable-cgi" \
  185. "--disable-cli"   

  186. make
  187. make install
  188. mkdir /usr/local/php/etc
  189. cp php.ini-dist /usr/local/php/etc/php.ini
  190. cd ..

  191. #安装Zend Optimizer (安装Zend Optimizer过程的最后不要选择重启Apache。)

  192. tar xzvf ZendOptimizer-3.3.3-linux-glibc23-i386.tar.gz
  193. cd ZendOptimizer-3.3.3-linux-glibc23-i386
  194. ./install.sh


  195. ##########################################################################
复制代码
脚本到这里为止,因为zend的设置,我没法自动完成,只能你手动设置,如果谁知道怎么做,麻烦指导指导,注意php.ini 的位置 /usr/local/php/etc/

#设置session的存放位置和修改php上次文件的大小,最大文件25m
  1. cp /usr/local/Zend/etc/php.ini /usr/local/Zend/etc/php.ini.save
  2. sed -i -e '991 s/;//' /usr/local/Zend/etc/php.ini
  3. sed -i 's/post_max_size = 8M/ post_max_size = 30M/g' /usr/local/Zend/etc/php.ini
  4. sed -i 's/upload_max_filesize = 2M/ upload_max_filesize = 25M/g' /usr/local/Zend/etc/php.ini
  5. cd /usr/local/src
复制代码
六:配置apache PHP

创建apache的启动脚本,apache编译包里带的那个启动脚本,有一个缺点,启动和停止没有任何提示,所以就用下面这个,比较方便。
  1. vi /etc/init.d/httpd
复制代码
  1. ###################################

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

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

  14. if [ -f /etc/sysconfig/httpd ]; then
  15.         . /etc/sysconfig/httpd
  16. fi

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

  20. # Path to the apachectl script, server binary, and short-form for messages.
  21. apachectl=/usr/local/apache2/bin/apachectl
  22. httpd=/usr/local/apache2/bin/httpd
  23. pid=/usr/local/apache2/logs/httpd.pid
  24. prog=httpd
  25. RETVAL=0




  26. # The semantics of these two functions differ from the way apachectl does
  27. # things -- attempting to start while running is a failure, and shutdown
  28. # when not running is also a failure.   So we just do it the way init scripts
  29. # are expected to behave here.
  30. start() {
  31.          echo -n [code]###################################

  32. #!/bin/bash
  33. #
  34. # Startup script for the Apache Web Server
  35. #
  36. # chkconfig: - 85 15
  37. # description: Apache is a World Wide Web server.   It is used to serve \
  38. #               HTML files and CGI.
  39. # processname: httpd
  40. # pidfile: /usr/local/apache2/logs/httpd.pid
  41. # config: /usr/local/apache2/conf/httpd.conf

  42. # Source function library.
  43. . /etc/rc.d/init.d/functions

  44. if [ -f /etc/sysconfig/httpd ]; then
  45.         . /etc/sysconfig/httpd
  46. fi

  47. # This will prevent initlog from swallowing up a pass-phrase prompt if
  48. # mod_ssl needs a pass-phrase from the user.
  49. INITLOG_ARGS=""

  50. # Path to the apachectl script, server binary, and short-form for messages.
  51. apachectl=/usr/local/apache2/bin/apachectl
  52. httpd=/usr/local/apache2/bin/httpd
  53. pid=/usr/local/apache2/logs/httpd.pid
  54. prog=httpd
  55. RETVAL=0




  56. # The semantics of these two functions differ from the way apachectl does
  57. # things -- attempting to start while running is a failure, and shutdown
  58. # when not running is also a failure.   So we just do it the way init scripts
  59. # are expected to behave here.
  60. start() {
  61.          echo -n [        DISCUZ_CODE_10        ]quot;Starting $prog: "
  62.         daemon $httpd $OPTIONS
  63.          RETVAL=$?
  64.          echo
  65.          [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
  66.         return $RETVAL
  67. }
  68. stop() {
  69.          echo -n [        DISCUZ_CODE_10        ]quot;Stopping $prog: "
  70.         killproc $httpd
  71.          RETVAL=$?
  72.          echo
  73.          [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
  74. }
  75. reload() {
  76.          echo -n [        DISCUZ_CODE_10        ]quot;Reloading $prog: "
  77.         killproc $httpd -HUP
  78.          RETVAL=$?
  79.          echo
  80. }

  81. # See how we were called.
  82. case "$1" in
  83.    start)
  84.         start
  85.         ;;
  86.   stop)
  87.         stop
  88.         ;;
  89.   status)
  90.         status $httpd
  91.          RETVAL=$?
  92.          ;;
  93.   restart)
  94.         stop
  95.          start
  96.         ;;
  97.   condrestart)
  98.          if [ -f $pid ] ; then
  99.                  stop
  100.                  start
  101.          fi
  102.         ;;
  103.   reload)
  104.         reload
  105.         ;;
  106.   graceful|help|configtest|fullstatus)
  107.         $apachectl $@
  108.         RETVAL=$?
  109.          ;;
  110.    *)
  111.          echo [        DISCUZ_CODE_10        ]quot;Usage: $prog {start|stop|restart|condrestart|reload|status"
  112.         echo [        DISCUZ_CODE_10        ]quot;|fullstatus|graceful|help|configtest}"
  113.         exit 1
  114. esac

  115. exit $RETVAL

  116. ###########################
复制代码
quot;Starting $prog: "
        daemon $httpd $OPTIONS
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && touch /var/lock/subsys/httpd
        return $RETVAL
}
stop() {
         echo -n [        DISCUZ_CODE_10        ]quot;Stopping $prog: "
        killproc $httpd
         RETVAL=$?
         echo
         [ $RETVAL = 0 ] && rm -f /var/lock/subsys/httpd $pid
}
reload() {
         echo -n [        DISCUZ_CODE_10        ]quot;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 $pid ] ; then
                 stop
                 start
         fi
        ;;
  reload)
        reload
        ;;
  graceful|help|configtest|fullstatus)
        $apachectl $@
        RETVAL=$?
         ;;
   *)
         echo [        DISCUZ_CODE_10        ]quot;Usage: $prog {start|stop|restart|condrestart|reload|status"
        echo [        DISCUZ_CODE_10        ]quot;|fullstatus|graceful|help|configtest}"
        exit 1
esac

exit $RETVAL

###########################[/code]设置可运行和开机启动
  1. chmod +x /etc/rc.d/init.d/httpd
  2. chkconfig --add httpd
  3. chkconfig --level 3 httpd on
复制代码
配置apache
  1. groupadd www -g 48
  2. useradd -u 48 -g www www
  3. mkdir -p /data/www/wwwroot/linux.com
  4. mkdir -p /data/www/wwwroot/test.com
  5. mkdir -p /data/logs
  6. chmod +w /data/www/wwwroot
  7. chown -R www:www /data/www/wwwroot
  8. cp /usr/local/apache2/conf/httpd.conf /usr/local/apache2/conf/httpd.conf.save
复制代码
编辑httpd.conf
  1. sed -i -e '121 s/^/#/' -i -e '122 s/^/#/' /usr/local/apache2/conf/httpd.conf
  2. sed -i -e "s/User daemon/User www/" -i -e "s/Group daemon/Group www/" /usr/local/apache2/conf/httpd.conf
  3. sed -i 's/DirectoryIndex index.html/ DirectoryIndex index.php index.html index.htm/g' /usr/local/apache2/conf/httpd.conf
  4. sed -i -e '101 s/^#//g' -i -e '374 s/^#//g' -i -e '389 s/^#//g' -i -e '392 s/^#//g' -i -e '401 s/^#//g' /usr/local/apache2/conf/httpd.conf
  5. sed -i "58 s/^/AddType application\/x-httpd-php .php/" /usr/local/apache2/conf/httpd.conf
复制代码
编辑php.ini
  1. cp /usr/local/php/etc/php.ini /usr/local/php/etc/php.ini.save
  2. sed -i '205 s#;open_basedir =#open_basedir = /data/www/wwwroot:/tmp#g' /usr/local/php/etc/php.ini
  3. sed -i '/expose_php/s/On/Off/' /usr/local/php/etc/php.ini
  4. sed -i '/display_errors/s/On/Off/' /usr/local/php/etc/php.ini
复制代码
配置虚拟主机

备份相关配置文件
  1. mv /usr/local/apache2/conf/extra/httpd-vhosts.conf /usr/local/apache2/conf/extra/httpd-vhosts.conf.save
  2. mv /usr/local/apache2/conf/extra/httpd-default.conf /usr/local/apache2/conf/extra/httpd-default.conf.save
  3. mv /usr/local/apache2/conf/extra/httpd-mpm.conf /usr/local/apache2/conf/extra/httpd-mpm.conf.save
复制代码
创建3个apache相关的文件
  1. vi /usr/local/apache2/conf/extra/httpd-vhosts.conf
复制代码
  1. NameVirtualHost *:80

  2. <VirtualHost *:80>
  3.     ServerAdmin shake.chen@gmail.com
  4.     DocumentRoot "/data/www/wwwroot/test.com"
  5.     ServerName test.com
  6.     ServerAlias bbs.test.com
  7.     ErrorLog "logs/test.com-error_log"
  8.     CustomLog "|/usr/local/cronolog/sbin/cronolog /data/logs/access_www.test.com.%Y%m%d" combined
  9. </VirtualHost>

  10. <VirtualHost *:80>
  11.     ServerAdmin shake.chen@gmail.com
  12.     DocumentRoot "/data/www/wwwroot/linux.com"
  13.     ServerName linux.com
  14.     ServerAlias bbs.linux.com
  15.     ErrorLog "logs/linux.com-error_log"
  16.     CustomLog "|/usr/local/cronolog/sbin/cronolog /data/logs/access_www.linux.com.%Y%m%d" combined
  17. </VirtualHost>
复制代码
  1. vi /usr/local/apache2/conf/extra/httpd-default.conf
复制代码
  1. Timeout 15
  2. KeepAlive Off
  3. MaxKeepAliveRequests 50
  4. KeepAliveTimeout 5
  5. UseCanonicalName Off
  6. AccessFileName .htaccess
  7. ServerTokens Prod
  8. ServerSignature Off
  9. HostnameLookups Off
复制代码
  1. vi /usr/local/apache2/conf/extra/httpd-mpm.conf
复制代码
  1. <IfModule mpm_prefork_module>
  2.     ServerLimit         2000
  3.     StartServers          10
  4.     MinSpareServers       10
  5.     MaxSpareServers      15
  6.     MaxClients          2000
  7.     MaxRequestsPerChild   10000
  8. </IfModule>
复制代码
七:测试


修改本地hosts文件
192.168.1.200    www.test.com

启动Apache
  1. service httpd start
复制代码
测试php
  1. cd /data/www/wwwroot/test.com
  2. vi info.php
复制代码
  1. <?

  2. phpinfo()

  3. ?>
复制代码
这个时候 http://192.168.1.200/info.php 或者 http://www.test.com/info.php 就可以看到php的信息。


安装phpadmin
  1. cd /usr/local/src
  2. tar zxvf phpMyAdmin-2.11.8.1-all-languages-utf-8-only.tar.gz
  3. cp -rf phpMyAdmin-2.11.8.1-all-languages-utf-8-only /data/www/wwwroot/test.com/phpmyadmin
  4. cd /data/www/wwwroot/test.com/phpmyadmin

  5. cp config.sample.inc.php config.inc.php

  6. sed -i -e "/^\$cfg\['blowfish_secret'\]/{ s@'';@'88888888888888888';@; }" config.inc.php
复制代码
这个时候,你就可以通过 http://192.168.1.200/phpmyadmin 或者http://www.test.com/phpmyadmin 来进行数据库管理, 我上面已经给mysql设置的密码。

user:root
password:chenshake




安装sugarcrm

sugarcrm的邮件模块需要用到imap,ssl,所以我编译的时候,需要吧imap,curl模块编译进去.
  1. cd /usr/local/src
  2. unzip SugarCE-5.1.0.zip
  3. mv SugarCE-Full-5.1.0/ /data/www/wwwroot/test.com/sugarcrm
  4. chmod -R 777 /data/www/wwwroot/test.com/sugarcrm/
复制代码
这个时候,你通过连接访问一步一步安装就基本没有问题了。
alan0879 发表于 2008-11-27 12:43:45 | 显示全部楼层
写的不错
回复

使用道具 举报

media008 发表于 2008-11-29 14:04:06 | 显示全部楼层
写的不错!!!支持
回复

使用道具 举报

abcnic1 发表于 2008-12-1 11:36:56 | 显示全部楼层
谢谢分享
回复

使用道具 举报

spleen 发表于 2008-12-31 12:10:23 | 显示全部楼层
嘿,樓主辛苦了,學習了
回复

使用道具 举报

mukden 发表于 2008-12-31 12:38:14 | 显示全部楼层
不错,支持楼主,学习了。
回复

使用道具 举报

usually023 发表于 2009-2-17 08:41:04 | 显示全部楼层
这么辛苦写的   顶上去
回复

使用道具 举报

tl20020313 发表于 2009-3-29 11:50:22 | 显示全部楼层
做个记号,下次看
回复

使用道具 举报

最盲流 发表于 2009-3-29 13:01:41 | 显示全部楼层
多谢楼主的分享了哦·1~   学习了哈 ~!
回复

使用道具 举报

集思网络 发表于 2009-4-1 14:22:28 | 显示全部楼层
((mk13))
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-11-17 02:41 , Processed in 0.065255 second(s), 5 queries , Gzip On, Redis On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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