马哥教育网络19期+第十二周课程练习

1、请描述一次完整的http请求处理过程;

a.向根域名服务器请求解析域名,然后根服务器返回相应的IP信息;
b.用户的Web浏览器向服务器端的80端口通过三次握手建立TCP连接;
c.建立完TCP连接后发送HTTP请求,请求的格式包括请求方法、URL和协议版本号,方法有GET、HEAD、POST、PUT、DELETE、OPTIONS、TRACE,如:
    起始行:如 GET / HTTP/1.0 (请求的方法  请求的URL 请求所使用的协议)
    头部信息:User-Agent  Host等成对出现的值
    主体
d.服务器向客户端相应http的头信息,客户端收到后确认,然后http服务器发送数据;
e.浏览器接收到数据后,解析数据并通过浏览器把画面呈现给用户;
f.数据传送完成后,四次断开TCP连接;

2、httpd所支持的处理模型有哪些,他们的分别使用于哪些环境。

工作模型一共有三种:prefork、worker、event
prefork:多进程模型,每个进程响应一个请求。一个主进程:负责生成n个子进程,子进程也称为工作进程,每个子进程处理一个用户请求;即便没有用户请求,也会预先生成多个空闲进程,
         随时等待请求到达;最大不会超过1024个;
worker:多线程模型,每个线程响应一个请求;一个主进程:生成多个子进程,每个子进程负责生个多个线程,每个线程响应一个请求;
event:事件驱动模型,每个线程响应n个请求;一个主进程:生成m个子进程,每个子进程直接响应n个请求;

适合的场景:
perfork:它适合于没有线程安全库,需要避免线程兼容性问题的系统;
worker:适合内存占用量比较小,适合高流量的http服务器。缺点是假如一个线程崩溃,整个进程就会连同其任何线程一起”死掉”;
总的来说,prefork方式速度要稍高于worker,然而它需要的cpu和memory资源也稍多于woker。

3、源码编译安装LAMP环境(基于wordpress程序),并写出详细的安装、配置、测试过程。

[root@Hao ~]# cd /usr/local/src
[root@Hao src]# ls
apr-1.5.2.tar.bz2       httpd-2.4.23.tar.bz2                 php-5.5.38.tar.gz
apr-util-1.5.4.tar.bz2  mysql-5.5.50-linux2.6-x86_64.tar.gz
httpd2.4的版本需要新版的apr和apr-util,所以需要编译安装apr和apr-util
[root@Hao src]# tar xf apr-1.5.2.tar.bz2 
[root@Hao src]# cd apr-1.5.2
[root@Hao apr-1.5.2]# ./configure --prefix=/usr/local/apr  
[root@Hao apr-1.5.2]# make && make install
[root@Hao apr-1.5.2]# cd ..
[root@Hao src]# tar xf apr-util-1.5.4.tar.bz2 
[root@Hao src]# cd apr-util-1.5.4
[root@Hao apr-util-1.5.4]# ./configure --prefix=/usr/local/apr-util --with-apr=/usr/local/apr 
[root@Hao apr-util-1.5.4]# make && make install

–prefix是指定安装路径 –with-apr是安装apr-util时指定apr的安装目录

下面编译安装httpd

[root@Hao apr-util-1.5.4]# yum -y install pcre-devel
[root@Hao apr-util-1.5.4]# yum -y install openssl-devel
[root@Hao src]# tar xf httpd-2.4.23.tar.bz2 
[root@Hao src]# cd httpd-2.4.23
[root@Hao httpd-2.4.23]# ./configure --prefix=/usr/local/apache --sysconfdir=/etc/httpd24 --enable-so --enable-ssl --enable-cgi 
                         --enable-rewrite --with-zlib --with-pcre --with-apr=/usr/local/apr --with-apr-util=/usr/local/apr-util 
                         --enable-modules=most --enable-mpms-shared=all --with-mpm=event
[root@Hao httpd-2.4.23]# make && make install

修改httpd主配置文件,设置pid文件的路径,编辑/etc/httpd/httpd.conf,添加内容如下:

PidFile  "var/run/httpd.pid"

