首页 > 数据库技术 > 详细

Centos+mysql+apache(http)+php+wordpress搭建个人站点

时间:2015-07-07 19:39:23      阅读:160      评论:0      收藏:0      [点我收藏+]

[root@localhost data]# 安装次序很重要:apr --> apr-util --> apache --> MySQL -->php--->Xcache ——>wordpress

架构:LAMP一直很受大众喜欢,完全能满足基本需求。当访问量大时可以尝试LNMP架构,做到前端负载均衡访问。

下载:各安装包已放到云盘上,http://pan.baidu.com/s/1gd1uWTX

一、安装编译apache

1 编译安装apr

  1. [root@localhost data]#tar xf apr-1.4.6.tar.bz2 
  2. [root@localhost data]#cd apr-1.4.6 
  3. [root@localhost apr-1.4.6]#./configure --prefix=/data/apr 
  4. #####软件包安装的路径统一放在第三方软件位置:/data/ 
  5. [root@localhost apr-1.4.6]#make  
  6. [root@localhost apr-1.4.6]#make install 

2 编译安装apr-util

  1. [root@localhost data]#tar xf apr-util-1.5.2.tar.bz2 
  2. [root@localhost data]#cd apr-util-1.5.2 
  3. [root@localhost apr-util-1.5.2]#./configure –prefix=/data/apr-util –with-apr=/data/apr 
  4. ####指定apr-util和apr安装路径 

3 安装pcre-devel软件包

  1. [root@localhost data]# yum install pcre-devel

4 编译安装httpd-2.4.4

  1. [root@localhost data]# tar xf httpd-2.4.4.tar.bz2 
  2. [root@localhost data]# cd httpd-2.4.4 
  3. [root@localhost httpd-2.4.4]#./configure --prefix=/data/apache –sysconfdir=/etc/httpd --enable-so --enable-ssl --enable-cgi --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/data/apr-util --enable-mpms-shared=all --with-mpm=event 
  4. 说明:--prefix=/data/apache    ####httpd安装路径 
  5. --sysconfdir=/etc/httpd      ####系统配置文件目录路径 
  6. --enable-so       ######支持共享模块功能 
  7. --enable-ssl            #####支持ssl功能 
  8. --enable-cgi       ####支持cgi功能 
  9. --enable-rewrite    ####支持重写功能 
  10. --with-zlib         #####支持扩展库文件功能 
  11. --with-pcre       #####支持pcre功能 
  12. --with-apr=/data/apr       ######指定apr安装路径 
  13. --with-apr-util=/data/apr-util     #####指定apr-util安装路径 
  14. --enable-mpms-shared=all      #####表示此平台的mpm模块都会被安装 
  15. --with-mpm=event       #####特指定mpm模块为event,mpm模块可以在配置文件中修改 
  16. [root@localhost httpd-2.4.4]#make 
  17. [root@localhost httpd-2.4.4]#setenforce 0       #####由于web服务是受selinux控制会导致系统运行不起来,要把selinux的功能关掉 
  18. [root@localhost httpd-2.4.4]#make install 

5 修改httpd的主配置文件,设置其pid文件的路径

  1. [root@localhost httpd-2.4.4]#vim /etc/httpd/httpd.conf 
  2. 添加内容:PidFile  “/var/run/httpd.pid” 
  3. 保存退出 
