LAMP架构实现网站动静分离及流行博客论坛安装实验


静分离能有效提升站点访问效率,此时apache工作在反向代理模式。PHP不在作为apache的模块。而是以独立服务器的方式运行。两者之间通过fcgi机制建立通讯。

Ubuntu 14.04 配置 LAMP+phpMyAdmin PHP(5.5.9)开发环境 

Windows 7下硬盘安装Ubuntu 14.10图文教程

U盘安装Ubuntu 14.10

Ubuntu 14.10 正式发布下载

Ubuntu 14.04 LTS 如何升级到 Ubuntu 14.10 

Ubuntu 14.10 下安装 LAMP 服务图文详解 

.安装DNS服务实现域名解析

1.安装bind

[root@www ~]# yum install bind

 

2.配置named主配置文件

[root@www ~]# vim /etc/named.conf

//

// named.conf

//

// Provided by Red Hat bind package toconfigure the ISC BIND named(8) DNS

// server as a caching only nameserver (asa localhost DNS resolver only).

//

// See /usr/share/doc/bind*/sample/ forexample named configuration files.

//

 

options {

//     listen-on port 53 { 127.0.0.1; };

//     listen-on-v6 port 53 { ::1; };

       directory      "/var/named";

       dump-file      "/var/named/data/cache_dump.db";

       statistics-file "/var/named/data/named_stats.txt";

       memstatistics-file "/var/named/data/named_mem_stats.txt";

//     allow-query    { localhost; };

       recursion yes;

 

//     dnssec-enable yes;

//     dnssec-validation yes;

//     dnssec-lookaside auto;

 

       /* Path to ISC DLV key */

       /*bindkeys-file "/etc/named.iscdlv.key";

 

       managed-keys-directory "/var/named/dynamic";

       */

};

 

logging {

       channel default_debug {

               file"data/named.run";

                severity dynamic;

       };

};

 

zone "." IN {

       type hint;

       file "named.ca";

};

 

include"/etc/named.rfc1912.zones";

include "/etc/named.root.key";

 

3.配置区域配置文件

1 2 3 4 5 [root@www ~]# vim /etc/named.rfc1912.zones zone "stu31.com" IN {        type master;        file "stu31.com.zone"; };

 

 

4.配置区域解析库文件(正向)

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 [root@www ~]# vim /var/named/stu31.com.zone $TTL 600 $ORIGIN stu31.com. @      IN      SOA     ns1.stu31.com.  root@stu31.com (                         20141219                         1M                         2H                         3D                         6M ) @      IN      NS      ns1        IN      MX   5 mail ns1    IN      A       172.16.31.20 www    IN      A       172.16.31.20 bbs    IN      A       172.16.31.20 pmp    IN      A       172.16.31.20 mail   IN      A       172.16.31.20 pop3   IN      CNAME   mail iamp4  IN      CNAME   mail

更改权限及属主属组

1 2 [root@www ~]# chmod 640/var/named/stu31.com.zone [root@www ~]# chown :named/var/named/stu31.com.zone

 

5.检查语法

1 2 3 4 [root@www ~]# named-checkconf [root@www ~]# named-checkzone stu31.com/var/named/stu31.com.zone zone stu31.com/IN: loaded serial 20141219 OK

 

6.启动named服务

1 2 3 [root@www ~]# service named start Generating /etc/rndc.key:                                  [  OK  ] Starting named:                                           [  OK  ]

 

将本地网络的DNS服务器地址指向172.16.31.20