提供SysV服务脚本/etc/rc.d/init.d/httpd,内容如下:

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: - 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#        HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# 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 swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
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, server binary, 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.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon --pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  killproc -p ${pidfile} -d 10 $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=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
        status -p ${pidfile} $httpd
  RETVAL=$?
  ;;
  restart)
  stop
  start
  ;;
  condrestart)
  if [ -f ${pidfile} ] ; then
    stop
    start
  fi
  ;;
  reload)
        reload
  ;;
  graceful|help|configtest|fullstatus)
  $apachectl $@
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  exit 1
esac

exit $RETVAL

然后给脚本执行权限:
[root@Hao ~]# chmod +x /etc/rc.d/init.d/httpd
[root@Hao ~]# chkconfig --add httpd
[root@Hao ~]# service httpd start
[root@Hao ~]# chkconfig httpd on

安装mysql服务

[root@Hao ~]# groupadd -r mysql
[root@Hao ~]# useradd -g mysql -r -s /sbin/nologin -M -d /mydata/data mysql
[root@Hao ~]# chown -R mysql:mysql /mydata/data
[root@Hao src]# tar xf mysql-5.5.50-linux2.6-x86_64.tar.gz 
[root@Hao src]# ln -sv mysql-5.5.50-linux2.6-x86_64 mysql
"mysql" -> "mysql-5.5.50-linux2.6-x86_64"
[root@Hao src]# cd mysql
[root@Hao mysql]# chown -R mysql:mysql .
[root@Hao mysql]# scripts/mysql_install_db --user=mysql --datadir=/mydata/data
[root@Hao mysql]# chown -R root .
为mysql提供主配置文件[root@Hao mysql]# cp support-files/my-large.cnf /etc/my.cnf
并且修改复制后的文件内的CPU个数的配置,我用的虚拟机,所以CPU个数为1,修改为CPU个数*2即可
# Try number of CPU's*2 for thread_concurrency
thread_concurrency = 2
为mysql提供sysv服务脚本
[root@Hao mysql]# cp support-files/mysql.server /etc/rc.d/init.d/mysqld
[root@Hao mysql]# chmod +x /etc/rc.d/init.d/mysqld
[root@Hao mysql]# chkconfig --add mysqld
[root@Hao mysql]# chkconfig mysqld on

4、建立httpd服务器(基于编译的方式进行),要求:

     提供两个基于名称的虚拟主机:

    (a)www1.stuX.com,页面文件目录为/web/vhosts/www1;错误日志为/var/log/httpd/www1.err,访问日志为/var/log/httpd/www1.access;

    (b)www2.stuX.com,页面文件目录为/web/vhosts/www2;错误日志为/var/log/httpd/www2.err,访问日志为/var/log/httpd/www2.access;

    (c)为两个虚拟主机建立各自的主页文件index.html,内容分别为其对应的主机名;

    (d)通过www1.stuX.com/server-status输出httpd工作状态相关信息,且只允许提供帐号密码才能访问(status:status);

先创建几个目录和文件:
mkdir /web/vhosts/www{1,2} -p
touch /var/log/httpd/www{1,2}.{err,access}

编辑配置文件/etc/httpd/conf/httpd.conf

NameVirtualHost 192.168.0.130:80
<VirtualHost192.168.0.130:80>
    DocumentRoot /web/vhosts/www1
    ServerName www1.stu31.com
    ErrorLog "/var/log/httpd/www1.err"
    CustomLog"/var/log/httpd/www1.access" combind
    <Location/server-status>                        /*
        SetHandler server-status
        Authtype   Basic
        Authname   "status area"                       这部分是用户认证配置
        AuthUserFile  /etc/httpd/users/.htpasswd
        Require valid-user
    </Location>                                    */
</VirtualHost>
 
<VirtualHost192.168.0.130:80>
    DocumentRoot /web/vhosts/www2
    ServerName www2.stu31.com
    ErrorLog"/var/log/httpd/www2.err"
    CustomLog"/var/log/httpd/www2.access" combind
</VirtualHost>

建立用户访问的认证文件:

# mkdir /etc/httpd/users
# htpasswd-c -m /etc/httpd/users/.htpasswd status
New password:
Re-type newpassword:
Adding passwordfor user status
然后重启服务
# service httpd restart