6 为httpd提供服务脚本
  • [root@localhost data]#cp /httpd-2.4.4/build/rpm/httpd.init  /etc/rc.d/init.d/httpd
  • [root@localhost data]#vim /etc/rc.d/init.d/httpd
  • 说明:修改配置文件
       1:  #!/bin/bash
       2:  #
       3:  # Licensed to the Apache Software Foundation (ASF) under one or more
       4:  # contributor license agreements.  See the NOTICE file distributed with
       5:  # this work for additional information regarding copyright ownership.
       6:  # The ASF licenses this file to You under the Apache License, Version 2.0
       7:  # (the "License"); you may not use this file except in compliance with
       8:  # the License.  You may obtain a copy of the License at
       9:  #
      10:  #     http://www.apache.org/licenses/LICENSE-2.0
      11:  #
      12:  # Unless required by applicable law or agreed to in writing, software
      13:  # distributed under the License is distributed on an "AS IS" BASIS,
      14:  # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
      15:  # See the License for the specific language governing permissions and
      16:  # limitations under the License.
      17:  #
      18:  #
      19:  # httpd        Startup script for the Apache Web Server
      20:  #
      21:  # chkconfig: - 85 15
      22:  # description: The Apache HTTP Server is an efficient and extensible  \
      23:  #             server implementing the current HTTP standards.
      24:  # processname: httpd
      25:  # pidfile: /var/run/httpd.pid
      26:  # config: /etc/httpd/httpd.conf
      27:  ### BEGIN INIT INFO
      28:  # Provides: httpd
      29:  # Required-Start: $local_fs $remote_fs $network $named
      30:  # Required-Stop: $local_fs $remote_fs $network
      31:  # Should-Start: distcache
      32:  # Short-Description: start and stop Apache HTTP Server
      33:  # Description: The Apache HTTP Server is an extensible server 
      34:  #  implementing the current HTTP standards.
      35:  ### END INIT INFO
      36:   
      37:  # Source function library.
      38:  . /etc/rc.d/init.d/functions
      39:   
      40:  # What were we called? Multiple instances of the same daemon can be
      41:  # created by creating suitably named symlinks to this startup script
      42:  prog=$(basename $0 | sed -e ‘s/^[SK][0-9][0-9]//‘)
      43:   
      44:  if [ -f /etc/sysconfig/${prog} ]; then
      45:          . /etc/sysconfig/${prog}
      46:  fi
      47:  # Start httpd in the C locale by default.
      48:  HTTPD_LANG=${HTTPD_LANG-"C"}
      49:   
      50:  # This will prevent initlog from swallowing up a pass-phrase prompt if
      51:  # mod_ssl needs a pass-phrase from the user.
      52:  INITLOG_ARGS=""
      53:   
      54:  # Set HTTPD=/usr/sbin/httpd.worker in /etc/sysconfig/httpd to use a server
      55:  # with the thread-based "worker" MPM; BE WARNED that some modules may not
      56:  # work correctly with a thread-based MPM; notably PHP will refuse to start.
      57:  apachectl=/database/apache/bin/apachectl
      58:  httpd=${HTTPD-/database/apache/bin/httpd}
      59:  pidfile=${PIDFILE-/var/run/${prog}.pid}
      60:  lockfile=${LOCKFILE-/var/lock/subsys/${prog}}
      61:  RETVAL=0
      62:   
      63:  # check for 1.3 configuration
      64:  check13 () {
      65:          CONFFILE=/etc/httpd/httpd.conf
      66:          GONE="(ServerType|BindAddress|Port|AddModule|ClearModuleList|"
      67:          GONE="${GONE}AgentLog|RefererLog|RefererIgnore|FancyIndexing|"
      68:          GONE="${GONE}AccessConfig|ResourceConfig)"
      69:          if grep -Eiq "^[[:space:]]*($GONE)" $CONFFILE; then
      70:                  echo
      71:                  echo 1>&2 " Apache 1.3 configuration directives found"
      72:                  echo 1>&2 " please read @docdir@/migration.html"
      73:                  failure "Apache 1.3 config directives test"
      74:                  echo
      75:                  exit 1
      76:          fi
      77:  }
      78:  # The semantics of these two functions differ from the way apachectl does
      79:  # things -- attempting to start while running is a failure, and shutdown
      80:  # when not running is also a failure.  So we just do it the way init scripts
      81:  # are expected to behave here.
      82:  start() {
      83:          echo -n $"Starting $prog: "
      84:          check13 || exit 1
      85:          LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
      86:          RETVAL=$?
      87:          echo
      88:          [ $RETVAL = 0 ] && touch ${lockfile}
      89:          return $RETVAL
      90:  }
      91:  stop() {
      92:          echo -n $"Stopping $prog: "
      93:          killproc -p ${pidfile} -d 10 $httpd
      94:          RETVAL=$?
      95:          echo
      96:          [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}
      97:  }
      98:  reload() {
      99:          echo -n $"Reloading $prog: "
     100:          check13 || exit 1
     101:          killproc -p ${pidfile} $httpd -HUP
     102:          RETVAL=$?
     103:          echo
     104:  }
     105:   
     106:  # See how we were called.
     107:  case "$1" in
     108:    start)
     109:          start
     110:          ;;
     111:    stop)
     112:          stop
     113:          ;;
     114:    status)
     115:          if ! test -f ${pidfile}; then
     116:              echo $prog is stopped
     117:              RETVAL=3
     118:          else
     119:              status -p ${pidfile} $httpd
     120:              RETVAL=$?
     121:          fi
     122:          ;;
     123:    restart)
     124:          stop
     125:          start
     126:          ;;
     127:    condrestart)
     128:          if test -f ${pidfile} && status -p ${pidfile} $httpd >&/dev/null; then
     129:                  stop
     130:                  start
     131:          fi
     132:          ;;
     133:    reload)
     134:          reload
     135:          ;;
     136:    configtest)
     137:          LANG=$HTTPD_LANG $httpd $OPTIONS -t
     138:          RETVAL=$?
     139:          ;;
     140:    graceful)
     141:          echo -n $"Gracefully restarting $prog: "
     142:          LANG=$HTTPD_LANG $httpd $OPTIONS -k $@
     143:          RETVAL=$?
     144:          echo
     145:          ;;
     146:    *)
     147:          echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|graceful|help|configtest}"
     148:          exit 1
     149:  esac
     150:  exit $RETVAL

7 为httpd提供服务脚本

   1:  [root@localhost httpd-2.4.4]#chmod +x /etc/rc.d/init.d/httpd