1 2 [root@www ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 DNS=172.16.31.20

 

测试完全区域:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 [root@www ~]# dig -t axfr stu31.com @172.16.31.20    ; <<>> DiG9.8.2rc1-RedHat-9.8.2-0.30.rc1.el6 <<>> -t axfr stu31.com@172.16.31.20 ;; global options: +cmd stu31.com.              600     IN     SOA     ns1.stu31.com.root\@stu31.com.stu31.com. 2014121903 60 7200 259200 360 stu31.com.              600     IN     NS      ns1.stu31.com. stu31.com.              600     IN     MX      5 mail.stu31.com. bbs.stu31.com.          600     IN     A       172.16.31.20 iamp4.stu31.com.        600    IN      CNAME   mail.stu31.com. mail.stu31.com.         600    IN      A       172.16.31.20 ns1.stu31.com.          600     IN     A       172.16.31.20 pmp.stu31.com.          600     IN     A       172.16.31.20 pop3.stu31.com.         600    IN      CNAME   mail.stu31.com. web.stu31.com.          600     IN     A       172.16.31.20 www.stu31.com.          600     IN     A       172.16.31.20 stu31.com.              600     IN     SOA     ns1.stu31.com.root\@stu31.com.stu31.com. 2014121903 60 7200 259200 360 ;; Query time: 2 msec ;; SERVER: 172.16.31.20#53(172.16.31.20) ;; WHEN: Mon Dec 22 08:31:22 2014 ;; XFR size: 12 records (messages 1, bytes304)

 

.源码安装httpd-2.4.10

 

1.安装aprapr-util

1 2 3 4 [root@www ~]# tar xf apr-1.5.0.tar.bz2 [root@www ~]# cd apr-1.5.0 [root@www apr-1.5.0]# ./configure--prefix=/usr/local/apr [root@www apr-1.5.0]# make && makeinstall

 

1 2 3 4 5 [root@www apr-1.5.0]# cd .. [root@www ~]# tar xf apr-util-1.5.3.tar.bz2 [root@www ~]# cd apr-util-1.5.3 [root@www apr-util-1.5.3]# ./configure--prefix=/usr/local/apr-util --with-apr=/usr/local/apr [root@www apr-util-1.5.3]# make &&make install

 

设置aprapr-util成为系统环境变量

1 2 [root@www apr-util-1.5.3]# vim/etc/profile.d/apr.sh exportPATH=/usr/local/apr/bin:/usr/local/apr-util/bin:$PATH

 

2.源码安装httpd

1 2 3 [root@www ~]# tar xf httpd-2.4.10.tar.bz2 [root@www ~]# cd httpd-2.4.10 [root@www httpd-2.4.10]# ./configure--prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-rewrite --with-z --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util --enable-modules=most --enable-mpms-shared=all --with-mpm=event

编译参数注释

--prefix=        #指定安装到/usr/local/apache路径下

--sysconfdir=    #指定配置文件安装到/etc/httpd24

--enable=so      #支持动态装卸载模块

--enable-ssl    #支持https加密传输

--enable-rewrite #支持URL重写

--enable-cgi    #支持cgi格式脚本

--with-z         #支持zlib压缩

--with-pcre      #支持扩展正则表达式

--with-apr      #指定apr安装位置

--with-apr-util  #指定apr-util安装位置

--enable-mpms-shared  #mpm三种模式以共享模块的方式编译进去

--enable-mpm    #httpd启动是默认是开启event模式

--enable-rewrite #支持反向代理

 

安装:

1 [root@www httpd-2.4.10]#make &&make install

 

3.创建httpd服务脚本(因为系统已安装httpd,我们需要安装到其他路径,服务脚本也一样要更改名称,与原httpd服务区分)

[root@www httpd-2.4.10]# cp /etc/rc.d/init.d/httpd httpd24

[root@www httpd-2.4.10]# vim httpd24

#!/bin/bash

#

# httpd        Startup script for the Apache HTTPServer

#

# chkconfig: - 85 15

# description: The Apache HTTP Server is anefficient and extensible  \

#              server implementing the currentHTTP standards.

# processname: httpd

# config: /etc/httpd/conf/httpd.conf

# config: /etc/sysconfig/httpd

# pidfile: /var/run/httpd/httpd.pid

#

### BEGIN INIT INFO

# Provides: httpd

# Required-Start: $local_fs $remote_fs$network $named

# Required-Stop: $local_fs $remote_fs$network

# Should-Start: distcache

# Short-Description: start and stop ApacheHTTP Server

# Description: The Apache HTTP Server is anextensible server

# implementing the current HTTP standards.

### END INIT INFO

 

# Source function library.

. /etc/rc.d/init.d/functions

 

#if [ -f /etc/sysconfig/httpd ]; then

#       . /etc/sysconfig/httpd

#fi

 

# Start httpd in the C locale by default.

HTTPD_LANG=${HTTPD_LANG-"C"}

 

# This will prevent initlog from swallowingup a pass-phrase prompt if

# mod_ssl needs a pass-phrase from theuser.

INITLOG_ARGS=""

 

# Set HTTPD=/usr/sbin/httpd.worker in/etc/sysconfig/httpd to use a server

# with the thread-based "worker"MPM; BE WARNED that some modules may not

# work correctly with a thread-based MPM;notably PHP will refuse to start.

 

# Path to the apachectl script, serverbinary, and short-form for messages.

apachectl=/usr/local/apache/bin/apachectl

httpd=${HTTPD-/usr/local/apache/bin/httpd}

prog=httpd

pidfile=${PIDFILE-/var/run/httpd/httpd.pid}

lockfile=${LOCKFILE-/var/lock/subsys/httpd}

RETVAL=0

STOP_TIMEOUT=${STOP_TIMEOUT-10}

 

# The semantics of these two functionsdiffer from the way apachectl does

# things -- attempting to start whilerunning 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: "

       LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS

       RETVAL=$?

       echo

       [ $RETVAL = 0 ] && touch ${lockfile}

       return $RETVAL

}

 