5、为第4题中的第2个虚拟主机提供https服务,使得用户可以通过https安全的访问此web站点;

   (1)要求使用证书认证,证书中要求使用的国家(CN)、州(HA)、城市(ZZ)和组织(MageEdu);

   (2)设置部门为Ops,主机名为www2.stuX.com,邮件为admin@stuX.com;

(a).建立私有CA认证服务器:
# cd /etc/pki/CA/
# (umask 077; openssl genrsa-out private/cakey.pem 2048)  
# openssl req -new -x509 -keyprivate/cakey.pem -out cacert.pem -days 3650
You are about to be asked to enterinformation that will be incorporated
into your certificate request.
What you are about to enter is what iscalled a Distinguished Name or a DN.
There are quite a few fields but you canleave some blank
For some fields there will be a defaultvalue,
If you enter '.', the field will be leftblank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [DefaultCompany Ltd]:Magedu
Organizational Unit Name (eg, section)[]:Ops
Common Name (eg, your name or your server'shostname) []:www2.stu31.com
Email Address []:admin@stuX.com
# touch index.txt
# touch serial
# echo 01 >serial
(b).给http服务器生成证书
# mkdir /etc/httpd/certs
# cd /etc/httpd/certs
# (umask 077; opensslgenrsa -out httpd.key 2048)
# openssl req -new -keyhttpd.key -out httpd.csr -days 3650
You are about to be asked to enterinformation that will be incorporated
into your certificate request.
What you are about to enter is what iscalled a Distinguished Name or a DN.
There are quite a few fields but you canleave some blank
For some fields there will be a defaultvalue,
If you enter '.', the field will be leftblank.
-----
Country Name (2 letter code) [XX]:CN
State or Province Name (full name) []:HA
Locality Name (eg, city) [Default City]:ZZ
Organization Name (eg, company) [DefaultCompany Ltd]:Magedu
Organizational Unit Name (eg, section)[]:Ops
Common Name (eg, your name or your server'shostname) []:www2.stu31.com
Email Address []:admin@stuX.com
 
Please enter the following 'extra'attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
(c) 配置httpd服务使用数字证书
#CA服务器签署请求证书
[root@www certs]# ls
httpd.csr httpd.key
[root@www certs]# openssl ca -in httpd.csr-out httpd.crt -days 3650
Using configuration from /etc/pki/tls/openssl.cnf
Check that the request matches thesignature
Signature ok
Certificate Details:
       Serial Number: 1 (0x1)
       Validity
           Not Before: Dec 13 05:30:19 2014 GMT
           Not After : Dec 10 05:30:19 2024 GMT
       Subject:
            countryName               = CN
           stateOrProvinceName       = HA
           organizationName          = stu31
           organizationalUnitName    = tech
           commonName                =www2.stu31.com
           emailAddress              = admin@stu31.com
       X509v3 extensions:
           X509v3 Basic Constraints:
                CA:FALSE
           Netscape Comment:
                OpenSSL Generated Certificate
           X509v3 Subject Key Identifier:
               9A:84:73:63:C0:82:7F:45:21:9C:BA:2B:4C:FB:C3:87:7C:BA:63:58
           X509v3 Authority Key Identifier:
               keyid:1C:57:C2:12:E4:D3:A6:4F:9A:7A:C6:53:7F:5B:7B:86:1E:75:0D:57
 
Certificate is to be certified until Dec 1005:30:19 2024 GMT (3650 days)
Sign the certificate? [y/n]:y
 
 
1 out of 1 certificate requests certified,commit? [y/n]y
Write out database with 1 new entries
Data Base Updated
 
(d)配置https服务器加密传输
针对Apache httpd软件默认配置中:
httpd软件默认没有使用ssl模块,需要安装相应的模块程序包
[root@www certs]# yum install mod_ssl -y
[root@www ~]# rpm -qa mod_ssl
mod_ssl-2.2.15-39.el6.centos.x86_64
 
安装之后会在/etc/httpd/conf.d/目录下生成ssl.conf的配置文件,我们配置https就在此文件中配置:
[root@www conf.d]# ls
mod_dnssd.conf  README ssl.conf  welcome.conf
 
配置ssl.conf文件,重要配置都在下面文件中了:
[root@www conf.d]#vim  /etc/httpd/conf.d/ssl.conf
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost 192.168.0.130:443>
         DocumentRoot"/web/vhosts/www2"
         ServerName  www2.stuX.com:443
         SSLEngineon
         SSLCertificateFile  /etc/httpd/certs/httpd.crt
         SSLCertificateKeyFile  /etc/httpd/certs/httpd.key
</VirtualHost>

6、在LAMP架构中,请分别以php编译成httpd模块形式和php以fpm工作为独立守护进程的方式来支持httpd,列出详细的过程。

# yum -y install pcre-devel     //先安装好必要的,省的一会报错
编译安装apr
# tar xf apr-1.5.2.tar.bz2
# cd apr-1.5.2
# ./configure –prefix=/usr/local/apr
# make && make install
编译安装apr-util
# tar xf apr-util-1.5.4.tar.bz2
# cd apr-util-1.5.4
# ./configure –prefix=/usr/local/apr-util –with-apr=/usr/local/apr
# make && make install
编译httpd:
# tar xf httpd-2.4.23.tar.bz2
# cd httpd-2.4.23
# ./configure –prefix=/usr/local/apache –sysconfdir=/etc/http24 –enable-so –enable-modules=most –enable-mods-shared=most –# enable-proxy –enable-proxy-fcgi –enable-mpms-shared=all –enable-cgi –with-apr=/usr/local/apr –with-apr-util=/usr/local/apr-util –with-z –with-ssl –with-mpm=event –enable-rewrite
# make && make install
编辑配置文件vim /etc/http24/httpd.conf,加入一下内容:
DirectoryIndex index.php index.html
AddType application/x-httpd-php .php
AddType application/x-httpd-php-source .phps

给http提供服务脚本

#!/bin/bash
#
# httpd        Startup script for the Apache HTTP Server
#
# chkconfig: – 85 15
# description: Apache is a World Wide Web server.  It is used to serve \
#        HTML files and CGI.
# processname: httpd
# config: /etc/httpd/conf/httpd.conf
# config: /etc/sysconfig/httpd
# pidfile: /var/run/httpd.pid

# 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 swallowing up a pass-phrase prompt if
# mod_ssl needs a pass-phrase from the user.
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, server binary, 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.pid}
lockfile=${LOCKFILE-/var/lock/subsys/httpd}
RETVAL=0

start() {
        echo -n $"Starting $prog: "
        LANG=$HTTPD_LANG daemon –pidfile=${pidfile} $httpd $OPTIONS
        RETVAL=$?
        echo
        [ $RETVAL = 0 ] && touch ${lockfile}
        return $RETVAL
}

stop() {
  echo -n $"Stopping $prog: "
  killproc -p ${pidfile} -d 10 $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=$?
        echo $"not reloading due to configuration syntax error"
        failure $"not reloading $httpd due to configuration syntax error"
    else
        killproc -p ${pidfile} $httpd -HUP
        RETVAL=$?
    fi
    echo
}

# See how we were called.
case "$1" in
  start)
  start
  ;;
  stop)
  stop
  ;;
  status)
        status -p ${pidfile} $httpd
  RETVAL=$?
  ;;
  restart)
  stop
  start
  ;;
  condrestart)
  if [ -f ${pidfile} ] ; then
    stop
    start
  fi
  ;;
  reload)
        reload
  ;;
  graceful|help|configtest|fullstatus)
  $apachectl $@
  RETVAL=$?
  ;;
  *)
  echo $"Usage: $prog {start|stop|restart|condrestart|reload|status|fullstatus|graceful|help|configtest}"
  exit 1
esac

exit $RETVAL

然后把脚本加入服务中:

chmod +x /etc/init.d/httpd24
chkconfig –add httpd24
service httpd24 start

在192.168.0.131主机上安装mariadb,二进制包安装。

# tar zxvf mariadb-5.5.36-linux-x86_64.tar.gz
# mv mariadb-5.5.36-linux-x86_64 /usr/local/
# ln -sv /usr/local/mariadb-5.5.36-linux-x86_64 /usr/local/mysql
# `/usr/local/mysql' -> `/usr/local/mariadb-5.5.36-linux-x86_64'
# mkdir /etc/mysql
# cp /usr/local/mysql/support-files/my-large.cnf /etc/mysql/my.cnf
编译这个配置文件,加入 datadir=/data
然后,我们需要创建这个数据库的数据目录:
# mkdir /data
# groupadd -r mysql
# useradd -r -g mysql mysql
# chown mysql:mysql /data
# cd /usr/local/mysql
# chown -R mysql:mysql ./
然后,我们就要进行数据库的初始化:
# ./scripts/mysql_install_db –user=mysql –datadir=/data –basedir=/usr/local/mysql
我们要为数据库提供服务脚本:
# cp support-files/mysql.server /etc/init.d/mysqld
把这个脚本放到服务脚本中去:
# chmod +x /etc/init.d/mysqld
# chkconfig –add mysqld
# service mysqld start