# When stopping httpd, a delay (of default10 second) is required

# before SIGKILLing the httpd parent; thisgives enough time for the

# httpd parent to SIGKILL any errantchildren.

stop() {

       echo -n $"Stopping $prog: "

       killproc -p ${pidfile} -d ${STOP_TIMEOUT} $httpd

       RETVAL=$?

       echo

       [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

}

reload() {

   echo -n $"Reloading $prog: "

   if ! LANG=$HTTPD_LANG $httpd $OPTIONS -t >&/dev/null; then

       RETVAL=6

       echo $"not reloading due to configuration syntax error"

       failure $"not reloading $httpd due to configuration syntaxerror"

   else

       # Force LSB behaviour from killproc

       LSB=1 killproc -p ${pidfile} $httpd -HUP

       RETVAL=$?

       if [ $RETVAL -eq 7 ]; then

           failure $"httpd shutdown"

       fi

   fi

   echo

}

 

# See how we were called.

case "$1" in

 start)

       start

       ;;

 stop)

       stop

       ;;

 status)

       status -p ${pidfile} $httpd

       RETVAL=$?

       ;;

 restart)

       stop

       start

       ;;

 condrestart|try-restart)

       if status -p ${pidfile} $httpd >&/dev/null; then

                stop

                start

       fi

        ;;

 force-reload|reload)

       reload

       ;;

 graceful|help|configtest|fullstatus)

       $apachectl $@

       RETVAL=$?

       ;;

  *)

       echo $"Usage: $prog{start|stop|restart|condrestart|try-restart|force-reload|reload|status|fullstatus|graceful|help|configtest}"

       RETVAL=2

esac

 

exit $RETVAL

复制脚本到服务脚本存放路径:

[root@www httpd-2.4.10]# cp httpd24  /etc/rc.d/init.d/httpd24

httpd24服务加入系统启动:

1 2 3 [root@www httpd-2.4.10]# chkconfig --listhttpd24 service httpd24 supports chkconfig, but isnot referenced in any runlevel (run 'chkconfig --add httpd24') [root@www httpd-2.4.10]# chkconfig --addhttpd24

4.启动httpd24服务

1 2 [root@www httpd-2.4.10]# service httpd24start Starting httpd:                                           [  OK  ]

查看服务监听端口:

1 2 [root@www ~]# ss -tunl |grep 80 tcp   LISTEN     0      128                   :::80                   :::*

测试:

1 2 [root@www ~]# curl http://172.16.31.20 <html><body><h1>Itworks!</h1></body></html>

 httpd-2.4.10安装完毕 

mysql主机本地网络的DNS服务器地址指向172.16.31.20

1 2 [root@mysql ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 DNS=172.16.31.20

更多详情见请继续阅读下一页的精彩内容:

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 下一页

相关内容