修改mysql的PATH环境变量

# vim /etc/profile.d/mysql.sh
内容如下:
export PATH=/usr/local/mysql/bin:$PATH
# mysql
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.36-MariaDB-log MariaDB Server
Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>
表明我们已经可以用mysql客户端登进服务器端了,我们为了等一下的测试先创建一个用户:
MariaDB [(none)]> grant all on *.* to 'liang'@192.168.0.131 identified by 'liang';
Query OK, 0 rows affected (0.01 sec)
MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec)
然后,我们可以退出了!

切换到192.168.0.130的php服务器上:

# yum install -y libxml2-devel
# yum -y install bzip2-devel libmcrypt-devel
# tar xf php-5.4.19.tar.bz2
# cd php-5.4.19
# ./configure –prefix=/usr/local/php –with-apxs2=/usr/local/apache/bin/apxs –with-config-file-path=/etc –with-config-file-scan-dir=/etc/php.d –with-libxml-dir=/usr –with-zlib –with-bz2 –enable-xml –with-jpeg-dir –with-png-dir –with-freetype-dir –enable-mbstring –with-mcrypt –enable-sockets –with-mysql=mysqlnd –with-mysqli=mysqlnd –with-pdo-mysql=mysqlnd –enable-maintainer-zts
# cp php.ini-production /etc/php.ini
# vim /usr/local/apache/htdocs/index.php   内容如下:
    <?php
        phpinfo();
    ?>
    <?php
        $con=mysql_connect('192.168.236.129','bwei','bwei');
        if($con)
        echo "ok!!";
        else
        echo "false!!";
        mysql_close();
    ?>
我们给php解析器加上组件xcache,先编译xcache:
# tar xf xcache-3.1.0.tar.bz2
# cd xcache-3.1.0
# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
这是为了xcache提供configure文件。
# ./configure –enable-xcache –with-php-config=/usr/local/php/bin/php-config –sysconfdir=/etc/php.d
# make && make install
安装后,会出现这个 Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-zts-20100525/
我们把这个路径复制一下,然后,把这个路径下的模块写到xcacahe的配置文件下:
# mkdir /etc/php.d
# cp xcache.ini /etc/php.d/
# vim /etc/php.d/xcache.ini
修改下面项:
extension =/usr/local/php/lib/php/extensions/no-debug-zts-20100525/xcache.so
重启一下服务器:service httpd24 restart
然后,我们在上面安装一个phpadmin:
# unzip phpMyAdmin-4.0.5-all-languages.zip
# mv phpMyAdmin-4.0.5-all-languages /usr/local/apache/htdocs/phpadmin
# cd /usr/local/apache/htdocs/phpadmin/
提供phpadmin的配置文件:
# cp config.sample.inc.php config.inc.php
编辑这个配置文件,修改这一项:
$cfg['Servers'][$i]['host'] = '192.168.236.129';

基于fpm的PHP

http服务器:192.168.0.130;php解析器 mysql服务器:192.168.0.131

cp sapi/fpm/init.d.php-fpm /etc/init.d/fpm
chmod +x /etc/init.d/fpm
chkconfig –add fpm
给php解析器提供配置文件:
cp php.ini-production /etc/php.ini
为fpm提供服务配置文件:
cp /usr/local/php/etc/php-fpm.conf.default /usr/local/php/etc/php-fpm.conf
编辑这个配置文件,修改以下几项:
listen = 192.168.236.129:9000
pm.max_children = 30
pm.start_servers = 5
pm.min_spare_servers = 5
pm.max_spare_servers = 8
启动服务:service fpm start
ss -tnlp 查看服务是否开启:
users:(("master",1947,12))
LISTEN      0      128                                                                192.168.0.131:9000                                                                            *:*      users:(("php-fpm",122099,7),("php-fpm",122100,0),("php-fpm",122101,0),("php-fpm",122102,0),("php-fpm",122103,0),("php-fpm",122104,0))
好了,我们再为php解析器提供xcache:
tar xf xcache-3.1.0.tar.bz2
cd xcache-3.1.0
# /usr/local/php/bin/phpize 
Configuring for:
PHP Api Version:         20100412
Zend Module Api No:      20100525
Zend Extension Api No:   220100525
这是为了xcache提供configure文件。
./configure –enable-xcache –with-php-config=/usr/local/php/bin/php-config –sysconfdir=/etc/php.d
make && make install
Installing shared extensions:     /usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/
我们把这个路径复制一下,然后,把这个路径下的模块写到xcacahe的配置文件下:
mkdir /etc/php.d
cp xcache.ini /etc/php.d/
vim /etc/php.d/xcache.ini
修改下面项:
extension =/usr/local/php/lib/php/extensions/no-debug-non-zts-20100525/xcache.so
重启一下服务:
service fpm restartservice fpm restart
配置http主机(192.168.0.130)
vim /etc/http24/httpd.conf
把这项注释(表示不启用php解析器作为http功能里):
#LoadModule php5_module        modules/libphp5.so
把下面的功能启动:
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so
然后在后面的配置文件中增加以下配置:
ProxyRequests Off
ProxyPassMatch  ^/(.*\.php)$ fcgi://192.168.0.131:9000/php/$1
切换到php解析器的主机,为这个主机提供phpadmin作为测试:
mkdir /php
mv phpMyAdmin-4.0.5-all-languages /php/phpadmin
cd /php/phpadmin/
提供phpadmin的配置文件:
cp config.sample.inc.php config.inc.php

原创文章,作者:Net19_口香糖,如若转载,请注明出处:http://www.178linux.com/30854

(0)
上一篇 2016-08-22 09:29
下一篇 2016-08-22 09:29

相关推荐

  • 文本处理三剑客之sed

    概述     经过上篇对正则表达式和grep相关内容的学习,我们对文本处理有了一个初步的认识,本篇将简要介绍一下文本处理三剑客之sed。具体分为以下几个部分:     1、sed原理概述     2、sed命令详解 第一部分 &n…

    Linux干货 2016-08-10
  • 网络班N22期第五周博客作业

    1、显示当前系统上root、fedora或user1用户的默认shell; [root@bogon ~]# cat /etc/passwd | grep -E "^(root|fedora|user1)\>" | cut -d:&nb…

    Linux干货 2016-09-15
  • old notes

    yum update: update software guest edition ***: how to install guest edition: 1) need to root: su – 2) yum install kernel-devel 3)yum install gcc* ( when don't remember n…

    Linux干货 2016-09-19
  • GNU awk

    文本处理三工具:grep, sed, awk grep, egrep, fgrep:文本过滤工具;pattern sed: 行编辑器 模式空间、保持空间 awk:报告生成器,格式化文本输出;  AWK: Aho, Weinberger, Kernighan –> New AWK, NAWK  GNU awk, gawk&…

    Linux干货 2015-12-03
  • 文件处理工具系列(二):行编辑器sed

    1、sed介绍     sed(Stream EDitor),是一种行编辑工具,它一次处理一行内容。处理时,把当前匹配到的行存储在临时缓冲区中,称为“模式空间”(pattern space),接着用sed命令对这些数据做出相应的增删改查操作,处理完成后,默认输出至屏幕,而未被匹配到的行也将默认输出至屏幕。而原来的文件内容并没有发生改变,除…

    Linux干货 2016-08-11
  • Lnmp安装脚本

    1、源码编译安装LNMP架构环境; 此题略 此链接为安装nginx时,编译参数和各个模块和第三方模块的介绍,十分丰富,安装前可以参考学习 https://www.nginx.com/resources/admin-guide/installing-nginx-open-source/ 2、编写一个脚本完成以下功能:    (1)、一键搭建…

    Linux干货 2016-12-05

评论列表(1条)

  • 马哥教育
    马哥教育 2016-08-22 15:16

    写的很好,排版还可以在漂亮一点,加油,都出界了